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