Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Side by Side Diff: ash/display/mirror_window_controller_unittest.cc

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase at r285842 Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ash/display/mirror_window_controller.h" 5 #include "ash/display/mirror_window_controller.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
11 #include "ash/test/display_manager_test_api.h" 11 #include "ash/test/display_manager_test_api.h"
12 #include "ash/test/mirror_window_test_api.h" 12 #include "ash/test/mirror_window_test_api.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "ui/aura/test/event_generator.h"
16 #include "ui/aura/test/test_window_delegate.h" 15 #include "ui/aura/test/test_window_delegate.h"
17 #include "ui/aura/test/test_windows.h" 16 #include "ui/aura/test/test_windows.h"
18 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
19 #include "ui/aura/window_event_dispatcher.h" 18 #include "ui/aura/window_event_dispatcher.h"
20 #include "ui/base/hit_test.h" 19 #include "ui/base/hit_test.h"
20 #include "ui/events/test/event_generator.h"
21 21
22 namespace ash { 22 namespace ash {
23 23
24 namespace { 24 namespace {
25 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) { 25 DisplayInfo CreateDisplayInfo(int64 id, const gfx::Rect& bounds) {
26 DisplayInfo info(id, base::StringPrintf("x-%d", static_cast<int>(id)), false); 26 DisplayInfo info(id, base::StringPrintf("x-%d", static_cast<int>(id)), false);
27 info.SetBounds(bounds); 27 info.SetBounds(bounds);
28 return info; 28 return info;
29 } 29 }
30 30
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 &test_window_delegate, 80 &test_window_delegate,
81 0, 81 0,
82 gfx::Rect(50, 50, 100, 100), 82 gfx::Rect(50, 50, 100, 100),
83 root)); 83 root));
84 window->Show(); 84 window->Show();
85 window->SetName("foo"); 85 window->SetName("foo");
86 86
87 EXPECT_TRUE(test_api.GetCursorWindow()); 87 EXPECT_TRUE(test_api.GetCursorWindow());
88 EXPECT_EQ("50,50 100x100", window->bounds().ToString()); 88 EXPECT_EQ("50,50 100x100", window->bounds().ToString());
89 89
90 aura::test::EventGenerator generator(root); 90 ui::test::EventGenerator generator(root);
91 generator.MoveMouseTo(10, 10); 91 generator.MoveMouseTo(10, 10);
92 92
93 // Test if cursor movement is propertly reflected in mirror window. 93 // Test if cursor movement is propertly reflected in mirror window.
94 gfx::Point hot_point = test_api.GetCursorHotPoint(); 94 gfx::Point hot_point = test_api.GetCursorHotPoint();
95 gfx::Point cursor_window_origin = 95 gfx::Point cursor_window_origin =
96 test_api.GetCursorWindow()->bounds().origin(); 96 test_api.GetCursorWindow()->bounds().origin();
97 EXPECT_EQ("4,4", hot_point.ToString()); 97 EXPECT_EQ("4,4", hot_point.ToString());
98 EXPECT_EQ(10 - hot_point.x(), cursor_window_origin.x()); 98 EXPECT_EQ(10 - hot_point.x(), cursor_window_origin.x());
99 EXPECT_EQ(10 - hot_point.y(), cursor_window_origin.y()); 99 EXPECT_EQ(10 - hot_point.y(), cursor_window_origin.y());
100 EXPECT_EQ(ui::kCursorNull, test_api.GetCurrentCursorType()); 100 EXPECT_EQ(ui::kCursorNull, test_api.GetCurrentCursorType());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 &test_window_delegate, 137 &test_window_delegate,
138 0, 138 0,
139 gfx::Rect(50, 50, 100, 100), 139 gfx::Rect(50, 50, 100, 100),
140 root)); 140 root));
141 window->Show(); 141 window->Show();
142 window->SetName("foo"); 142 window->SetName("foo");
143 143
144 EXPECT_TRUE(test_api.GetCursorWindow()); 144 EXPECT_TRUE(test_api.GetCursorWindow());
145 EXPECT_EQ("50,50 100x100", window->bounds().ToString()); 145 EXPECT_EQ("50,50 100x100", window->bounds().ToString());
146 146
147 aura::test::EventGenerator generator(root); 147 ui::test::EventGenerator generator(root);
148 generator.MoveMouseToInHost(100, 100); 148 generator.MoveMouseToInHost(100, 100);
149 149
150 // Test if cursor movement is propertly reflected in mirror window. 150 // Test if cursor movement is propertly reflected in mirror window.
151 gfx::Point hot_point = test_api.GetCursorHotPoint(); 151 gfx::Point hot_point = test_api.GetCursorHotPoint();
152 gfx::Point cursor_window_origin = 152 gfx::Point cursor_window_origin =
153 test_api.GetCursorWindow()->bounds().origin(); 153 test_api.GetCursorWindow()->bounds().origin();
154 EXPECT_EQ("11,12", hot_point.ToString()); 154 EXPECT_EQ("11,12", hot_point.ToString());
155 EXPECT_EQ(100 - hot_point.x(), cursor_window_origin.x()); 155 EXPECT_EQ(100 - hot_point.x(), cursor_window_origin.x());
156 EXPECT_EQ(100 - hot_point.y(), cursor_window_origin.y()); 156 EXPECT_EQ(100 - hot_point.y(), cursor_window_origin.y());
157 EXPECT_EQ(ui::kCursorNorthResize, test_api.GetCurrentCursorType()); 157 EXPECT_EQ(ui::kCursorNorthResize, test_api.GetCurrentCursorType());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // coordinates. 193 // coordinates.
194 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorLocations) { 194 TEST_F(MirrorWindowControllerTest, MAYBE_MirrorCursorLocations) {
195 test::MirrorWindowTestApi test_api; 195 test::MirrorWindowTestApi test_api;
196 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 196 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
197 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING); 197 display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING);
198 198
199 // Test with device scale factor. 199 // Test with device scale factor.
200 UpdateDisplay("400x600*2,400x600"); 200 UpdateDisplay("400x600*2,400x600");
201 201
202 aura::Window* root = Shell::GetInstance()->GetPrimaryRootWindow(); 202 aura::Window* root = Shell::GetInstance()->GetPrimaryRootWindow();
203 aura::test::EventGenerator generator(root); 203 ui::test::EventGenerator generator(root);
204 generator.MoveMouseToInHost(10, 20); 204 generator.MoveMouseToInHost(10, 20);
205 205
206 gfx::Point hot_point = test_api.GetCursorHotPoint(); 206 gfx::Point hot_point = test_api.GetCursorHotPoint();
207 EXPECT_EQ("8,9", hot_point.ToString()); 207 EXPECT_EQ("8,9", hot_point.ToString());
208 gfx::Point cursor_window_origin = 208 gfx::Point cursor_window_origin =
209 test_api.GetCursorWindow()->bounds().origin(); 209 test_api.GetCursorWindow()->bounds().origin();
210 EXPECT_EQ(10 - hot_point.x(), cursor_window_origin.x()); 210 EXPECT_EQ(10 - hot_point.x(), cursor_window_origin.x());
211 EXPECT_EQ(20 - hot_point.y(), cursor_window_origin.y()); 211 EXPECT_EQ(20 - hot_point.y(), cursor_window_origin.y());
212 212
213 // Test with ui scale 213 // Test with ui scale
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 280
281 TEST_F(MirrorOnBootTest, MAYBE_MirrorOnBoot) { 281 TEST_F(MirrorOnBootTest, MAYBE_MirrorOnBoot) {
282 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 282 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
283 EXPECT_TRUE(display_manager->IsMirrored()); 283 EXPECT_TRUE(display_manager->IsMirrored());
284 RunAllPendingInMessageLoop(); 284 RunAllPendingInMessageLoop();
285 test::MirrorWindowTestApi test_api; 285 test::MirrorWindowTestApi test_api;
286 EXPECT_TRUE(test_api.GetHost()); 286 EXPECT_TRUE(test_api.GetHost());
287 } 287 }
288 288
289 } // namespace ash 289 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/display/root_window_transformers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698