Add a unit testing framework.

Populate it with the beginnings of a resampler unit test to have it do someting.

Also fix a bug in resampler caught with the test ;)
Review URL: http://webrtc-codereview.appspot.com/135019

git-svn-id: http://webrtc.googlecode.com/svn/trunk@595 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org
2011-09-14 17:02:44 +00:00
parent b524f441d0
commit 19eefdc9f0
9 changed files with 278 additions and 19 deletions

16
test/run_all_unittests.cc Normal file
View File

@@ -0,0 +1,16 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "test/test_suite.h"
int main(int argc, char** argv) {
webrtc::TestSuite test_suite(argc, argv);
return test_suite.Run();
}

27
test/test.gyp Normal file
View File

@@ -0,0 +1,27 @@
# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.
# TODO(andrew): consider moving test_support to src/base/test.
{
'includes': [
'../src/build/common.gypi',
],
'targets': [
{
'target_name': 'test_support',
'type': 'static_library',
'dependencies': [
'../testing/gtest.gyp:gtest',
],
'sources': [
'test_suite.cc',
'test_suite.h',
],
},
],
}

36
test/test_suite.cc Normal file
View File

@@ -0,0 +1,36 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "test/test_suite.h"
#include "gtest/gtest.h"
namespace webrtc {
TestSuite::TestSuite(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
}
TestSuite::~TestSuite() {
}
int TestSuite::Run() {
Initialize();
int result = RUN_ALL_TESTS();
Shutdown();
return result;
}
void TestSuite::Initialize() {
// TODO(andrew): initialize singletons here (e.g. Trace).
}
void TestSuite::Shutdown() {
}
} // namespace webrtc

40
test/test_suite.h Normal file
View File

@@ -0,0 +1,40 @@
/*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef TEST_TEST_SUITE_H_
#define TEST_TEST_SUITE_H_
// Derived from Chromium's src/base/test/test_suite.h.
// Defines a basic test suite framework for running gtest based tests. You can
// instantiate this class in your main function and call its Run method to run
// any gtest based tests that are linked into your executable.
#include "src/system_wrappers/interface/constructor_magic.h"
namespace webrtc {
class TestSuite {
public:
TestSuite(int argc, char** argv);
virtual ~TestSuite();
int Run();
protected:
// Override these for custom initialization and shutdown handling. Use these
// instead of putting complex code in your constructor/destructor.
virtual void Initialize();
virtual void Shutdown();
DISALLOW_COPY_AND_ASSIGN(TestSuite);
};
} // namespace webrtc
#endif // TEST_TEST_SUITE_H_