| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_TEST_SUITE_H_ | 5 #ifndef BASE_TEST_SUITE_H_ |
| 6 #define BASE_TEST_SUITE_H_ | 6 #define BASE_TEST_SUITE_H_ |
| 7 | 7 |
| 8 // Defines a basic test suite framework for running gtest based tests. You can | 8 // Defines a basic test suite framework for running gtest based tests. You can |
| 9 // instantiate this class in your main function and call its Run method to run | 9 // instantiate this class in your main function and call its Run method to run |
| 10 // any gtest based tests that are linked into your executable. | 10 // any gtest based tests that are linked into your executable. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| 25 #include <windows.h> | 25 #include <windows.h> |
| 26 #elif defined(OS_LINUX) | 26 #elif defined(OS_LINUX) |
| 27 #include <gtk/gtk.h> | 27 #include <gtk/gtk.h> |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 class TestSuite { | 30 class TestSuite { |
| 31 public: | 31 public: |
| 32 TestSuite(int argc, char** argv) { | 32 TestSuite(int argc, char** argv) { |
| 33 base::EnableTerminationOnHeapCorruption(); | 33 base::EnableTerminationOnHeapCorruption(); |
| 34 CommandLine::SetArgcArgv(argc, argv); | 34 CommandLine::Init(argc, argv); |
| 35 testing::InitGoogleTest(&argc, argv); | 35 testing::InitGoogleTest(&argc, argv); |
| 36 #if defined(OS_LINUX) | 36 #if defined(OS_LINUX) |
| 37 gtk_init_check(&argc, &argv); | 37 gtk_init_check(&argc, &argv); |
| 38 #endif | 38 #endif |
| 39 // Don't add additional code to this constructor. Instead add it to | 39 // Don't add additional code to this constructor. Instead add it to |
| 40 // Initialize(). See bug 6436. | 40 // Initialize(). See bug 6436. |
| 41 } | 41 } |
| 42 | 42 |
| 43 virtual ~TestSuite() {} | 43 virtual ~TestSuite() {} |
| 44 | 44 |
| 45 // Don't add additional code to this method. Instead add it to | 45 // Don't add additional code to this method. Instead add it to |
| 46 // Initialize(). See bug 6436. | 46 // Initialize(). See bug 6436. |
| 47 int Run() { | 47 int Run() { |
| 48 base::ScopedNSAutoreleasePool scoped_pool; | 48 base::ScopedNSAutoreleasePool scoped_pool; |
| 49 | 49 |
| 50 Initialize(); | 50 Initialize(); |
| 51 std::wstring client_func = CommandLine().GetSwitchValue(kRunClientProcess); | 51 std::wstring client_func = |
| 52 CommandLine::ForCurrentProcess()->GetSwitchValue(kRunClientProcess); |
| 52 // Check to see if we are being run as a client process. | 53 // Check to see if we are being run as a client process. |
| 53 if (!client_func.empty()) { | 54 if (!client_func.empty()) { |
| 54 // Convert our function name to a usable string for GetProcAddress. | 55 // Convert our function name to a usable string for GetProcAddress. |
| 55 std::string func_name(client_func.begin(), client_func.end()); | 56 std::string func_name(client_func.begin(), client_func.end()); |
| 56 | 57 |
| 57 return multi_process_function_list::InvokeChildProcessTest(func_name); | 58 return multi_process_function_list::InvokeChildProcessTest(func_name); |
| 58 } | 59 } |
| 59 int result = RUN_ALL_TESTS(); | 60 int result = RUN_ALL_TESTS(); |
| 60 | 61 |
| 61 Shutdown(); | 62 Shutdown(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, | 95 logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, |
| 95 logging::LOCK_LOG_FILE, | 96 logging::LOCK_LOG_FILE, |
| 96 logging::DELETE_OLD_LOG_FILE); | 97 logging::DELETE_OLD_LOG_FILE); |
| 97 // We want process and thread IDs because we may have multiple processes. | 98 // We want process and thread IDs because we may have multiple processes. |
| 98 // Note: temporarily enabled timestamps in an effort to catch bug 6361. | 99 // Note: temporarily enabled timestamps in an effort to catch bug 6361. |
| 99 logging::SetLogItems(true, true, true, true); | 100 logging::SetLogItems(true, true, true, true); |
| 100 | 101 |
| 101 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
| 102 // In some cases, we do not want to see standard error dialogs. | 103 // In some cases, we do not want to see standard error dialogs. |
| 103 if (!IsDebuggerPresent() && | 104 if (!IsDebuggerPresent() && |
| 104 !CommandLine().HasSwitch(L"show-error-dialogs")) { | 105 !CommandLine::ForCurrentProcess()->HasSwitch(L"show-error-dialogs")) { |
| 105 SuppressErrorDialogs(); | 106 SuppressErrorDialogs(); |
| 106 logging::SetLogAssertHandler(UnitTestAssertHandler); | 107 logging::SetLogAssertHandler(UnitTestAssertHandler); |
| 107 } | 108 } |
| 108 #endif | 109 #endif |
| 109 | 110 |
| 110 icu_util::Initialize(); | 111 icu_util::Initialize(); |
| 111 } | 112 } |
| 112 | 113 |
| 113 virtual void Shutdown() { | 114 virtual void Shutdown() { |
| 114 } | 115 } |
| 115 | 116 |
| 116 // Make sure that we setup an AtExitManager so Singleton objects will be | 117 // Make sure that we setup an AtExitManager so Singleton objects will be |
| 117 // destroyed. | 118 // destroyed. |
| 118 base::AtExitManager at_exit_manager_; | 119 base::AtExitManager at_exit_manager_; |
| 119 }; | 120 }; |
| 120 | 121 |
| 121 #endif // BASE_TEST_SUITE_H_ | 122 #endif // BASE_TEST_SUITE_H_ |
| 122 | 123 |
| OLD | NEW |