| 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/events/ozone/device/device_manager.h" | 9 #include "ui/events/ozone/device/device_manager.h" |
| 10 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 10 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 11 #include "ui/ozone/common/platform_window_base.h" | 11 #include "ui/ozone/common/platform_window_base.h" |
| 12 #include "ui/ozone/platform/test/file_surface_factory.h" | |
| 13 #include "ui/ozone/platform/test/test_cursor_factory.h" | 12 #include "ui/ozone/platform/test/test_cursor_factory.h" |
| 13 #include "ui/ozone/platform/test/test_window_manager.h" |
| 14 #include "ui/ozone/public/cursor_factory_ozone.h" |
| 14 #include "ui/ozone/public/gpu_platform_support.h" | 15 #include "ui/ozone/public/gpu_platform_support.h" |
| 15 #include "ui/ozone/public/gpu_platform_support_host.h" | 16 #include "ui/ozone/public/gpu_platform_support_host.h" |
| 16 #include "ui/ozone/public/ozone_platform.h" | 17 #include "ui/ozone/public/ozone_platform.h" |
| 17 #include "ui/ozone/public/ozone_switches.h" | 18 #include "ui/ozone/public/ozone_switches.h" |
| 18 | 19 |
| 19 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
| 20 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h" | 21 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h" |
| 21 #include "ui/ozone/common/chromeos/touchscreen_device_manager_ozone.h" | 22 #include "ui/ozone/common/chromeos/touchscreen_device_manager_ozone.h" |
| 22 #endif | 23 #endif |
| 23 | 24 |
| 24 namespace ui { | 25 namespace ui { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 // OzonePlatform for testing | 29 // OzonePlatform for testing |
| 29 // | 30 // |
| 30 // This platform dumps images to a file for testing purposes. | 31 // This platform dumps images to a file for testing purposes. |
| 31 class OzonePlatformTest : public OzonePlatform { | 32 class OzonePlatformTest : public OzonePlatform { |
| 32 public: | 33 public: |
| 33 OzonePlatformTest(const base::FilePath& dump_file) : file_path_(dump_file) {} | 34 OzonePlatformTest(const base::FilePath& dump_file) : file_path_(dump_file) {} |
| 34 virtual ~OzonePlatformTest() {} | 35 virtual ~OzonePlatformTest() {} |
| 35 | 36 |
| 36 // OzonePlatform: | 37 // OzonePlatform: |
| 37 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { | 38 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { |
| 38 return surface_factory_ozone_.get(); | 39 return window_manager_.get(); |
| 39 } | 40 } |
| 40 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { | 41 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { |
| 41 return event_factory_ozone_.get(); | 42 return event_factory_ozone_.get(); |
| 42 } | 43 } |
| 43 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { | 44 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { |
| 44 return cursor_factory_ozone_.get(); | 45 return cursor_factory_ozone_.get(); |
| 45 } | 46 } |
| 46 virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE { | 47 virtual GpuPlatformSupport* GetGpuPlatformSupport() OVERRIDE { |
| 47 return gpu_platform_support_.get(); | 48 return gpu_platform_support_.get(); |
| 48 } | 49 } |
| 49 virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE { | 50 virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() OVERRIDE { |
| 50 return gpu_platform_support_host_.get(); | 51 return gpu_platform_support_host_.get(); |
| 51 } | 52 } |
| 52 virtual scoped_ptr<PlatformWindow> CreatePlatformWindow( | 53 virtual scoped_ptr<PlatformWindow> CreatePlatformWindow( |
| 53 PlatformWindowDelegate* delegate, | 54 PlatformWindowDelegate* delegate, |
| 54 const gfx::Rect& bounds) OVERRIDE { | 55 const gfx::Rect& bounds) OVERRIDE { |
| 55 return make_scoped_ptr<PlatformWindow>( | 56 return make_scoped_ptr<PlatformWindow>( |
| 56 new PlatformWindowCompat(delegate, bounds)); | 57 new TestWindow(delegate, window_manager_.get(), bounds)); |
| 57 } | 58 } |
| 58 | 59 |
| 59 #if defined(OS_CHROMEOS) | 60 #if defined(OS_CHROMEOS) |
| 60 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() | 61 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() |
| 61 OVERRIDE { | 62 OVERRIDE { |
| 62 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); | 63 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); |
| 63 } | 64 } |
| 64 virtual scoped_ptr<TouchscreenDeviceManager> | 65 virtual scoped_ptr<TouchscreenDeviceManager> |
| 65 CreateTouchscreenDeviceManager() OVERRIDE { | 66 CreateTouchscreenDeviceManager() OVERRIDE { |
| 66 return scoped_ptr<TouchscreenDeviceManager>( | 67 return scoped_ptr<TouchscreenDeviceManager>( |
| 67 new TouchscreenDeviceManagerOzone()); | 68 new TouchscreenDeviceManagerOzone()); |
| 68 } | 69 } |
| 69 #endif | 70 #endif |
| 70 | 71 |
| 71 virtual void InitializeUI() OVERRIDE { | 72 virtual void InitializeUI() OVERRIDE { |
| 72 device_manager_ = CreateDeviceManager(); | 73 device_manager_ = CreateDeviceManager(); |
| 73 surface_factory_ozone_.reset(new FileSurfaceFactory(file_path_)); | 74 window_manager_.reset(new TestWindowManager(file_path_)); |
| 74 event_factory_ozone_.reset( | 75 event_factory_ozone_.reset( |
| 75 new EventFactoryEvdev(NULL, device_manager_.get())); | 76 new EventFactoryEvdev(NULL, device_manager_.get())); |
| 76 cursor_factory_ozone_.reset(new TestCursorFactory()); | 77 cursor_factory_ozone_.reset(new TestCursorFactory()); |
| 77 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | 78 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); |
| 78 } | 79 } |
| 79 | 80 |
| 80 virtual void InitializeGPU() OVERRIDE { | 81 virtual void InitializeGPU() OVERRIDE { |
| 81 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); | 82 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); |
| 82 } | 83 } |
| 83 | 84 |
| 84 private: | 85 private: |
| 85 scoped_ptr<DeviceManager> device_manager_; | 86 scoped_ptr<DeviceManager> device_manager_; |
| 86 scoped_ptr<FileSurfaceFactory> surface_factory_ozone_; | 87 scoped_ptr<TestWindowManager> window_manager_; |
| 87 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; | 88 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
| 88 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; | 89 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; |
| 89 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; | 90 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; |
| 90 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | 91 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; |
| 91 base::FilePath file_path_; | 92 base::FilePath file_path_; |
| 92 | 93 |
| 93 DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest); | 94 DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest); |
| 94 }; | 95 }; |
| 95 | 96 |
| 96 } // namespace | 97 } // namespace |
| 97 | 98 |
| 98 OzonePlatform* CreateOzonePlatformTest() { | 99 OzonePlatform* CreateOzonePlatformTest() { |
| 99 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 100 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 100 base::FilePath location = base::FilePath("/dev/null"); | 101 base::FilePath location = base::FilePath("/dev/null"); |
| 101 if (cmd->HasSwitch(switches::kOzoneDumpFile)) | 102 if (cmd->HasSwitch(switches::kOzoneDumpFile)) |
| 102 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); | 103 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); |
| 103 return new OzonePlatformTest(location); | 104 return new OzonePlatformTest(location); |
| 104 } | 105 } |
| 105 | 106 |
| 106 } // namespace ui | 107 } // namespace ui |
| OLD | NEW |