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

Side by Side Diff: trunk/src/ash/extended_desktop_unittest.cc

Issue 59153004: Revert 233787 "Eliminate Shell::RootWindowList in favor of aura:..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/display_controller.h" 5 #include "ash/display/display_controller.h"
6 #include "ash/display/display_manager.h" 6 #include "ash/display/display_manager.h"
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 class MoveWindowByClickEventHandler : public ui::EventHandler { 68 class MoveWindowByClickEventHandler : public ui::EventHandler {
69 public: 69 public:
70 explicit MoveWindowByClickEventHandler(aura::Window* target) 70 explicit MoveWindowByClickEventHandler(aura::Window* target)
71 : target_(target) {} 71 : target_(target) {}
72 virtual ~MoveWindowByClickEventHandler() {} 72 virtual ~MoveWindowByClickEventHandler() {}
73 73
74 private: 74 private:
75 // ui::EventHandler overrides: 75 // ui::EventHandler overrides:
76 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { 76 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
77 if (event->type() == ui::ET_MOUSE_RELEASED) { 77 if (event->type() == ui::ET_MOUSE_RELEASED) {
78 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 78 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
79 DCHECK_LT(1u, root_windows.size()); 79 DCHECK_LT(1u, root_windows.size());
80 root_windows[1]->AddChild(target_); 80 root_windows[1]->AddChild(target_);
81 } 81 }
82 } 82 }
83 83
84 aura::Window* target_; 84 aura::Window* target_;
85 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventHandler); 85 DISALLOW_COPY_AND_ASSIGN(MoveWindowByClickEventHandler);
86 }; 86 };
87 87
88 // An event handler which records the event's locations. 88 // An event handler which records the event's locations.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 }; 155 };
156 156
157 // Test conditions that root windows in extended desktop mode 157 // Test conditions that root windows in extended desktop mode
158 // must satisfy. 158 // must satisfy.
159 TEST_F(ExtendedDesktopTest, Basic) { 159 TEST_F(ExtendedDesktopTest, Basic) {
160 if (!SupportsMultipleDisplays()) 160 if (!SupportsMultipleDisplays())
161 return; 161 return;
162 162
163 UpdateDisplay("1000x600,600x400"); 163 UpdateDisplay("1000x600,600x400");
164 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 164 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
165 165
166 // All root windows must have the root window controller. 166 // All root windows must have the root window controller.
167 ASSERT_EQ(2U, root_windows.size()); 167 ASSERT_EQ(2U, root_windows.size());
168 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); 168 for (Shell::RootWindowList::const_iterator iter = root_windows.begin();
169 iter != root_windows.end(); ++iter) { 169 iter != root_windows.end(); ++iter) {
170 EXPECT_TRUE(internal::GetRootWindowController(*iter) != NULL); 170 EXPECT_TRUE(internal::GetRootWindowController(*iter) != NULL);
171 } 171 }
172 // Make sure root windows share the same controllers. 172 // Make sure root windows share the same controllers.
173 EXPECT_EQ(aura::client::GetFocusClient(root_windows[0]), 173 EXPECT_EQ(aura::client::GetFocusClient(root_windows[0]),
174 aura::client::GetFocusClient(root_windows[1])); 174 aura::client::GetFocusClient(root_windows[1]));
175 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]), 175 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]),
176 aura::client::GetActivationClient(root_windows[1])); 176 aura::client::GetActivationClient(root_windows[1]));
177 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]), 177 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]),
178 aura::client::GetCaptureClient(root_windows[1])); 178 aura::client::GetCaptureClient(root_windows[1]));
179 } 179 }
180 180
181 TEST_F(ExtendedDesktopTest, Activation) { 181 TEST_F(ExtendedDesktopTest, Activation) {
182 if (!SupportsMultipleDisplays()) 182 if (!SupportsMultipleDisplays())
183 return; 183 return;
184 184
185 UpdateDisplay("1000x600,600x400"); 185 UpdateDisplay("1000x600,600x400");
186 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 186 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
187 187
188 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 188 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
189 views::Widget* widget_on_2nd = 189 views::Widget* widget_on_2nd =
190 CreateTestWidget(gfx::Rect(1200, 10, 100, 100)); 190 CreateTestWidget(gfx::Rect(1200, 10, 100, 100));
191 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); 191 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
192 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow()); 192 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow());
193 193
194 EXPECT_EQ(widget_on_2nd->GetNativeView(), 194 EXPECT_EQ(widget_on_2nd->GetNativeView(),
195 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow()); 195 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow());
196 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); 196 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView()));
(...skipping 13 matching lines...) Expand all
210 EXPECT_EQ(widget_on_2nd->GetNativeView(), 210 EXPECT_EQ(widget_on_2nd->GetNativeView(),
211 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow()); 211 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow());
212 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); 212 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView()));
213 } 213 }
214 214
215 TEST_F(ExtendedDesktopTest, SystemModal) { 215 TEST_F(ExtendedDesktopTest, SystemModal) {
216 if (!SupportsMultipleDisplays()) 216 if (!SupportsMultipleDisplays())
217 return; 217 return;
218 218
219 UpdateDisplay("1000x600,600x400"); 219 UpdateDisplay("1000x600,600x400");
220 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 220 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
221 221
222 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 222 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
223 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); 223 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
224 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); 224 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow());
225 EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow()); 225 EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow());
226 226
227 // Open system modal. Make sure it's on 2nd root window and active. 227 // Open system modal. Make sure it's on 2nd root window and active.
228 views::Widget* modal_widget = views::Widget::CreateWindowWithContextAndBounds( 228 views::Widget* modal_widget = views::Widget::CreateWindowWithContextAndBounds(
229 new ModalWidgetDelegate(), 229 new ModalWidgetDelegate(),
230 CurrentContext(), 230 CurrentContext(),
(...skipping 17 matching lines...) Expand all
248 event_generator.ClickLeftButton(); 248 event_generator.ClickLeftButton();
249 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); 249 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView()));
250 EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow()); 250 EXPECT_EQ(root_windows[0], Shell::GetTargetRootWindow());
251 } 251 }
252 252
253 TEST_F(ExtendedDesktopTest, TestCursor) { 253 TEST_F(ExtendedDesktopTest, TestCursor) {
254 if (!SupportsMultipleDisplays()) 254 if (!SupportsMultipleDisplays())
255 return; 255 return;
256 256
257 UpdateDisplay("1000x600,600x400"); 257 UpdateDisplay("1000x600,600x400");
258 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 258 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
259 aura::WindowEventDispatcher* dispatcher0 = root_windows[0]->GetDispatcher(); 259 EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type());
260 aura::WindowEventDispatcher* dispatcher1 = root_windows[1]->GetDispatcher(); 260 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type());
261 EXPECT_EQ(ui::kCursorPointer, dispatcher0->last_cursor().native_type());
262 EXPECT_EQ(ui::kCursorPointer, dispatcher1->last_cursor().native_type());
263 Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorCopy); 261 Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorCopy);
264 EXPECT_EQ(ui::kCursorCopy, dispatcher0->last_cursor().native_type()); 262 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type());
265 EXPECT_EQ(ui::kCursorCopy, dispatcher1->last_cursor().native_type()); 263 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type());
266 } 264 }
267 265
268 TEST_F(ExtendedDesktopTest, TestCursorLocation) { 266 TEST_F(ExtendedDesktopTest, TestCursorLocation) {
269 if (!SupportsMultipleDisplays()) 267 if (!SupportsMultipleDisplays())
270 return; 268 return;
271 269
272 UpdateDisplay("1000x600,600x400"); 270 UpdateDisplay("1000x600,600x400");
273 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 271 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
274 aura::test::WindowTestApi root_window0_test_api(root_windows[0]); 272 aura::test::WindowTestApi root_window0_test_api(root_windows[0]);
275 aura::test::WindowTestApi root_window1_test_api(root_windows[1]); 273 aura::test::WindowTestApi root_window1_test_api(root_windows[1]);
276 274
277 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); 275 root_windows[0]->MoveCursorTo(gfx::Point(10, 10));
278 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); 276 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString());
279 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); 277 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
280 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); 278 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
281 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); 279 root_windows[1]->MoveCursorTo(gfx::Point(10, 20));
282 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); 280 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString());
283 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); 281 EXPECT_FALSE(root_window0_test_api.ContainsMouse());
284 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); 282 EXPECT_TRUE(root_window1_test_api.ContainsMouse());
285 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); 283 root_windows[0]->MoveCursorTo(gfx::Point(20, 10));
286 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); 284 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString());
287 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); 285 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
288 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); 286 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
289 } 287 }
290 288
291 TEST_F(ExtendedDesktopTest, CycleWindows) { 289 TEST_F(ExtendedDesktopTest, CycleWindows) {
292 if (!SupportsMultipleDisplays()) 290 if (!SupportsMultipleDisplays())
293 return; 291 return;
294 292
295 UpdateDisplay("700x500,500x500"); 293 UpdateDisplay("700x500,500x500");
296 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 294 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
297 295
298 WindowCycleController* controller = 296 WindowCycleController* controller =
299 Shell::GetInstance()->window_cycle_controller(); 297 Shell::GetInstance()->window_cycle_controller();
300 298
301 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 299 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
302 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); 300 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow());
303 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); 301 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
304 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); 302 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow());
305 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); 303 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView()));
306 304
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); 336 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true);
339 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); 337 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView()));
340 } 338 }
341 339
342 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { 340 TEST_F(ExtendedDesktopTest, GetRootWindowAt) {
343 if (!SupportsMultipleDisplays()) 341 if (!SupportsMultipleDisplays())
344 return; 342 return;
345 343
346 UpdateDisplay("700x500,500x500"); 344 UpdateDisplay("700x500,500x500");
347 SetSecondaryDisplayLayout(DisplayLayout::LEFT); 345 SetSecondaryDisplayLayout(DisplayLayout::LEFT);
348 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 346 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
349 347
350 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); 348 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100)));
351 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); 349 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100)));
352 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); 350 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300)));
353 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); 351 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300)));
354 352
355 // Zero origin. 353 // Zero origin.
356 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); 354 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0)));
357 355
358 // Out of range point should return the primary root window 356 // Out of range point should return the primary root window
359 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); 357 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0)));
360 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); 358 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100)));
361 } 359 }
362 360
363 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { 361 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) {
364 if (!SupportsMultipleDisplays()) 362 if (!SupportsMultipleDisplays())
365 return; 363 return;
366 364
367 UpdateDisplay("700x500,500x500"); 365 UpdateDisplay("700x500,500x500");
368 SetSecondaryDisplayLayout(DisplayLayout::LEFT); 366 SetSecondaryDisplayLayout(DisplayLayout::LEFT);
369 367
370 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 368 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
371 369
372 // Containing rect. 370 // Containing rect.
373 EXPECT_EQ(root_windows[1], 371 EXPECT_EQ(root_windows[1],
374 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); 372 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50)));
375 EXPECT_EQ(root_windows[0], 373 EXPECT_EQ(root_windows[0],
376 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); 374 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50)));
377 375
378 // Intersecting rect. 376 // Intersecting rect.
379 EXPECT_EQ(root_windows[1], 377 EXPECT_EQ(root_windows[1],
380 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300))); 378 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300)));
(...skipping 17 matching lines...) Expand all
398 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); 396 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50)));
399 EXPECT_EQ(root_windows[0], 397 EXPECT_EQ(root_windows[0],
400 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); 398 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)));
401 } 399 }
402 400
403 TEST_F(ExtendedDesktopTest, Capture) { 401 TEST_F(ExtendedDesktopTest, Capture) {
404 if (!SupportsMultipleDisplays()) 402 if (!SupportsMultipleDisplays())
405 return; 403 return;
406 404
407 UpdateDisplay("1000x600,600x400"); 405 UpdateDisplay("1000x600,600x400");
408 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 406 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
409 407
410 aura::test::EventCountDelegate r1_d1; 408 aura::test::EventCountDelegate r1_d1;
411 aura::test::EventCountDelegate r1_d2; 409 aura::test::EventCountDelegate r1_d2;
412 aura::test::EventCountDelegate r2_d1; 410 aura::test::EventCountDelegate r2_d1;
413 411
414 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( 412 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate(
415 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); 413 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
416 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( 414 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate(
417 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); 415 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0]));
418 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( 416 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // Make sure the mouse_moved_handler_ is properly reset. 455 // Make sure the mouse_moved_handler_ is properly reset.
458 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset()); 456 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset());
459 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset()); 457 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset());
460 } 458 }
461 459
462 TEST_F(ExtendedDesktopTest, MoveWindow) { 460 TEST_F(ExtendedDesktopTest, MoveWindow) {
463 if (!SupportsMultipleDisplays()) 461 if (!SupportsMultipleDisplays())
464 return; 462 return;
465 463
466 UpdateDisplay("1000x600,600x400"); 464 UpdateDisplay("1000x600,600x400");
467 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 465 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
468 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 466 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
469 467
470 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); 468 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
471 469
472 d1->SetBounds(gfx::Rect(1010, 10, 100, 100)); 470 d1->SetBounds(gfx::Rect(1010, 10, 100, 100));
473 EXPECT_EQ("1010,10 100x100", 471 EXPECT_EQ("1010,10 100x100",
474 d1->GetWindowBoundsInScreen().ToString()); 472 d1->GetWindowBoundsInScreen().ToString());
475 473
476 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); 474 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow());
477 475
(...skipping 17 matching lines...) Expand all
495 } 493 }
496 494
497 // Verifies if the mouse event arrives to the window even when the window 495 // Verifies if the mouse event arrives to the window even when the window
498 // moves to another root in a pre-target handler. See: crbug.com/157583 496 // moves to another root in a pre-target handler. See: crbug.com/157583
499 TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) { 497 TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) {
500 if (!SupportsMultipleDisplays()) 498 if (!SupportsMultipleDisplays())
501 return; 499 return;
502 500
503 UpdateDisplay("1000x600,600x400"); 501 UpdateDisplay("1000x600,600x400");
504 502
505 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 503 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
506 aura::test::EventCountDelegate delegate; 504 aura::test::EventCountDelegate delegate;
507 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( 505 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
508 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); 506 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0]));
509 MoveWindowByClickEventHandler event_handler(window.get()); 507 MoveWindowByClickEventHandler event_handler(window.get());
510 window->AddPreTargetHandler(&event_handler); 508 window->AddPreTargetHandler(&event_handler);
511 509
512 aura::test::EventGenerator& event_generator(GetEventGenerator()); 510 aura::test::EventGenerator& event_generator(GetEventGenerator());
513 511
514 event_generator.MoveMouseToCenterOf(window.get()); 512 event_generator.MoveMouseToCenterOf(window.get());
515 event_generator.ClickLeftButton(); 513 event_generator.ClickLeftButton();
516 // Both mouse pressed and released arrive at the window and its delegate. 514 // Both mouse pressed and released arrive at the window and its delegate.
517 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset()); 515 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset());
518 // Also event_handler moves the window to another root at mouse release. 516 // Also event_handler moves the window to another root at mouse release.
519 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 517 EXPECT_EQ(root_windows[1], window->GetRootWindow());
520 } 518 }
521 519
522 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { 520 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) {
523 if (!SupportsMultipleDisplays()) 521 if (!SupportsMultipleDisplays())
524 return; 522 return;
525 523
526 UpdateDisplay("1000x1000,1000x1000"); 524 UpdateDisplay("1000x1000,1000x1000");
527 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 525 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
528 526
529 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching( 527 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching(
530 root_windows[0]->GetBoundsInScreen()); 528 root_windows[0]->GetBoundsInScreen());
531 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching( 529 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching(
532 root_windows[1]->GetBoundsInScreen()); 530 root_windows[1]->GetBoundsInScreen());
533 EXPECT_NE(display0.id(), display1.id()); 531 EXPECT_NE(display0.id(), display1.id());
534 532
535 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); 533 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100));
536 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); 534 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
537 535
(...skipping 11 matching lines...) Expand all
549 EXPECT_EQ("500,10 1000x100", 547 EXPECT_EQ("500,10 1000x100",
550 d1->GetWindowBoundsInScreen().ToString()); 548 d1->GetWindowBoundsInScreen().ToString());
551 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); 549 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
552 } 550 }
553 551
554 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { 552 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) {
555 if (!SupportsMultipleDisplays()) 553 if (!SupportsMultipleDisplays())
556 return; 554 return;
557 555
558 UpdateDisplay("1000x600,600x400"); 556 UpdateDisplay("1000x600,600x400");
559 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 557 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
560 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); 558 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100));
561 views::Widget* w1_t1 = CreateTestWidgetWithParent( 559 views::Widget* w1_t1 = CreateTestWidgetWithParent(
562 w1, gfx::Rect(50, 50, 50, 50), false /* transient */); 560 w1, gfx::Rect(50, 50, 50, 50), false /* transient */);
563 // Transient child of the transient child. 561 // Transient child of the transient child.
564 views::Widget* w1_t11 = CreateTestWidgetWithParent( 562 views::Widget* w1_t11 = CreateTestWidgetWithParent(
565 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */); 563 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */);
566 564
567 views::Widget* w11 = CreateTestWidgetWithParent( 565 views::Widget* w11 = CreateTestWidgetWithParent(
568 w1, gfx::Rect(10, 10, 40, 40), true /* child */); 566 w1, gfx::Rect(10, 10, 40, 40), true /* child */);
569 views::Widget* w11_t1 = CreateTestWidgetWithParent( 567 views::Widget* w11_t1 = CreateTestWidgetWithParent(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 w1_t1->GetWindowBoundsInScreen().ToString()); 607 w1_t1->GetWindowBoundsInScreen().ToString());
610 } 608 }
611 609
612 // Test if the Window::ConvertPointToTarget works across root windows. 610 // Test if the Window::ConvertPointToTarget works across root windows.
613 // TODO(oshima): Move multiple display suport and this test to aura. 611 // TODO(oshima): Move multiple display suport and this test to aura.
614 TEST_F(ExtendedDesktopTest, ConvertPoint) { 612 TEST_F(ExtendedDesktopTest, ConvertPoint) {
615 if (!SupportsMultipleDisplays()) 613 if (!SupportsMultipleDisplays())
616 return; 614 return;
617 gfx::Screen* screen = Shell::GetInstance()->screen(); 615 gfx::Screen* screen = Shell::GetInstance()->screen();
618 UpdateDisplay("1000x600,600x400"); 616 UpdateDisplay("1000x600,600x400");
619 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 617 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
620 gfx::Display display_1 = screen->GetDisplayNearestWindow(root_windows[0]); 618 gfx::Display display_1 = screen->GetDisplayNearestWindow(root_windows[0]);
621 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); 619 EXPECT_EQ("0,0", display_1.bounds().origin().ToString());
622 gfx::Display display_2 = screen->GetDisplayNearestWindow(root_windows[1]); 620 gfx::Display display_2 = screen->GetDisplayNearestWindow(root_windows[1]);
623 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); 621 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString());
624 622
625 aura::Window* d1 = 623 aura::Window* d1 =
626 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); 624 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView();
627 aura::Window* d2 = 625 aura::Window* d2 =
628 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView(); 626 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView();
629 EXPECT_EQ(root_windows[0], d1->GetRootWindow()); 627 EXPECT_EQ(root_windows[0], d1->GetRootWindow());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 EXPECT_FALSE(tray->HasSystemBubble()); 698 EXPECT_FALSE(tray->HasSystemBubble());
701 UpdateDisplay("500x600,600x400"); 699 UpdateDisplay("500x600,600x400");
702 EXPECT_FALSE(tray->HasSystemBubble()); 700 EXPECT_FALSE(tray->HasSystemBubble());
703 } 701 }
704 702
705 TEST_F(ExtendedDesktopTest, StayInSameRootWindow) { 703 TEST_F(ExtendedDesktopTest, StayInSameRootWindow) {
706 if (!SupportsMultipleDisplays()) 704 if (!SupportsMultipleDisplays())
707 return; 705 return;
708 706
709 UpdateDisplay("100x100,200x200"); 707 UpdateDisplay("100x100,200x200");
710 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 708 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
711 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 50, 50)); 709 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 50, 50));
712 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); 710 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow());
713 w1->SetBounds(gfx::Rect(150, 10, 50, 50)); 711 w1->SetBounds(gfx::Rect(150, 10, 50, 50));
714 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); 712 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
715 713
716 // The widget stays in the same root if kStayInSameRootWindowKey is set to 714 // The widget stays in the same root if kStayInSameRootWindowKey is set to
717 // true. 715 // true.
718 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true); 716 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true);
719 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); 717 w1->SetBounds(gfx::Rect(10, 10, 50, 50));
720 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); 718 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow());
(...skipping 21 matching lines...) Expand all
742 window->SetBoundsInScreen(gfx::Rect(150, 10, 50, 50), 740 window->SetBoundsInScreen(gfx::Rect(150, 10, 50, 50),
743 ScreenAsh::GetSecondaryDisplay()); 741 ScreenAsh::GetSecondaryDisplay());
744 EXPECT_EQ(root_windows[0], window->GetRootWindow()); 742 EXPECT_EQ(root_windows[0], window->GetRootWindow());
745 } 743 }
746 744
747 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { 745 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) {
748 if (!SupportsMultipleDisplays()) 746 if (!SupportsMultipleDisplays())
749 return; 747 return;
750 748
751 UpdateDisplay("100x100,200x200"); 749 UpdateDisplay("100x100,200x200");
752 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 750 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
753 751
754 // Create normal windows on both displays. 752 // Create normal windows on both displays.
755 views::Widget* widget1 = CreateTestWidget( 753 views::Widget* widget1 = CreateTestWidget(
756 Shell::GetScreen()->GetPrimaryDisplay().bounds()); 754 Shell::GetScreen()->GetPrimaryDisplay().bounds());
757 widget1->Show(); 755 widget1->Show();
758 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); 756 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow());
759 views::Widget* widget2 = CreateTestWidget( 757 views::Widget* widget2 = CreateTestWidget(
760 ScreenAsh::GetSecondaryDisplay().bounds()); 758 ScreenAsh::GetSecondaryDisplay().bounds());
761 widget2->Show(); 759 widget2->Show();
762 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow()); 760 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow());
(...skipping 11 matching lines...) Expand all
774 lock_widget->Show(); 772 lock_widget->Show();
775 textfield->RequestFocus(); 773 textfield->RequestFocus();
776 774
777 aura::client::FocusClient* focus_client = 775 aura::client::FocusClient* focus_client =
778 aura::client::GetFocusClient(root_windows[0]); 776 aura::client::GetFocusClient(root_windows[0]);
779 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 777 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
780 778
781 // The lock window should get events on both root windows. 779 // The lock window should get events on both root windows.
782 aura::test::EventGenerator& event_generator(GetEventGenerator()); 780 aura::test::EventGenerator& event_generator(GetEventGenerator());
783 781
784 event_generator.set_current_root_window(root_windows[0]->GetDispatcher()); 782 event_generator.set_current_root_window(root_windows[0]);
785 event_generator.PressKey(ui::VKEY_A, 0); 783 event_generator.PressKey(ui::VKEY_A, 0);
786 event_generator.ReleaseKey(ui::VKEY_A, 0); 784 event_generator.ReleaseKey(ui::VKEY_A, 0);
787 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 785 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
788 EXPECT_EQ("a", UTF16ToASCII(textfield->text())); 786 EXPECT_EQ("a", UTF16ToASCII(textfield->text()));
789 787
790 event_generator.set_current_root_window(root_windows[1]->GetDispatcher()); 788 event_generator.set_current_root_window(root_windows[1]);
791 event_generator.PressKey(ui::VKEY_B, 0); 789 event_generator.PressKey(ui::VKEY_B, 0);
792 event_generator.ReleaseKey(ui::VKEY_B, 0); 790 event_generator.ReleaseKey(ui::VKEY_B, 0);
793 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 791 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
794 EXPECT_EQ("ab", UTF16ToASCII(textfield->text())); 792 EXPECT_EQ("ab", UTF16ToASCII(textfield->text()));
795 793
796 // Deleting 2nd display. The lock window still should get the events. 794 // Deleting 2nd display. The lock window still should get the events.
797 UpdateDisplay("100x100"); 795 UpdateDisplay("100x100");
798 event_generator.PressKey(ui::VKEY_C, 0); 796 event_generator.PressKey(ui::VKEY_C, 0);
799 event_generator.ReleaseKey(ui::VKEY_C, 0); 797 event_generator.ReleaseKey(ui::VKEY_C, 0);
800 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 798 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
801 EXPECT_EQ("abc", UTF16ToASCII(textfield->text())); 799 EXPECT_EQ("abc", UTF16ToASCII(textfield->text()));
802 800
803 // Creating 2nd display again, and lock window still should get events 801 // Creating 2nd display again, and lock window still should get events
804 // on both root windows. 802 // on both root windows.
805 UpdateDisplay("100x100,200x200"); 803 UpdateDisplay("100x100,200x200");
806 root_windows = Shell::GetAllRootWindows(); 804 root_windows = Shell::GetAllRootWindows();
807 event_generator.set_current_root_window(root_windows[0]->GetDispatcher()); 805 event_generator.set_current_root_window(root_windows[0]);
808 event_generator.PressKey(ui::VKEY_D, 0); 806 event_generator.PressKey(ui::VKEY_D, 0);
809 event_generator.ReleaseKey(ui::VKEY_D, 0); 807 event_generator.ReleaseKey(ui::VKEY_D, 0);
810 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 808 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
811 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text())); 809 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text()));
812 810
813 event_generator.set_current_root_window(root_windows[1]->GetDispatcher()); 811 event_generator.set_current_root_window(root_windows[1]);
814 event_generator.PressKey(ui::VKEY_E, 0); 812 event_generator.PressKey(ui::VKEY_E, 0);
815 event_generator.ReleaseKey(ui::VKEY_E, 0); 813 event_generator.ReleaseKey(ui::VKEY_E, 0);
816 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); 814 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow());
817 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); 815 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text()));
818 } 816 }
819 817
820 TEST_F(ExtendedDesktopTest, PassiveGrab) { 818 TEST_F(ExtendedDesktopTest, PassiveGrab) {
821 if (!SupportsMultipleDisplays()) 819 if (!SupportsMultipleDisplays())
822 return; 820 return;
823 821
(...skipping 18 matching lines...) Expand all
842 generator.ReleaseLeftButton(); 840 generator.ReleaseLeftButton();
843 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); 841 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset());
844 842
845 generator.MoveMouseTo(400, 150); 843 generator.MoveMouseTo(400, 150);
846 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); 844 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset());
847 845
848 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 846 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
849 } 847 }
850 848
851 } // namespace ash 849 } // namespace ash
OLDNEW
« no previous file with comments | « trunk/src/ash/drag_drop/drag_drop_tracker_unittest.cc ('k') | trunk/src/ash/high_contrast/high_contrast_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698