| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/ozone/platform/test/ozone_platform_test.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/files/file_path.h" | |
| 9 #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" | |
| 10 #include "ui/events/platform/platform_event_source.h" | |
| 11 #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_manager.h" | |
| 14 #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_host.h" | |
| 17 #include "ui/ozone/public/ozone_platform.h" | |
| 18 #include "ui/ozone/public/ozone_switches.h" | |
| 19 | |
| 20 namespace ui { | |
| 21 | |
| 22 namespace { | |
| 23 | |
| 24 // OzonePlatform for testing | |
| 25 // | |
| 26 // This platform dumps images to a file for testing purposes. | |
| 27 class OzonePlatformTest : public OzonePlatform { | |
| 28 public: | |
| 29 OzonePlatformTest(const base::FilePath& dump_file) : file_path_(dump_file) {} | |
| 30 virtual ~OzonePlatformTest() {} | |
| 31 | |
| 32 // OzonePlatform: | |
| 33 virtual ui::SurfaceFactoryOzone* GetSurfaceFactoryOzone() override { | |
| 34 return window_manager_.get(); | |
| 35 } | |
| 36 virtual CursorFactoryOzone* GetCursorFactoryOzone() override { | |
| 37 return cursor_factory_ozone_.get(); | |
| 38 } | |
| 39 virtual GpuPlatformSupport* GetGpuPlatformSupport() override { | |
| 40 return gpu_platform_support_.get(); | |
| 41 } | |
| 42 virtual GpuPlatformSupportHost* GetGpuPlatformSupportHost() override { | |
| 43 return gpu_platform_support_host_.get(); | |
| 44 } | |
| 45 virtual scoped_ptr<PlatformWindow> CreatePlatformWindow( | |
| 46 PlatformWindowDelegate* delegate, | |
| 47 const gfx::Rect& bounds) override { | |
| 48 return make_scoped_ptr<PlatformWindow>( | |
| 49 new TestWindow(delegate, window_manager_.get(), bounds)); | |
| 50 } | |
| 51 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() | |
| 52 override { | |
| 53 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); | |
| 54 } | |
| 55 | |
| 56 virtual void InitializeUI() override { | |
| 57 window_manager_.reset(new TestWindowManager(file_path_)); | |
| 58 window_manager_->Initialize(); | |
| 59 // This unbreaks tests that create their own. | |
| 60 if (!PlatformEventSource::GetInstance()) | |
| 61 platform_event_source_ = PlatformEventSource::CreateDefault(); | |
| 62 | |
| 63 cursor_factory_ozone_.reset(new BitmapCursorFactoryOzone); | |
| 64 gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); | |
| 65 } | |
| 66 | |
| 67 virtual void InitializeGPU() override { | |
| 68 gpu_platform_support_.reset(CreateStubGpuPlatformSupport()); | |
| 69 } | |
| 70 | |
| 71 private: | |
| 72 scoped_ptr<TestWindowManager> window_manager_; | |
| 73 scoped_ptr<PlatformEventSource> platform_event_source_; | |
| 74 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; | |
| 75 scoped_ptr<GpuPlatformSupport> gpu_platform_support_; | |
| 76 scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_; | |
| 77 base::FilePath file_path_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest); | |
| 80 }; | |
| 81 | |
| 82 } // namespace | |
| 83 | |
| 84 OzonePlatform* CreateOzonePlatformTest() { | |
| 85 CommandLine* cmd = CommandLine::ForCurrentProcess(); | |
| 86 base::FilePath location; | |
| 87 if (cmd->HasSwitch(switches::kOzoneDumpFile)) | |
| 88 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); | |
| 89 return new OzonePlatformTest(location); | |
| 90 } | |
| 91 | |
| 92 } // namespace ui | |
| OLD | NEW |