OLD | NEW |
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/screen_ash.h" | 7 #include "ash/screen_ash.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 EXPECT_EQ(root_windows[0], | 318 EXPECT_EQ(root_windows[0], |
319 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); | 319 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); |
320 | 320 |
321 // Out of range rect should return the primary root window. | 321 // Out of range rect should return the primary root window. |
322 EXPECT_EQ(root_windows[0], | 322 EXPECT_EQ(root_windows[0], |
323 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); | 323 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); |
324 EXPECT_EQ(root_windows[0], | 324 EXPECT_EQ(root_windows[0], |
325 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); | 325 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); |
326 } | 326 } |
327 | 327 |
328 #if defined(OS_WIN) | 328 TEST_F(ExtendedDesktopTest, Capture) { |
329 // TODO(mazda): Re-enable this (http://crbug.com/150986). | |
330 #define MAYBE_Capture DISABLED_Capture | |
331 #else | |
332 #define MAYBE_Capture Capture | |
333 #endif | |
334 | |
335 TEST_F(ExtendedDesktopTest, MAYBE_Capture) { | |
336 UpdateDisplay("1000x600,600x400"); | 329 UpdateDisplay("1000x600,600x400"); |
337 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 330 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
338 | 331 |
339 aura::test::EventCountDelegate r1_d1; | 332 aura::test::EventCountDelegate r1_d1; |
340 aura::test::EventCountDelegate r1_d2; | 333 aura::test::EventCountDelegate r1_d2; |
341 aura::test::EventCountDelegate r2_d1; | 334 aura::test::EventCountDelegate r2_d1; |
342 | 335 |
343 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( | 336 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( |
344 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); | 337 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); |
345 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( | 338 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( |
346 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); | 339 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); |
347 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( | 340 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( |
348 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); | 341 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); |
349 | 342 |
350 r1_w1->SetCapture(); | 343 r1_w1->SetCapture(); |
351 | 344 |
352 EXPECT_EQ(r1_w1.get(), | 345 EXPECT_EQ(r1_w1.get(), |
353 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); | 346 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); |
354 aura::test::EventGenerator generator2(root_windows[1]); | 347 aura::test::EventGenerator generator2(root_windows[1]); |
355 generator2.MoveMouseToCenterOf(r2_w1.get()); | 348 generator2.MoveMouseToCenterOf(r2_w1.get()); |
356 generator2.ClickLeftButton(); | 349 generator2.ClickLeftButton(); |
357 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset()); | 350 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset()); |
358 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset()); | 351 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset()); |
359 // The mouse is outside. On chromeos, the mouse is warped to the | 352 // The mouse is outside. On chromeos, the mouse is warped to the |
360 // dest root window, but it's not implemented on Win yet, so | 353 // dest root window, but it's not implemented on Win yet, so |
361 // no mouse move event on Win. | 354 // no mouse move event on Win. |
362 #if defined(OS_WIN) | |
363 EXPECT_EQ("1 0 0", r1_d1.GetMouseMotionCountsAndReset()); | |
364 #else | |
365 EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset()); | 355 EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset()); |
366 #endif | |
367 EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset()); | 356 EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset()); |
368 // (15,15) on 1st display is (-985,15) on 2nd display. | 357 // (15,15) on 1st display is (-985,15) on 2nd display. |
369 generator2.MoveMouseTo(-985, 15); | 358 generator2.MoveMouseTo(-985, 15); |
370 EXPECT_EQ("0 1 0", r1_d1.GetMouseMotionCountsAndReset()); | 359 EXPECT_EQ("0 1 0", r1_d1.GetMouseMotionCountsAndReset()); |
371 | 360 |
372 r1_w2->SetCapture(); | 361 r1_w2->SetCapture(); |
373 EXPECT_EQ(r1_w2.get(), | 362 EXPECT_EQ(r1_w2.get(), |
374 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); | 363 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); |
375 generator2.MoveMouseBy(10, 10); | 364 generator2.MoveMouseBy(10, 10); |
376 generator2.ClickLeftButton(); | 365 generator2.ClickLeftButton(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 MoveWindowByClickEventFilter event_filter(window.get()); | 424 MoveWindowByClickEventFilter event_filter(window.get()); |
436 window->AddPreTargetHandler(&event_filter); | 425 window->AddPreTargetHandler(&event_filter); |
437 aura::test::EventGenerator generator(root_windows[0], window.get()); | 426 aura::test::EventGenerator generator(root_windows[0], window.get()); |
438 generator.ClickLeftButton(); | 427 generator.ClickLeftButton(); |
439 // Both mouse pressed and released arrive at the window and its delegate. | 428 // Both mouse pressed and released arrive at the window and its delegate. |
440 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset()); | 429 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset()); |
441 // Also event_filter moves the window to another root at mouse release. | 430 // Also event_filter moves the window to another root at mouse release. |
442 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 431 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
443 } | 432 } |
444 | 433 |
445 // This test fails on the "Win Aura" bot: <http://crbug.com/157817>. | 434 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { |
446 #if defined(OS_WIN) | |
447 #define MAYBE_MoveWindowToDisplay DISABLED_MoveWindowToDisplay | |
448 #else | |
449 #define MAYBE_MoveWindowToDisplay MoveWindowToDisplay | |
450 #endif | |
451 TEST_F(ExtendedDesktopTest, MAYBE_MoveWindowToDisplay) { | |
452 UpdateDisplay("1000x1000,1000x1000"); | 435 UpdateDisplay("1000x1000,1000x1000"); |
453 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 436 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
454 | 437 |
455 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching( | 438 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching( |
456 root_windows[0]->GetBoundsInScreen()); | 439 root_windows[0]->GetBoundsInScreen()); |
457 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching( | 440 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching( |
458 root_windows[1]->GetBoundsInScreen()); | 441 root_windows[1]->GetBoundsInScreen()); |
459 EXPECT_NE(display0.id(), display1.id()); | 442 EXPECT_NE(display0.id(), display1.id()); |
460 | 443 |
461 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); | 444 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 | 688 |
706 aura::test::EventGenerator generator22(root_windows[1]); | 689 aura::test::EventGenerator generator22(root_windows[1]); |
707 generator22.PressKey(ui::VKEY_E, 0); | 690 generator22.PressKey(ui::VKEY_E, 0); |
708 generator22.ReleaseKey(ui::VKEY_E, 0); | 691 generator22.ReleaseKey(ui::VKEY_E, 0); |
709 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 692 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); |
710 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); | 693 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); |
711 } | 694 } |
712 | 695 |
713 } // namespace internal | 696 } // namespace internal |
714 } // namespace ash | 697 } // namespace ash |
OLD | NEW |