OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/test/test_suite.h" | 5 #include "base/test/test_suite.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/debug_on_start_win.h" | 11 #include "base/debug/debug_on_start_win.h" |
12 #include "base/debug/debugger.h" | 12 #include "base/debug/debugger.h" |
13 #include "base/debug/stack_trace.h" | 13 #include "base/debug/stack_trace.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/i18n/icu_util.h" | 15 #include "base/i18n/icu_util.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/process_util.h" | 19 #include "base/process_util.h" |
20 #include "base/test/multiprocess_test.h" | 20 #include "base/test/multiprocess_test.h" |
21 #include "base/test/test_timeouts.h" | 21 #include "base/test/test_timeouts.h" |
22 #include "base/time.h" | 22 #include "base/time.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "testing/multiprocess_func_list.h" | 24 #include "testing/multiprocess_func_list.h" |
25 | 25 |
26 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
27 #include "base/mac/scoped_nsautorelease_pool.h" | 27 #include "base/mac/scoped_nsautorelease_pool.h" |
28 #if defined(OS_IOS) | 28 #if defined(OS_IOS) |
29 #include "base/test/run_hook_ios.h" | |
29 #include "base/test/test_listener_ios.h" | 30 #include "base/test/test_listener_ios.h" |
30 #else | 31 #else |
31 #include "base/test/mock_chrome_application_mac.h" | 32 #include "base/test/mock_chrome_application_mac.h" |
32 #endif // OS_IOS | 33 #endif // OS_IOS |
33 #endif // OS_MACOSX | 34 #endif // OS_MACOSX |
34 | 35 |
35 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
36 #include "base/test/test_support_android.h" | 37 #include "base/test/test_support_android.h" |
37 #endif | 38 #endif |
38 | 39 |
39 #if defined(OS_IOS) | 40 #if defined(OS_IOS) |
40 #include "base/test/test_support_ios.h" | 41 #include "base/test/test_support_ios.h" |
TVL
2013/02/27 15:59:35
since you already have this file, does it make mor
lliabraa
2013/02/27 20:31:31
Done.
| |
41 #endif | 42 #endif |
42 | 43 |
43 #if defined(TOOLKIT_GTK) | 44 #if defined(TOOLKIT_GTK) |
44 #include <gtk/gtk.h> | 45 #include <gtk/gtk.h> |
45 #endif | 46 #endif |
46 | 47 |
47 namespace { | 48 namespace { |
48 | 49 |
49 class MaybeTestDisabler : public testing::EmptyTestEventListener { | 50 class MaybeTestDisabler : public testing::EmptyTestEventListener { |
50 public: | 51 public: |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 gtk_init_check(&argc, &argv); | 110 gtk_init_check(&argc, &argv); |
110 #endif // defined(TOOLKIT_GTK) | 111 #endif // defined(TOOLKIT_GTK) |
111 | 112 |
112 // On Android, AtExitManager is created in | 113 // On Android, AtExitManager is created in |
113 // testing/android/native_test_wrapper.cc before main() is called. | 114 // testing/android/native_test_wrapper.cc before main() is called. |
114 #if !defined(OS_ANDROID) | 115 #if !defined(OS_ANDROID) |
115 if (create_at_exit_manager) | 116 if (create_at_exit_manager) |
116 at_exit_manager_.reset(new base::AtExitManager); | 117 at_exit_manager_.reset(new base::AtExitManager); |
117 #endif | 118 #endif |
118 | 119 |
120 #if defined(OS_IOS) | |
121 RunHook::Init(this, argc, argv); | |
122 #endif | |
123 | |
119 // Don't add additional code to this function. Instead add it to | 124 // Don't add additional code to this function. Instead add it to |
120 // Initialize(). See bug 6436. | 125 // Initialize(). See bug 6436. |
121 } | 126 } |
122 | 127 |
123 | 128 |
124 // static | 129 // static |
125 bool TestSuite::IsMarkedMaybe(const testing::TestInfo& test) { | 130 bool TestSuite::IsMarkedMaybe(const testing::TestInfo& test) { |
126 return strncmp(test.name(), "MAYBE_", 6) == 0; | 131 return strncmp(test.name(), "MAYBE_", 6) == 0; |
127 } | 132 } |
128 | 133 |
129 void TestSuite::CatchMaybeTests() { | 134 void TestSuite::CatchMaybeTests() { |
130 testing::TestEventListeners& listeners = | 135 testing::TestEventListeners& listeners = |
131 testing::UnitTest::GetInstance()->listeners(); | 136 testing::UnitTest::GetInstance()->listeners(); |
132 listeners.Append(new MaybeTestDisabler); | 137 listeners.Append(new MaybeTestDisabler); |
133 } | 138 } |
134 | 139 |
135 void TestSuite::ResetCommandLine() { | 140 void TestSuite::ResetCommandLine() { |
136 testing::TestEventListeners& listeners = | 141 testing::TestEventListeners& listeners = |
137 testing::UnitTest::GetInstance()->listeners(); | 142 testing::UnitTest::GetInstance()->listeners(); |
138 listeners.Append(new TestClientInitializer); | 143 listeners.Append(new TestClientInitializer); |
139 } | 144 } |
140 | 145 |
141 // Don't add additional code to this method. Instead add it to | 146 // Don't add additional code to this method. Instead add it to |
142 // Initialize(). See bug 6436. | 147 // Initialize(). See bug 6436. |
143 int TestSuite::Run() { | 148 int TestSuite::Run() { |
149 #if defined(OS_IOS) | |
150 // When TestSuite::Run() is invoked initially, RunTestsFromApp() will fire up | |
151 // an iOS app which will invoke TestSuite::Run() again. On the second | |
152 // invocation, RunTestsFromApp is a no-op and TestSuite::Run() is procesessed | |
153 // normally, but in the context of the iOS app. | |
TVL
2013/02/27 15:59:35
I'd probably just put this comment on the RunTests
lliabraa
2013/02/27 20:31:31
Done.
| |
154 RunHook::RunTestsFromApp(); | |
155 #endif | |
156 | |
144 #if defined(OS_MACOSX) | 157 #if defined(OS_MACOSX) |
145 base::mac::ScopedNSAutoreleasePool scoped_pool; | 158 base::mac::ScopedNSAutoreleasePool scoped_pool; |
146 #endif | 159 #endif |
147 | 160 |
148 Initialize(); | 161 Initialize(); |
149 std::string client_func = | 162 std::string client_func = |
150 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 163 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
151 switches::kTestChildProcess); | 164 switches::kTestChildProcess); |
152 | 165 |
153 // Check to see if we are being run as a client process. | 166 // Check to see if we are being run as a client process. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 icu_util::Initialize(); | 255 icu_util::Initialize(); |
243 | 256 |
244 CatchMaybeTests(); | 257 CatchMaybeTests(); |
245 ResetCommandLine(); | 258 ResetCommandLine(); |
246 | 259 |
247 TestTimeouts::Initialize(); | 260 TestTimeouts::Initialize(); |
248 } | 261 } |
249 | 262 |
250 void TestSuite::Shutdown() { | 263 void TestSuite::Shutdown() { |
251 } | 264 } |
OLD | NEW |