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/cursor_factory_ozone.h" | 9 #include "ui/base/cursor/ozone/cursor_factory_ozone.h" |
10 #include "ui/events/ozone/device/device_manager.h" | 10 #include "ui/events/ozone/device/device_manager.h" |
11 #include "ui/events/ozone/evdev/event_factory_evdev.h" | 11 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
12 #include "ui/gfx/ozone/impl/file_surface_factory.h" | 12 #include "ui/gfx/ozone/impl/file_surface_factory.h" |
13 #include "ui/ozone/ime/input_method_context_factory_ozone.h" | 13 #include "ui/ozone/ime/input_method_context_factory_ozone.h" |
14 #include "ui/ozone/ozone_platform.h" | 14 #include "ui/ozone/ozone_platform.h" |
15 #include "ui/ozone/ozone_switches.h" | 15 #include "ui/ozone/ozone_switches.h" |
16 | 16 |
17 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
18 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h" | 18 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h" |
19 #endif | 19 #endif |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 // OzonePlatform for testing | 25 // OzonePlatform for testing |
26 // | 26 // |
27 // This platform dumps images to a file for testing purposes. | 27 // This platform dumps images to a file for testing purposes. |
28 class OzonePlatformTest : public OzonePlatform { | 28 class OzonePlatformTest : public OzonePlatform { |
29 public: | 29 public: |
30 OzonePlatformTest(const base::FilePath& dump_file) | 30 OzonePlatformTest(const base::FilePath& dump_file) : file_path_(dump_file) {} |
31 : device_manager_(CreateDeviceManager()), | |
32 surface_factory_ozone_(dump_file), | |
33 event_factory_ozone_(NULL, device_manager_.get()) {} | |
34 virtual ~OzonePlatformTest() {} | 31 virtual ~OzonePlatformTest() {} |
35 | 32 |
36 // OzonePlatform: | 33 // OzonePlatform: |
37 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { | 34 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE { |
38 return &surface_factory_ozone_; | 35 return surface_factory_ozone_.get(); |
39 } | 36 } |
40 virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { | 37 virtual EventFactoryOzone* GetEventFactoryOzone() OVERRIDE { |
41 return &event_factory_ozone_; | 38 return event_factory_ozone_.get(); |
42 } | 39 } |
43 virtual ui::InputMethodContextFactoryOzone* | 40 virtual InputMethodContextFactoryOzone* GetInputMethodContextFactoryOzone() |
44 GetInputMethodContextFactoryOzone() OVERRIDE { | 41 OVERRIDE { |
45 return &input_method_context_factory_ozone_; | 42 return input_method_context_factory_ozone_.get(); |
46 } | 43 } |
47 virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { | 44 virtual CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE { |
48 return &cursor_factory_ozone_; | 45 return cursor_factory_ozone_.get(); |
49 } | 46 } |
50 | 47 |
51 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
52 virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate() | 49 virtual scoped_ptr<NativeDisplayDelegate> CreateNativeDisplayDelegate() |
53 OVERRIDE { | 50 OVERRIDE { |
54 return scoped_ptr<ui::NativeDisplayDelegate>( | 51 return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone()); |
55 new NativeDisplayDelegateOzone()); | |
56 } | 52 } |
57 #endif | 53 #endif |
58 | 54 |
| 55 virtual void InitializeUI() OVERRIDE { |
| 56 device_manager_ = CreateDeviceManager(); |
| 57 surface_factory_ozone_.reset(new gfx::FileSurfaceFactory(file_path_)); |
| 58 event_factory_ozone_.reset( |
| 59 new EventFactoryEvdev(NULL, device_manager_.get())); |
| 60 input_method_context_factory_ozone_.reset( |
| 61 new InputMethodContextFactoryOzone()); |
| 62 cursor_factory_ozone_.reset(new CursorFactoryOzone()); |
| 63 } |
| 64 |
| 65 virtual void InitializeGPU() OVERRIDE {} |
| 66 |
59 private: | 67 private: |
60 scoped_ptr<DeviceManager> device_manager_; | 68 scoped_ptr<DeviceManager> device_manager_; |
61 gfx::FileSurfaceFactory surface_factory_ozone_; | 69 scoped_ptr<gfx::FileSurfaceFactory> surface_factory_ozone_; |
62 ui::EventFactoryEvdev event_factory_ozone_; | 70 scoped_ptr<EventFactoryEvdev> event_factory_ozone_; |
63 ui::InputMethodContextFactoryOzone input_method_context_factory_ozone_; | 71 scoped_ptr<InputMethodContextFactoryOzone> |
64 ui::CursorFactoryOzone cursor_factory_ozone_; | 72 input_method_context_factory_ozone_; |
| 73 scoped_ptr<CursorFactoryOzone> cursor_factory_ozone_; |
| 74 base::FilePath file_path_; |
65 | 75 |
66 DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest); | 76 DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest); |
67 }; | 77 }; |
68 | 78 |
69 } // namespace | 79 } // namespace |
70 | 80 |
71 OzonePlatform* CreateOzonePlatformTest() { | 81 OzonePlatform* CreateOzonePlatformTest() { |
72 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 82 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
73 base::FilePath location = base::FilePath("/dev/null"); | 83 base::FilePath location = base::FilePath("/dev/null"); |
74 if (cmd->HasSwitch(switches::kOzoneDumpFile)) | 84 if (cmd->HasSwitch(switches::kOzoneDumpFile)) |
75 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); | 85 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile); |
76 return new OzonePlatformTest(location); | 86 return new OzonePlatformTest(location); |
77 } | 87 } |
78 | 88 |
79 } // namespace ui | 89 } // namespace ui |
OLD | NEW |