| 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/stub/stub_keyboard_layouts.h" |
| 10 #include "ui/events/platform/platform_event_source.h" | 11 #include "ui/events/platform/platform_event_source.h" |
| 11 #include "ui/ozone/common/native_display_delegate_ozone.h" | 12 #include "ui/ozone/common/native_display_delegate_ozone.h" |
| 12 #include "ui/ozone/platform/test/test_window.h" | 13 #include "ui/ozone/platform/test/test_window.h" |
| 13 #include "ui/ozone/platform/test/test_window_manager.h" | 14 #include "ui/ozone/platform/test/test_window_manager.h" |
| 14 #include "ui/ozone/public/cursor_factory_ozone.h" | 15 #include "ui/ozone/public/cursor_factory_ozone.h" |
| 15 #include "ui/ozone/public/gpu_platform_support.h" | 16 #include "ui/ozone/public/gpu_platform_support.h" |
| 16 #include "ui/ozone/public/gpu_platform_support_host.h" | 17 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 17 #include "ui/ozone/public/ozone_platform.h" | 18 #include "ui/ozone/public/ozone_platform.h" |
| 18 #include "ui/ozone/public/ozone_switches.h" | 19 #include "ui/ozone/public/ozone_switches.h" |
| 19 | 20 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 35 } | 36 } |
| 36 CursorFactoryOzone* GetCursorFactoryOzone() override { | 37 CursorFactoryOzone* GetCursorFactoryOzone() override { |
| 37 return cursor_factory_ozone_.get(); | 38 return cursor_factory_ozone_.get(); |
| 38 } | 39 } |
| 39 GpuPlatformSupport* GetGpuPlatformSupport() override { | 40 GpuPlatformSupport* GetGpuPlatformSupport() override { |
| 40 return gpu_platform_support_.get(); | 41 return gpu_platform_support_.get(); |
| 41 } | 42 } |
| 42 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | 43 GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { |
| 43 return gpu_platform_support_host_.get(); | 44 return gpu_platform_support_host_.get(); |
| 44 } | 45 } |
| 46 KeyboardLayoutsOzone* GetKeyboardLayouts() override { |
| 47 return keyboard_layouts_ozone_.get(); |
| 48 } |
| 45 scoped_ptr<PlatformWindow> CreatePlatformWindow( | 49 scoped_ptr<PlatformWindow> CreatePlatformWindow( |
| 46 PlatformWindowDelegate* delegate, | 50 PlatformWindowDelegate* delegate, |
| 47 const gfx::Rect& bounds) override { | 51 const gfx::Rect& bounds) override { |
| 48 return make_scoped_ptr<PlatformWindow>( | 52 return make_scoped_ptr<PlatformWindow>( |
| 49 new TestWindow(delegate, window_manager_.get(), bounds)); | 53 new TestWindow(delegate, window_manager_.get(), bounds)); |
| 50 } | 54 } |
| 51 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { | 55 scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() override { |
| 52 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); | 56 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); |
| 53 } | 57 } |
| 54 | 58 |
| 55 void InitializeUI() override { | 59 void InitializeUI() override { |
| 56 window_manager_.reset(new TestWindowManager(file_path_)); | 60 window_manager_.reset(new TestWindowManager(file_path_)); |
| 57 window_manager_->Initialize(); | 61 window_manager_->Initialize(); |
| 58 // This unbreaks tests that create their own. | 62 // This unbreaks tests that create their own. |
| 59 if (!PlatformEventSource::GetInstance()) | 63 if (!PlatformEventSource::GetInstance()) |
| 60 platform_event_source_ = PlatformEventSource::CreateDefault(); | 64 platform_event_source_ = PlatformEventSource::CreateDefault(); |
| 61 | 65 |
| 62 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | 66 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); |
| 63 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 67 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
| 68 keyboard_layouts_ozone_.reset(new StubKeyboardLayouts()); |
| 64 } | 69 } |
| 65 | 70 |
| 66 void InitializeGPU() override { | 71 void InitializeGPU() override { |
| 67 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); | 72 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
| 68 } | 73 } |
| 69 | 74 |
| 70 private: | 75 private: |
| 71 scoped_ptr<TestWindowManager> window_manager_; | 76 scoped_ptr<TestWindowManager> window_manager_; |
| 72 scoped_ptr<PlatformEventSource> platform_event_source_; | 77 scoped_ptr<PlatformEventSource> platform_event_source_; |
| 73 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; | 78 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; |
| 74 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; | 79 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; |
| 75 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | 80 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
| 81 scoped_ptr<KeyboardLayoutsOzone> keyboard_layouts_ozone_; |
| 76 base::FilePath file_path_; | 82 base::FilePath file_path_; |
| 77 | 83 |
| 78 DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest); | 84 DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest); |
| 79 }; | 85 }; |
| 80 | 86 |
| 81 } // namespace | 87 } // namespace |
| 82 | 88 |
| 83 OzonePlatform* CreateOzonePlatformTest() { | 89 OzonePlatform* CreateOzonePlatformTest() { |
| 84 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 90 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 85 base::FilePath location; | 91 base::FilePath location; |
| 86 if (cmd->HasSwitch(switches::kOzoneDumpFile)) | 92 if (cmd->HasSwitch(switches::kOzoneDumpFile)) |
| 87 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); | 93 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); |
| 88 return new OzonePlatformTest(location); | 94 return new OzonePlatformTest(location); |
| 89 } | 95 } |
| 90 | 96 |
| 91 } // namespace ui | 97 } // namespace ui |
| OLD | NEW |