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/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop/message_loop.h" |
8 #include "base/test/launcher/unit_test_launcher.h" | 9 #include "base/test/launcher/unit_test_launcher.h" |
9 #include "base/test/test_suite.h" | 10 #include "base/test/test_suite.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
12 | 13 |
| 14 #if defined(OS_MACOSX) |
| 15 #include "base/mac/scoped_nsautorelease_pool.h" |
| 16 #endif |
| 17 |
13 namespace { | 18 namespace { |
14 | 19 |
15 class NoAtExitBaseTestSuite : public base::TestSuite { | 20 class NoAtExitBaseTestSuite : public base::TestSuite { |
16 public: | 21 public: |
17 NoAtExitBaseTestSuite(int argc, char** argv) | 22 NoAtExitBaseTestSuite(int argc, char** argv) |
18 : base::TestSuite(argc, argv, false) { | 23 : base::TestSuite(argc, argv, false) { |
19 } | 24 } |
20 }; | 25 }; |
21 | 26 |
22 int RunTestSuite(int argc, char** argv) { | 27 int RunTestSuite(int argc, char** argv) { |
| 28 base::MessageLoop message_loop; |
23 return NoAtExitBaseTestSuite(argc, argv).Run(); | 29 return NoAtExitBaseTestSuite(argc, argv).Run(); |
24 } | 30 } |
25 | 31 |
26 } // namespace | 32 } // namespace |
27 | 33 |
28 int main(int argc, char** argv) { | 34 int main(int argc, char** argv) { |
29 // On Android, AtExitManager is created in | 35 // On Android, AtExitManager is created in |
30 // testing/android/native_test_wrapper.cc before main() is called. | 36 // testing/android/native_test_wrapper.cc before main() is called. |
31 // The same thing is also done in base/test/test_suite.cc | 37 // The same thing is also done in base/test/test_suite.cc |
32 #if !defined(OS_ANDROID) | 38 #if !defined(OS_ANDROID) |
33 base::AtExitManager exit_manager; | 39 base::AtExitManager exit_manager; |
34 #endif | 40 #endif |
35 base::CommandLine::Init(argc, argv); | 41 base::CommandLine::Init(argc, argv); |
| 42 #if defined(OS_MACOSX) |
| 43 base::mac::ScopedNSAutoreleasePool autorelease_pool; |
| 44 #endif |
36 testing::InitGoogleMock(&argc, argv); | 45 testing::InitGoogleMock(&argc, argv); |
37 return base::LaunchUnitTests(argc, | 46 return base::LaunchUnitTests(argc, |
38 argv, | 47 argv, |
39 base::Bind(&RunTestSuite, argc, argv)); | 48 base::Bind(&RunTestSuite, argc, argv)); |
40 } | 49 } |
OLD | NEW |