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.
5 #include "ui/ozone/platform/test/ozone_platform_test.h"
7 #include "base/command_line.h"
8 #include "base/files/file_path.h"
9 #include "ui/base/cursor/ozone/cursor_factory_ozone.h"
10 #include "ui/events/ozone/evdev/event_factory_evdev.h"
11 #include "ui/gfx/ozone/impl/file_surface_factory.h"
12 #include "ui/ozone/ime/input_method_context_factory_ozone.h"
13 #include "ui/ozone/ozone_platform.h"
14 #include "ui/ozone/ozone_switches.h"
16 #if defined(OS_CHROMEOS)
17 #include "ui/ozone/common/chromeos/native_display_delegate_ozone.h"
24 // OzonePlatform for testing
26 // This platform dumps images to a file for testing purposes.
27 class OzonePlatformTest : public OzonePlatform {
29 OzonePlatformTest(const base::FilePath& dump_file)
30 : surface_factory_ozone_(dump_file) {}
31 virtual ~OzonePlatformTest() {}
34 virtual gfx::SurfaceFactoryOzone* GetSurfaceFactoryOzone() OVERRIDE {
35 return &surface_factory_ozone_;
37 virtual ui::EventFactoryOzone* GetEventFactoryOzone() OVERRIDE {
38 return &event_factory_ozone_;
40 virtual ui::InputMethodContextFactoryOzone*
41 GetInputMethodContextFactoryOzone() OVERRIDE {
42 return &input_method_context_factory_ozone_;
44 virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() OVERRIDE {
45 return &cursor_factory_ozone_;
48 #if defined(OS_CHROMEOS)
49 virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate()
51 return scoped_ptr<ui::NativeDisplayDelegate>(
52 new NativeDisplayDelegateOzone());
57 gfx::FileSurfaceFactory surface_factory_ozone_;
58 ui::EventFactoryEvdev event_factory_ozone_;
59 ui::InputMethodContextFactoryOzone input_method_context_factory_ozone_;
60 ui::CursorFactoryOzone cursor_factory_ozone_;
62 DISALLOW_COPY_AND_ASSIGN(OzonePlatformTest);
67 OzonePlatform* CreateOzonePlatformTest() {
68 CommandLine* cmd = CommandLine::ForCurrentProcess();
69 base::FilePath location = base::FilePath("/dev/null");
70 if (cmd->HasSwitch(switches::kOzoneDumpFile))
71 location = cmd->GetSwitchValuePath(switches::kOzoneDumpFile);
72 return new OzonePlatformTest(location);