diff options
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/chrome_frame_unittest_main.cc | 31 | ||||
-rw-r--r-- | chrome_frame/test/run_all_unittests.cc | 52 |
2 files changed, 58 insertions, 25 deletions
diff --git a/chrome_frame/chrome_frame_unittest_main.cc b/chrome_frame/chrome_frame_unittest_main.cc index f8be06e..84523d8 100644 --- a/chrome_frame/chrome_frame_unittest_main.cc +++ b/chrome_frame/chrome_frame_unittest_main.cc @@ -9,6 +9,8 @@ #include "base/command_line.h" #include "base/process/kill.h" #include "base/process/process.h" +#include "base/test/launcher/unit_test_launcher.h" +#include "base/test/test_suite.h" #include "chrome_frame/crash_server_init.h" #include "chrome_frame/test/chrome_frame_test_utils.h" #include "gtest/gtest.h" @@ -26,23 +28,38 @@ void DeleteAllSingletons() { } } -int main(int argc, char** argv) { - testing::InitGoogleTest(&argc, argv); +namespace { + +class NoAtExitBaseTestSuite : public base::TestSuite { + public: + NoAtExitBaseTestSuite(int argc, char** argv) + : base::TestSuite(argc, argv, false) { + } +}; +int RunTests(int argc, char** argv) { base::AtExitManager at_exit_manager; g_at_exit_manager = &at_exit_manager; + NoAtExitBaseTestSuite test_suite(argc, argv); + int exit_code = test_suite.Run(); + g_at_exit_manager = NULL; + return exit_code; +} +} // namespace + +int main(int argc, char** argv) { base::ProcessHandle crash_service = chrome_frame_test::StartCrashService(); google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( InitializeCrashReporting(HEADLESS)); - CommandLine::Init(argc, argv); - - RUN_ALL_TESTS(); - - g_at_exit_manager = NULL; + int exit_code = base::LaunchUnitTests(argc, + argv, + base::Bind(&RunTests, argc, argv)); if (crash_service) base::KillProcess(crash_service, 0, false); + + return exit_code; } diff --git a/chrome_frame/test/run_all_unittests.cc b/chrome_frame/test/run_all_unittests.cc index 8d42783..c1deee4 100644 --- a/chrome_frame/test/run_all_unittests.cc +++ b/chrome_frame/test/run_all_unittests.cc @@ -7,6 +7,7 @@ #include "base/command_line.h" #include "base/process/kill.h" #include "base/process/memory.h" +#include "base/test/launcher/unit_test_launcher.h" #include "base/test/test_suite.h" #include "base/threading/platform_thread.h" #include "base/win/scoped_com_initializer.h" @@ -44,31 +45,17 @@ void PureCall() { __debugbreak(); } -int main(int argc, char **argv) { +namespace { + +int RunTests(int argc, char** argv) { // For ATL in VS2010 and up, ChromeFrameUnittestsModule::InitializeCom() is // not called, so we init COM here. base::win::ScopedCOMInitializer com_initializer_; ScopedChromeFrameRegistrar::RegisterAndExitProcessIfDirected(); - base::EnableTerminationOnHeapCorruption(); - base::PlatformThread::SetName("ChromeFrame tests"); - - _set_purecall_handler(PureCall); base::TestSuite test_suite(argc, argv); - SetConfigBool(kChromeFrameHeadlessMode, true); - SetConfigBool(kChromeFrameAccessibleMode, true); - - base::ProcessHandle crash_service = NULL; - google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad; - - if (!CommandLine::ForCurrentProcess()->HasSwitch(kNoCrashService)) { - crash_service = chrome_frame_test::StartCrashService(); - - breakpad.reset(InitializeCrashReporting(HEADLESS)); - } - // Install the log collector before anything else that adds a Google Test // event listener so that it's the last one to run after each test (the // listeners are invoked in reverse order at the end of a test). This allows @@ -101,10 +88,39 @@ int main(int argc, char **argv) { ret = test_suite.Run(); } + return ret; +} + +} // namespace + +int main(int argc, char **argv) { + CommandLine::Init(argc, argv); + + base::EnableTerminationOnHeapCorruption(); + + _set_purecall_handler(PureCall); + + SetConfigBool(kChromeFrameHeadlessMode, true); + SetConfigBool(kChromeFrameAccessibleMode, true); + + base::ProcessHandle crash_service = NULL; + google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad; + + if (!CommandLine::ForCurrentProcess()->HasSwitch(kNoCrashService)) { + crash_service = chrome_frame_test::StartCrashService(); + + breakpad.reset(InitializeCrashReporting(HEADLESS)); + } + + int exit_code = base::LaunchUnitTests(argc, + argv, + base::Bind(&RunTests, argc, argv)); + DeleteConfigValue(kChromeFrameHeadlessMode); DeleteConfigValue(kChromeFrameAccessibleMode); if (crash_service) base::KillProcess(crash_service, 0, false); - return ret; + + return exit_code; } |