OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/test/launcher/unit_test_launcher.h" | 7 #include "base/test/launcher/unit_test_launcher.h" |
8 #include "base/test/test_suite.h" | 8 #include "base/test/test_suite.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #if defined(OS_MACOSX) && !defined(OS_IOS) | 11 #if defined(OS_MACOSX) && !defined(OS_IOS) |
12 #include "base/test/mock_chrome_application_mac.h" | 12 #include "base/test/mock_chrome_application_mac.h" |
13 #endif | 13 #endif |
| 14 #if defined(USE_OZONE) |
| 15 #include "base/message_loop/message_loop.h" |
| 16 #include "ui/ozone/public/client_native_pixmap_factory.h" |
| 17 #endif |
14 | 18 |
15 namespace { | 19 namespace { |
16 | 20 |
17 class GlTestSuite : public base::TestSuite { | 21 class GlTestSuite : public base::TestSuite { |
18 public: | 22 public: |
19 GlTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) { | 23 GlTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) { |
20 } | 24 } |
21 | 25 |
22 protected: | 26 protected: |
23 void Initialize() override { | 27 void Initialize() override { |
24 base::TestSuite::Initialize(); | 28 base::TestSuite::Initialize(); |
25 | 29 |
26 #if defined(OS_MACOSX) && !defined(OS_IOS) | 30 #if defined(OS_MACOSX) && !defined(OS_IOS) |
27 mock_cr_app::RegisterMockCrApp(); | 31 mock_cr_app::RegisterMockCrApp(); |
28 #endif | 32 #endif |
| 33 #if defined(USE_OZONE) |
| 34 // On Ozone, the backend initializes the event system using a UI thread. |
| 35 message_loop_.reset(new base::MessageLoopForUI); |
| 36 client_native_pixmap_factory_ = ui::ClientNativePixmapFactory::Create(); |
| 37 ui::ClientNativePixmapFactory::SetInstance( |
| 38 client_native_pixmap_factory_.get()); |
| 39 #endif |
29 } | 40 } |
30 | 41 |
31 void Shutdown() override { | 42 void Shutdown() override { |
32 base::TestSuite::Shutdown(); | 43 base::TestSuite::Shutdown(); |
33 } | 44 } |
34 | 45 |
35 private: | 46 private: |
| 47 #if defined(USE_OZONE) |
| 48 std::unique_ptr<base::MessageLoop> message_loop_; |
| 49 std::unique_ptr<ui::ClientNativePixmapFactory> client_native_pixmap_factory_; |
| 50 #endif |
36 DISALLOW_COPY_AND_ASSIGN(GlTestSuite); | 51 DISALLOW_COPY_AND_ASSIGN(GlTestSuite); |
37 }; | 52 }; |
38 | 53 |
39 } // namespace | 54 } // namespace |
40 | 55 |
41 int main(int argc, char** argv) { | 56 int main(int argc, char** argv) { |
42 GlTestSuite test_suite(argc, argv); | 57 GlTestSuite test_suite(argc, argv); |
43 | 58 |
44 return base::LaunchUnitTests( | 59 return base::LaunchUnitTests( |
45 argc, | 60 argc, |
46 argv, | 61 argv, |
47 base::Bind(&GlTestSuite::Run, base::Unretained(&test_suite))); | 62 base::Bind(&GlTestSuite::Run, base::Unretained(&test_suite))); |
48 } | 63 } |
OLD | NEW |