| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/ozone/platform/test/ozone_platform_test.h" | 5 #include "ui/ozone/platform/test/ozone_platform_test.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | 9 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| 10 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 10 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 11 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" | 11 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" |
| 12 #include "ui/events/platform/platform_event_source.h" | 12 #include "ui/events/platform/platform_event_source.h" |
| 13 #include "ui/ozone/common/native_display_delegate_ozone.h" | 13 #include "ui/ozone/common/native_display_delegate_ozone.h" |
| 14 #include "ui/ozone/platform/test/test_window.h" | 14 #include "ui/ozone/platform/test/test_window.h" |
| 15 #include "ui/ozone/platform/test/test_window_manager.h" | 15 #include "ui/ozone/platform/test/test_window_manager.h" |
| 16 #include "ui/ozone/public/cursor_factory_ozone.h" | 16 #include "ui/ozone/public/cursor_factory_ozone.h" |
| 17 #include "ui/ozone/public/gpu_platform_support.h" | 17 #include "ui/ozone/public/gpu_platform_support.h" |
| 18 #include "ui/ozone/public/gpu_platform_support_host.h" | 18 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 19 #include "ui/ozone/public/input_controller.h" | 19 #include "ui/ozone/public/input_controller.h" |
| 20 #include "ui/ozone/public/ozone_platform.h" | 20 #include "ui/ozone/public/ozone_platform.h" |
| 21 #include "ui/ozone/public/ozone_switches.h" | 21 #include "ui/ozone/public/ozone_switches.h" |
| 22 #include "ui/ozone/public/system_input_injector.h" | 22 #include "ui/ozone/public/system_input_injector.h" |
| 23 | 23 |
| 24 namespace ui { | 24 namespace ui { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // A test implementation of PlatformEventSource that we can instantiate to make |
| 29 // sure that the PlatformEventSource has an instance while in unit tests. |
| 30 class TestPlatformEventSource : public ui::PlatformEventSource { |
| 31 public: |
| 32 TestPlatformEventSource() {} |
| 33 ~TestPlatformEventSource() override {} |
| 34 |
| 35 private: |
| 36 DISALLOW_COPY_AND_ASSIGN(TestPlatformEventSource); |
| 37 }; |
| 38 |
| 28 // OzonePlatform for testing | 39 // OzonePlatform for testing |
| 29 // | 40 // |
| 30 // This platform dumps images to a file for testing purposes. | 41 // This platform dumps images to a file for testing purposes. |
| 31 class OzonePlatformTest : public OzonePlatform { | 42 class OzonePlatformTest : public OzonePlatform { |
| 32 public: | 43 public: |
| 33 OzonePlatformTest(const base::FilePath& dump_file) : file_path_(dump_file) {} | 44 OzonePlatformTest(const base::FilePath& dump_file) : file_path_(dump_file) {} |
| 34 ~OzonePlatformTest() override {} | 45 ~OzonePlatformTest() override {} |
| 35 | 46 |
| 36 // OzonePlatform: | 47 // OzonePlatform: |
| 37 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | 48 ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 60 } | 71 } |
| 61 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 72 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
| 62 return make_scoped_ptr(new NativeDisplayDelegateOzone()); | 73 return make_scoped_ptr(new NativeDisplayDelegateOzone()); |
| 63 } | 74 } |
| 64 | 75 |
| 65 void InitializeUI() override { | 76 void InitializeUI() override { |
| 66 window_manager_.reset(new TestWindowManager(file_path_)); | 77 window_manager_.reset(new TestWindowManager(file_path_)); |
| 67 window_manager_->Initialize(); | 78 window_manager_->Initialize(); |
| 68 // This unbreaks tests that create their own. | 79 // This unbreaks tests that create their own. |
| 69 if (!PlatformEventSource::GetInstance()) | 80 if (!PlatformEventSource::GetInstance()) |
| 70 platform_event_source_ = PlatformEventSource::CreateDefault(); | 81 platform_event_source_.reset(new TestPlatformEventSource); |
| 71 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( | 82 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
| 72 make_scoped_ptr(new StubKeyboardLayoutEngine())); | 83 make_scoped_ptr(new StubKeyboardLayoutEngine())); |
| 73 | 84 |
| 74 input_controller_ = CreateStubInputController(); | 85 input_controller_ = CreateStubInputController(); |
| 75 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | 86 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 76 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 87 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
| 77 } | 88 } |
| 78 | 89 |
| 79 void InitializeGPU() override { | 90 void InitializeGPU() override { |
| 80 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); | 91 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 96 | 107 |
| 97 OzonePlatform* CreateOzonePlatformTest() { | 108 OzonePlatform* CreateOzonePlatformTest() { |
| 98 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); | 109 base::CommandLine* cmd = base::CommandLine::ForCurrentProcess(); |
| 99 base::FilePath location; | 110 base::FilePath location; |
| 100 if (cmd->HasSwitch(switches::kOzoneDumpFile)) | 111 if (cmd->HasSwitch(switches::kOzoneDumpFile)) |
| 101 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); | 112 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); |
| 102 return new OzonePlatformTest(location); | 113 return new OzonePlatformTest(location); |
| 103 } | 114 } |
| 104 | 115 |
| 105 } // namespace ui | 116 } // namespace ui |
| OLD | NEW |