diff --git a/webrtc/common_audio/BUILD.gn b/webrtc/common_audio/BUILD.gn index a26d74b0ec..39702dc13c 100644 --- a/webrtc/common_audio/BUILD.gn +++ b/webrtc/common_audio/BUILD.gn @@ -289,7 +289,7 @@ if (rtc_include_tests) { deps = [ ":common_audio", - "../test:test_support_main", + "../test:test_main", "//testing/gmock", "//testing/gtest", ] diff --git a/webrtc/common_audio/resampler/sinc_resampler_unittest.cc b/webrtc/common_audio/resampler/sinc_resampler_unittest.cc index c7e84fc2c7..35c5d22b08 100644 --- a/webrtc/common_audio/resampler/sinc_resampler_unittest.cc +++ b/webrtc/common_audio/resampler/sinc_resampler_unittest.cc @@ -25,7 +25,6 @@ #include "webrtc/system_wrappers/include/stringize_macros.h" #include "webrtc/test/gmock.h" #include "webrtc/test/gtest.h" -#include "webrtc/test/test_suite.h" using testing::_; diff --git a/webrtc/common_video/BUILD.gn b/webrtc/common_video/BUILD.gn index 34cb6d6a3d..0aefefd193 100644 --- a/webrtc/common_video/BUILD.gn +++ b/webrtc/common_video/BUILD.gn @@ -119,7 +119,7 @@ if (rtc_include_tests) { deps = [ ":common_video", "../system_wrappers:system_wrappers", - "../test:test_support_main", + "../test:test_main", "../test:video_test_common", "//testing/gmock", "//testing/gtest", diff --git a/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc b/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc index 5ca885cd54..3bff88769b 100644 --- a/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/webrtc/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -28,7 +28,6 @@ #include "webrtc/modules/rtp_rtcp/source/rtp_packet_to_send.h" #include "webrtc/system_wrappers/include/clock.h" #include "webrtc/test/gtest.h" -#include "webrtc/test/test_suite.h" #include "webrtc/test/testsupport/fileutils.h" // Files generated at build-time by the protobuf compiler. diff --git a/webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.cc b/webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.cc index 88bc9ba887..fb60dbcc05 100644 --- a/webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.cc +++ b/webrtc/logging/rtc_event_log/rtc_event_log_unittest_helper.cc @@ -16,7 +16,6 @@ #include "webrtc/base/checks.h" #include "webrtc/test/gtest.h" -#include "webrtc/test/test_suite.h" #include "webrtc/test/testsupport/fileutils.h" // Files generated at build-time by the protobuf compiler. diff --git a/webrtc/modules/BUILD.gn b/webrtc/modules/BUILD.gn index 1708c15988..3437e6e30c 100644 --- a/webrtc/modules/BUILD.gn +++ b/webrtc/modules/BUILD.gn @@ -74,8 +74,8 @@ if (rtc_include_tests) { "../modules/video_coding", "../modules/video_coding:video_codecs_test_framework", "../system_wrappers", + "../test:test_main", "../test:test_support", - "../test:test_support_main", "//testing/gmock", "//testing/gtest", ] @@ -649,8 +649,8 @@ if (rtc_include_tests) { "../system_wrappers", "../test:rtp_test_utils", "../test:test_common", + "../test:test_main", "../test:test_support", - "../test:test_support_main", "../test:video_test_common", "audio_coding", "audio_coding:acm_receive_test", @@ -750,7 +750,7 @@ if (rtc_include_tests) { "..:webrtc_common", "../base:rtc_base_approved", "../test:test_common", - "../test:test_support_main", + "../test:test_main", "remote_bitrate_estimator:bwe_simulator_lib", "video_capture", "//testing/gmock", diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn index 7bd8adfd8d..77a9c3e264 100644 --- a/webrtc/modules/audio_coding/BUILD.gn +++ b/webrtc/modules/audio_coding/BUILD.gn @@ -1075,7 +1075,7 @@ if (rtc_include_tests) { ":neteq", ":neteq_unittest_tools", "../../common_audio", - "../../test:test_support_main", + "../../test:test_main", "//testing/gtest", ] @@ -1173,7 +1173,7 @@ if (rtc_include_tests) { ":isac_fix", ":webrtc_opus", "../../system_wrappers:system_wrappers_default", - "../../test:test_support_main", + "../../test:test_main", "../audio_processing", "//testing/gtest", ] @@ -1451,7 +1451,7 @@ if (rtc_include_tests) { ":neteq_quality_test_support", ":neteq_unittest_tools", ":webrtc_opus", - "../../test:test_support_main", + "../../test:test_main", "//testing/gtest", "//third_party/gflags", ] @@ -1498,7 +1498,7 @@ if (rtc_include_tests) { ":neteq_quality_test_support", ":neteq_unittest_tools", "../../system_wrappers:system_wrappers_default", - "../../test:test_support_main", + "../../test:test_main", "//testing/gtest", "//third_party/gflags", ] @@ -1515,7 +1515,7 @@ if (rtc_include_tests) { ":isac_fix", ":neteq", ":neteq_quality_test_support", - "../../test:test_support_main", + "../../test:test_main", "//testing/gtest", "//third_party/gflags", ] @@ -1532,7 +1532,7 @@ if (rtc_include_tests) { ":g711", ":neteq", ":neteq_quality_test_support", - "../../test:test_support_main", + "../../test:test_main", "//testing/gtest", "//third_party/gflags", ] @@ -1678,8 +1678,8 @@ if (rtc_include_tests) { ":webrtc_opus", "../../base:rtc_base_approved", "../../common_audio", + "../../test:test_main", "../../test:test_support", - "../../test:test_support_main", "//testing/gtest", ] diff --git a/webrtc/modules/audio_coding/acm2/acm_receiver_unittest.cc b/webrtc/modules/audio_coding/acm2/acm_receiver_unittest.cc index ce7e8fcb7c..92a06b2ade 100644 --- a/webrtc/modules/audio_coding/acm2/acm_receiver_unittest.cc +++ b/webrtc/modules/audio_coding/acm2/acm_receiver_unittest.cc @@ -20,7 +20,6 @@ #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" #include "webrtc/system_wrappers/include/clock.h" #include "webrtc/test/gtest.h" -#include "webrtc/test/test_suite.h" #include "webrtc/test/testsupport/fileutils.h" namespace webrtc { diff --git a/webrtc/modules/audio_device/BUILD.gn b/webrtc/modules/audio_device/BUILD.gn index 7a0bce0736..1dee9437d3 100644 --- a/webrtc/modules/audio_device/BUILD.gn +++ b/webrtc/modules/audio_device/BUILD.gn @@ -282,8 +282,8 @@ if (rtc_include_tests && !is_ios) { ":audio_device", "../..:webrtc_common", "../../system_wrappers", + "../../test:test_main", "../../test:test_support", - "../../test:test_support_main", "../rtp_rtcp", "../utility", "//testing/gtest", diff --git a/webrtc/modules/rtp_rtcp/BUILD.gn b/webrtc/modules/rtp_rtcp/BUILD.gn index 50d8b193ed..80f79c1764 100644 --- a/webrtc/modules/rtp_rtcp/BUILD.gn +++ b/webrtc/modules/rtp_rtcp/BUILD.gn @@ -203,7 +203,7 @@ if (rtc_include_tests) { deps = [ ":rtp_rtcp", "//testing/gtest", - "//webrtc/test:test_support_main", + "//webrtc/test:test_main", ] } # test_packet_masks_metrics } diff --git a/webrtc/modules/video_capture/BUILD.gn b/webrtc/modules/video_capture/BUILD.gn index 03a8d384da..887bd2c2bf 100644 --- a/webrtc/modules/video_capture/BUILD.gn +++ b/webrtc/modules/video_capture/BUILD.gn @@ -187,7 +187,7 @@ if (!build_with_chromium) { "../utility", "//testing/gtest", ] - deps += [ "//webrtc/test:test_support_main" ] + deps += [ "//webrtc/test:test_main" ] if (!build_with_chromium && is_clang) { # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). diff --git a/webrtc/system_wrappers/BUILD.gn b/webrtc/system_wrappers/BUILD.gn index 8bed25e274..df6de0ad47 100644 --- a/webrtc/system_wrappers/BUILD.gn +++ b/webrtc/system_wrappers/BUILD.gn @@ -196,7 +196,7 @@ if (rtc_include_tests) { deps = [ ":metrics_default", ":system_wrappers", - "../test:test_support_main", + "../test:test_main", "//testing/gtest", ] diff --git a/webrtc/test/BUILD.gn b/webrtc/test/BUILD.gn index c6f2f4d2e6..1b3c05973a 100644 --- a/webrtc/test/BUILD.gn +++ b/webrtc/test/BUILD.gn @@ -22,9 +22,9 @@ group("test") { ":field_trial", ":rtp_test_utils", ":test_common", + ":test_main", ":test_renderer", ":test_support", - ":test_support_main", ":test_support_unittests", ":video_test_common", ] @@ -98,6 +98,7 @@ rtc_source_set("test_main") { ":field_trial", ":test_support", "../system_wrappers:metrics_default", + "//testing/gmock", "//testing/gtest", "//third_party/gflags", ] @@ -163,46 +164,6 @@ rtc_source_set("test_support") { } } -# Depend on this target when you want to have test_support but also the -# main method needed for gtest to execute! -rtc_source_set("test_support_main") { - testonly = true - - sources = [ - "run_all_unittests.cc", - "test_suite.cc", - "test_suite.h", - ] - - deps = [ - ":field_trial", - ":test_support", - "../system_wrappers:metrics_default", - "//testing/gmock", - "//testing/gtest", - "//third_party/gflags", - ] -} - -# Depend on this target when you want to have test_support and a special -# main for mac which will run your test on a worker thread and consume -# events on the main thread. Useful if you want to access a webcam. -# This main will provide all the scaffolding and objective-c black magic -# for you. All you need to do is to implement a function in the -# run_threaded_main_mac.h file (ImplementThisToRunYourTest). -rtc_source_set("test_support_main_threaded_mac") { - testonly = true - - sources = [ - "testsupport/mac/run_threaded_main_mac.h", - "testsupport/mac/run_threaded_main_mac.mm", - ] - - deps = [ - ":test_support", - ] -} - rtc_source_set("run_test") { testonly = true sources = [ @@ -276,7 +237,7 @@ rtc_test("test_support_unittests") { deps += [ ":test_common", - ":test_support_main", + ":test_main", "../modules/video_capture", "//testing/gmock", "//testing/gtest", diff --git a/webrtc/test/run_all_unittests.cc b/webrtc/test/run_all_unittests.cc deleted file mode 100644 index 486df5ea8c..0000000000 --- a/webrtc/test/run_all_unittests.cc +++ /dev/null @@ -1,16 +0,0 @@ -/* - * 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 "webrtc/test/test_suite.h" - -int main(int argc, char** argv) { - webrtc::test::TestSuite test_suite(argc, argv); - return test_suite.Run(); -} diff --git a/webrtc/test/test_main.cc b/webrtc/test/test_main.cc index b75e78c9dd..1b1cdba789 100644 --- a/webrtc/test/test_main.cc +++ b/webrtc/test/test_main.cc @@ -12,8 +12,12 @@ #include "webrtc/base/logging.h" #include "webrtc/system_wrappers/include/metrics_default.h" #include "webrtc/test/field_trial.h" +#include "webrtc/test/gmock.h" #include "webrtc/test/gtest.h" #include "webrtc/test/testsupport/fileutils.h" +#include "webrtc/test/testsupport/trace_to_stderr.h" + +DEFINE_bool(logs, false, "print logs to stderr"); DEFINE_string(force_fieldtrials, "", "Field trials control experimental feature code which can be forced. " @@ -21,7 +25,7 @@ DEFINE_string(force_fieldtrials, "", " will assign the group Enable to field trial WebRTC-FooFeature."); int main(int argc, char* argv[]) { - ::testing::InitGoogleTest(&argc, argv); + ::testing::InitGoogleMock(&argc, argv); // Default to LS_INFO, even for release builds to provide better test logging. // TODO(pbos): Consider adding a command-line override. @@ -36,5 +40,11 @@ int main(int argc, char* argv[]) { webrtc::test::SetExecutablePath(argv[0]); webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials); webrtc::metrics::Enable(); + + rtc::LogMessage::SetLogToStderr(FLAGS_logs); + std::unique_ptr trace_to_stderr; + if (FLAGS_logs) + trace_to_stderr.reset(new webrtc::test::TraceToStderr); + return RUN_ALL_TESTS(); } diff --git a/webrtc/test/test_suite.cc b/webrtc/test/test_suite.cc deleted file mode 100644 index e7adfc8ec5..0000000000 --- a/webrtc/test/test_suite.cc +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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 "webrtc/test/test_suite.h" - -#include "gflags/gflags.h" -#include "webrtc/base/logging.h" -#include "webrtc/system_wrappers/include/metrics_default.h" -#include "webrtc/test/field_trial.h" -#include "webrtc/test/gmock.h" -#include "webrtc/test/gtest.h" -#include "webrtc/test/testsupport/fileutils.h" -#include "webrtc/test/testsupport/trace_to_stderr.h" - -DEFINE_bool(logs, false, "print logs to stderr"); - -DEFINE_string(force_fieldtrials, "", - "Field trials control experimental feature code which can be forced. " - "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" - " will assign the group Enable to field trial WebRTC-FooFeature."); - -namespace webrtc { -namespace test { - -TestSuite::TestSuite(int argc, char** argv) { - SetExecutablePath(argv[0]); - testing::InitGoogleMock(&argc, argv); // Runs InitGoogleTest() internally. - // AllowCommandLineParsing allows us to ignore flags passed on to us by - // Chromium build bots without having to explicitly disable them. - google::AllowCommandLineReparsing(); - google::ParseCommandLineFlags(&argc, &argv, true); - - webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials); - webrtc::metrics::Enable(); -} - -TestSuite::~TestSuite() { -} - -int TestSuite::Run() { - Initialize(); - int result = RUN_ALL_TESTS(); - Shutdown(); - return result; -} - -void TestSuite::Initialize() { - rtc::LogMessage::SetLogToStderr(FLAGS_logs); - if (FLAGS_logs) - trace_to_stderr_.reset(new TraceToStderr); -} - -void TestSuite::Shutdown() { -} - -} // namespace test -} // namespace webrtc diff --git a/webrtc/test/test_suite.h b/webrtc/test/test_suite.h deleted file mode 100644 index 4b27f9f2c3..0000000000 --- a/webrtc/test/test_suite.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 WEBRTC_TEST_TEST_SUITE_H_ -#define WEBRTC_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 - -#include "webrtc/base/constructormagic.h" - -namespace webrtc { -namespace test { - -class TraceToStderr; - -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(); - - RTC_DISALLOW_COPY_AND_ASSIGN(TestSuite); - - private: - std::unique_ptr trace_to_stderr_; -}; - -} // namespace test -} // namespace webrtc - -#endif // TEST_TEST_SUITE_H_ diff --git a/webrtc/test/testsupport/mac/run_threaded_main_mac.h b/webrtc/test/testsupport/mac/run_threaded_main_mac.h deleted file mode 100644 index c8cc4bbaeb..0000000000 --- a/webrtc/test/testsupport/mac/run_threaded_main_mac.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -/** - * This file and its corresponding .mm file implement a main function on Mac. - * It's useful if you need to access a webcam in your Mac application. The code - * forks a worker thread which runs the below ImplementThisToRunYourTest - * function, and uses the main thread to pump messages. That way we can run our - * code in a regular sequential fashion and still pump events, which are - * necessary to access the webcam for instance. - */ - -// Implement this method to do whatever you want to do in the worker thread. -// The argc and argv variables are the unmodified command line from main. -int ImplementThisToRunYourTest(int argc, char** argv); diff --git a/webrtc/test/testsupport/mac/run_threaded_main_mac.mm b/webrtc/test/testsupport/mac/run_threaded_main_mac.mm deleted file mode 100644 index 4a908fbf2d..0000000000 --- a/webrtc/test/testsupport/mac/run_threaded_main_mac.mm +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2012 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. - */ - -#import "webrtc/test/testsupport/mac/run_threaded_main_mac.h" - -#import - -// This class passes parameter from main to the worked thread and back. -@interface AutoTestInWorkerThread : NSObject { - int argc_; - char** argv_; - int result_; - bool done_; -} - -- (void)setDone:(bool)done; -- (bool)done; -- (void)setArgc:(int)argc argv:(char**)argv; -- (int) result; -- (void)runTest:(NSObject*)ignored; - -@end - -@implementation AutoTestInWorkerThread - -- (void)setDone:(bool)done { - done_ = done; -} - -- (bool)done { - return done_; -} - -- (void)setArgc:(int)argc argv:(char**)argv { - argc_ = argc; - argv_ = argv; -} - -- (void)runTest:(NSObject*)ignored { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - result_ = ImplementThisToRunYourTest(argc_, argv_); - done_ = true; - - [pool release]; - return; -} - -- (int)result { - return result_; -} - -@end - -int main(int argc, char * argv[]) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - [NSApplication sharedApplication]; - - int result = 0; - AutoTestInWorkerThread* tests = [[AutoTestInWorkerThread alloc] init]; - - [tests setArgc:argc argv:argv]; - [tests setDone:false]; - - [NSThread detachNewThreadSelector:@selector(runTest:) - toTarget:tests - withObject:nil]; - - NSRunLoop* main_run_loop = [NSRunLoop mainRunLoop]; - NSDate *loop_until = [NSDate dateWithTimeIntervalSinceNow:0.1]; - bool runloop_ok = true; - while (![tests done] && runloop_ok) { - runloop_ok = [main_run_loop runMode:NSDefaultRunLoopMode - beforeDate:loop_until]; - loop_until = [NSDate dateWithTimeIntervalSinceNow:0.1]; - } - - result = [tests result]; - - [pool release]; - return result; -} diff --git a/webrtc/tools/BUILD.gn b/webrtc/tools/BUILD.gn index 565a0a2d66..5353ba8e8a 100644 --- a/webrtc/tools/BUILD.gn +++ b/webrtc/tools/BUILD.gn @@ -271,7 +271,7 @@ if (rtc_include_tests) { ":command_line_parser", ":frame_editing_lib", ":video_quality_analysis", - "../test:test_support_main", + "../test:test_main", "//testing/gtest", ] diff --git a/webrtc/voice_engine/BUILD.gn b/webrtc/voice_engine/BUILD.gn index 0cdca05b10..f68b6423d9 100644 --- a/webrtc/voice_engine/BUILD.gn +++ b/webrtc/voice_engine/BUILD.gn @@ -199,7 +199,7 @@ if (rtc_include_tests) { "//webrtc/modules/rtp_rtcp", "//webrtc/modules/utility", "//webrtc/system_wrappers", - "//webrtc/test:test_support_main", + "//webrtc/test:test_main", ] if (is_android) { diff --git a/webrtc/voice_engine/test/auto_test/standard/codec_test.cc b/webrtc/voice_engine/test/auto_test/standard/codec_test.cc index dad03baf7f..a263a59213 100644 --- a/webrtc/voice_engine/test/auto_test/standard/codec_test.cc +++ b/webrtc/voice_engine/test/auto_test/standard/codec_test.cc @@ -11,7 +11,6 @@ #include #include -#include "webrtc/test/test_suite.h" #include "webrtc/test/testsupport/fileutils.h" #include "webrtc/voice_engine/test/auto_test/fixtures/after_streaming_fixture.h" #include "webrtc/voice_engine/voice_engine_defines.h"