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/message_loop/message_loop.h" |
7 #include "base/test/launcher/unit_test_launcher.h" | 8 #include "base/test/launcher/unit_test_launcher.h" |
8 #include "base/test/test_suite.h" | 9 #include "base/test/test_suite.h" |
9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
10 | 11 |
11 #if defined(OS_MACOSX) && !defined(OS_IOS) | 12 #if defined(OS_MACOSX) && !defined(OS_IOS) |
12 #include "base/test/mock_chrome_application_mac.h" | 13 #include "base/test/mock_chrome_application_mac.h" |
13 #endif | 14 #endif |
14 | 15 |
| 16 #if defined(USE_OZONE) |
| 17 #include "ui/ozone/public/client_native_pixmap_factory.h" |
| 18 #include "ui/ozone/public/ozone_gpu_test_helper.h" |
| 19 #include "ui/ozone/public/ozone_platform.h" |
| 20 #endif |
| 21 |
15 namespace { | 22 namespace { |
16 | 23 |
17 class GlTestSuite : public base::TestSuite { | 24 class GlTestSuite : public base::TestSuite { |
18 public: | 25 public: |
19 GlTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) { | 26 GlTestSuite(int argc, char** argv) : base::TestSuite(argc, argv) { |
20 } | 27 } |
21 | 28 |
22 protected: | 29 protected: |
23 void Initialize() override { | 30 void Initialize() override { |
| 31 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoopForUI); |
24 base::TestSuite::Initialize(); | 32 base::TestSuite::Initialize(); |
25 | 33 |
| 34 #if defined(USE_OZONE) |
| 35 ozone_ = ui::OzoneInitializerForTest::Create(); |
| 36 DCHECK(ozone_); |
| 37 |
| 38 client_native_pixmap_factory_ = ui::ClientNativePixmapFactory::Create(); |
| 39 ui::ClientNativePixmapFactory::SetInstance( |
| 40 client_native_pixmap_factory_.get()); |
| 41 ui::ClientNativePixmapFactory::GetInstance()->Initialize( |
| 42 ui::OzonePlatform::GetInstance()->OpenClientNativePixmapDevice()); |
| 43 #endif |
| 44 // TODO(reveman): initialize SurfaceTextureManager or IOSurfaceManager |
26 #if defined(OS_MACOSX) && !defined(OS_IOS) | 45 #if defined(OS_MACOSX) && !defined(OS_IOS) |
27 mock_cr_app::RegisterMockCrApp(); | 46 mock_cr_app::RegisterMockCrApp(); |
28 #endif | 47 #endif |
29 } | 48 } |
30 | 49 |
31 void Shutdown() override { | 50 void Shutdown() override { |
32 base::TestSuite::Shutdown(); | 51 base::TestSuite::Shutdown(); |
33 } | 52 } |
34 | 53 |
35 private: | 54 private: |
| 55 #if defined(USE_OZONE) |
| 56 scoped_ptr<ui::OzoneInitializerForTest> ozone_; |
| 57 scoped_ptr<ui::ClientNativePixmapFactory> client_native_pixmap_factory_; |
| 58 #endif |
36 DISALLOW_COPY_AND_ASSIGN(GlTestSuite); | 59 DISALLOW_COPY_AND_ASSIGN(GlTestSuite); |
37 }; | 60 }; |
38 | 61 |
39 } // namespace | 62 } // namespace |
40 | 63 |
41 int main(int argc, char** argv) { | 64 int main(int argc, char** argv) { |
42 GlTestSuite test_suite(argc, argv); | 65 GlTestSuite test_suite(argc, argv); |
43 | 66 |
44 return base::LaunchUnitTests( | 67 return base::LaunchUnitTests( |
45 argc, | 68 argc, |
46 argv, | 69 argv, |
47 base::Bind(&GlTestSuite::Run, base::Unretained(&test_suite))); | 70 base::Bind(&GlTestSuite::Run, base::Unretained(&test_suite))); |
48 } | 71 } |
OLD | NEW |