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 #include "ash/wm/ash_native_cursor_manager.h" | 4 #include "ash/wm/ash_native_cursor_manager.h" |
5 | 5 |
6 #include "ash/display/display_info.h" | 6 #include "ash/display/display_info.h" |
7 #include "ash/display/display_manager.h" | 7 #include "ash/display/display_manager.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/test/cursor_manager_test_api.h" | 10 #include "ash/test/cursor_manager_test_api.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/aura/window_tree_host.h" | 14 #include "ui/aura/window_tree_host.h" |
15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/base/test/ui_controls.h" | 16 #include "ui/base/test/ui_controls.h" |
17 #include "ui/base/ui_base_paths.h" | 17 #include "ui/base/ui_base_paths.h" |
| 18 #include "ui/events/platform/platform_event_source.h" |
18 #include "ui/gl/gl_surface.h" | 19 #include "ui/gl/gl_surface.h" |
19 | 20 |
20 #if defined(USE_X11) | 21 #if defined(USE_X11) |
21 #include <X11/Xlib.h> | 22 #include <X11/Xlib.h> |
22 | 23 |
23 #include "base/message_loop/message_pump_x11.h" | 24 #include "base/message_loop/message_pump_x11.h" |
24 #endif | 25 #endif |
25 | 26 |
26 namespace ash { | 27 namespace ash { |
27 | 28 |
28 using ::wm::CursorManager; | 29 using ::wm::CursorManager; |
29 | 30 |
30 class AshNativeCursorManagerTest : public test::AshTestBase { | 31 class AshNativeCursorManagerTest : public test::AshTestBase { |
31 public: | 32 public: |
32 AshNativeCursorManagerTest() {} | 33 AshNativeCursorManagerTest() {} |
33 virtual ~AshNativeCursorManagerTest() {} | 34 virtual ~AshNativeCursorManagerTest() {} |
34 | 35 |
35 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() OVERRIDE { |
36 gfx::GLSurface::InitializeOneOffForTests(); | 37 gfx::GLSurface::InitializeOneOffForTests(); |
37 | 38 |
| 39 event_source_ = ui::PlatformEventSource::CreateDefault(); |
38 ui::RegisterPathProvider(); | 40 ui::RegisterPathProvider(); |
39 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); | 41 ResourceBundle::InitSharedInstanceWithLocale("en-US", NULL); |
40 base::FilePath resources_pack_path; | 42 base::FilePath resources_pack_path; |
41 PathService::Get(base::DIR_MODULE, &resources_pack_path); | 43 PathService::Get(base::DIR_MODULE, &resources_pack_path); |
42 resources_pack_path = | 44 resources_pack_path = |
43 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); | 45 resources_pack_path.Append(FILE_PATH_LITERAL("resources.pak")); |
44 ResourceBundle::GetSharedInstance().AddDataPackFromPath( | 46 ResourceBundle::GetSharedInstance().AddDataPackFromPath( |
45 resources_pack_path, ui::SCALE_FACTOR_NONE); | 47 resources_pack_path, ui::SCALE_FACTOR_NONE); |
46 | 48 |
47 test::AshTestBase::SetUp(); | 49 test::AshTestBase::SetUp(); |
48 } | 50 } |
| 51 |
| 52 private: |
| 53 scoped_ptr<ui::PlatformEventSource> event_source_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(AshNativeCursorManagerTest); |
49 }; | 56 }; |
50 | 57 |
51 namespace { | 58 namespace { |
52 | 59 |
53 internal::DisplayInfo CreateDisplayInfo(int64 id, | 60 internal::DisplayInfo CreateDisplayInfo(int64 id, |
54 const gfx::Rect& bounds, | 61 const gfx::Rect& bounds, |
55 float device_scale_factor) { | 62 float device_scale_factor) { |
56 internal::DisplayInfo info(id, "", false); | 63 internal::DisplayInfo info(id, "", false); |
57 info.SetBounds(bounds); | 64 info.SetBounds(bounds); |
58 info.set_device_scale_factor(device_scale_factor); | 65 info.set_device_scale_factor(device_scale_factor); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 display_manager->OnNativeDisplaysChanged(display_info_list); | 112 display_manager->OnNativeDisplaysChanged(display_info_list); |
106 | 113 |
107 MoveMouseSync(Shell::GetAllRootWindows()[0], 10, 10); | 114 MoveMouseSync(Shell::GetAllRootWindows()[0], 10, 10); |
108 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); | 115 EXPECT_EQ(1.0f, test_api.GetDisplay().device_scale_factor()); |
109 | 116 |
110 MoveMouseSync(Shell::GetAllRootWindows()[0], 600, 10); | 117 MoveMouseSync(Shell::GetAllRootWindows()[0], 600, 10); |
111 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); | 118 EXPECT_EQ(2.0f, test_api.GetDisplay().device_scale_factor()); |
112 } | 119 } |
113 | 120 |
114 } // namespace ash | 121 } // namespace ash |
OLD | NEW |