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