diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-23 22:49:07 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-23 22:49:07 +0000 |
commit | f634dd3d11f123a08653d63ea4d2a5cfdd6a8082 (patch) | |
tree | dc4fb29a9317012dfe6b2569821b915b40297bef /ash/extended_desktop_unittest.cc | |
parent | 414c89d95a795b6b23eedea122e2593e5b87e585 (diff) | |
download | chromium_src-f634dd3d11f123a08653d63ea4d2a5cfdd6a8082.zip chromium_src-f634dd3d11f123a08653d63ea4d2a5cfdd6a8082.tar.gz chromium_src-f634dd3d11f123a08653d63ea4d2a5cfdd6a8082.tar.bz2 |
Enable Virtual Screen Coordinates and remove --ash-virtual-screen-coordinates
Update tests to work with VSC.
I'll land this after http://codereview.chromium.org/10795027/ is landed.
I kept active_root_window_ because we're planning to create a launcher per display, and I'm going to use it to decide on which display the status bubble will be shown.
BUG=123160
TEST=Updated tests, plus added new test cases to ExtendedDesktopText.ConvertPoint
Review URL: https://chromiumcodereview.appspot.com/10790090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147977 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/extended_desktop_unittest.cc')
-rw-r--r-- | ash/extended_desktop_unittest.cc | 129 |
1 files changed, 68 insertions, 61 deletions
diff --git a/ash/extended_desktop_unittest.cc b/ash/extended_desktop_unittest.cc index 179055e..0b0d554 100644 --- a/ash/extended_desktop_unittest.cc +++ b/ash/extended_desktop_unittest.cc @@ -88,7 +88,7 @@ class ExtendedDesktopTest : public test::AshTestBase { // Test conditions that root windows in extended desktop mode // must satisfy. TEST_F(ExtendedDesktopTest, Basic) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateDisplay("1000x600,600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); // All root windows must have the root window controller. @@ -107,55 +107,49 @@ TEST_F(ExtendedDesktopTest, Basic) { } TEST_F(ExtendedDesktopTest, Activation) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateDisplay("1000x600,600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); - // Move the active root window to the secondary. - Shell::GetInstance()->set_active_root_window(root_windows[1]); - - views::Widget* widget_on_2nd = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); - EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow()); - - // Move the active root window back to the primary. - Shell::GetInstance()->set_active_root_window(root_windows[0]); - views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); + views::Widget* widget_on_2nd = + CreateTestWidget(gfx::Rect(1200, 10, 100, 100)); EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); - - aura::test::EventGenerator generator_1st(root_windows[0]); - aura::test::EventGenerator generator_2nd(root_windows[1]); - - // Clicking a window changes the active window and active root window. - generator_2nd.MoveMouseToCenterOf(widget_on_2nd->GetNativeView()); - generator_2nd.ClickLeftButton(); + EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow()); EXPECT_EQ(widget_on_2nd->GetNativeView(), root_windows[0]->GetFocusManager()->GetFocusedWindow()); EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); + aura::test::EventGenerator generator_1st(root_windows[0]); + aura::test::EventGenerator generator_2nd(root_windows[1]); + + // Clicking a window changes the active window and active root window. generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); generator_1st.ClickLeftButton(); EXPECT_EQ(widget_on_1st->GetNativeView(), root_windows[0]->GetFocusManager()->GetFocusedWindow()); EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); + + generator_2nd.MoveMouseToCenterOf(widget_on_2nd->GetNativeView()); + generator_2nd.ClickLeftButton(); + + EXPECT_EQ(widget_on_2nd->GetNativeView(), + root_windows[0]->GetFocusManager()->GetFocusedWindow()); + EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); } TEST_F(ExtendedDesktopTest, SystemModal) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateDisplay("1000x600,600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); - Shell::GetInstance()->set_active_root_window(root_windows[0]); views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); - // Change the active root window to 2nd. - Shell::GetInstance()->set_active_root_window(root_windows[1]); - // Open system modal. Make sure it's on 2nd root window and active. - views::Widget* modal_widget = views::Widget::CreateWindowWithParent( - new ModalWidgetDelegate(), NULL); + views::Widget* modal_widget = views::Widget::CreateWindowWithBounds( + new ModalWidgetDelegate(), gfx::Rect(1200, 100, 100, 100)); modal_widget->Show(); EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView())); EXPECT_EQ(root_windows[1], modal_widget->GetNativeView()->GetRootWindow()); @@ -177,7 +171,7 @@ TEST_F(ExtendedDesktopTest, SystemModal) { } TEST_F(ExtendedDesktopTest, TestCursor) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateDisplay("1000x600,600x400"); Shell::GetInstance()->ShowCursor(false); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); EXPECT_FALSE(root_windows[0]->cursor_shown()); @@ -194,8 +188,7 @@ TEST_F(ExtendedDesktopTest, TestCursor) { } TEST_F(ExtendedDesktopTest, CycleWindows) { - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); - UpdateDisplay("0+0-700x500,0+0-500x500"); + UpdateDisplay("700x500,500x500"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); WindowCycleController* controller = @@ -240,12 +233,10 @@ TEST_F(ExtendedDesktopTest, CycleWindows) { EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); } TEST_F(ExtendedDesktopTest, GetRootWindowAt) { - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); - UpdateDisplay("0+0-700x500,0+0-500x500"); + UpdateDisplay("700x500,500x500"); Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( internal::DisplayController::LEFT); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); @@ -261,12 +252,10 @@ TEST_F(ExtendedDesktopTest, GetRootWindowAt) { // Out of range point should return the primary root window EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(-600, 0))); EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(701, 100))); - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); } TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); - UpdateDisplay("0+0-700x500,0+0-500x500"); + UpdateDisplay("700x500,500x500"); Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( internal::DisplayController::LEFT); @@ -301,11 +290,10 @@ TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { Shell::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); EXPECT_EQ(root_windows[0], Shell::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); } TEST_F(ExtendedDesktopTest, Capture) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateDisplay("1000x600,600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); aura::test::EventCountDelegate r1_d1; @@ -318,6 +306,7 @@ TEST_F(ExtendedDesktopTest, Capture) { &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); + r1_w1->SetCapture(); EXPECT_EQ(r1_w1.get(), @@ -327,8 +316,12 @@ TEST_F(ExtendedDesktopTest, Capture) { generator2.ClickLeftButton(); EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset()); EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset()); - EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset()); + // The mouse is outside, so no move event will be sent. + EXPECT_EQ("1 0 0", r1_d1.GetMouseMotionCountsAndReset()); EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset()); + // (15,15) on 1st display is (-985,15) on 2nd display. + generator2.MoveMouseTo(-985, 15); + EXPECT_EQ("0 1 0", r1_d1.GetMouseMotionCountsAndReset()); r1_w2->SetCapture(); EXPECT_EQ(r1_w2.get(), @@ -344,7 +337,7 @@ TEST_F(ExtendedDesktopTest, Capture) { r1_w2->ReleaseCapture(); EXPECT_EQ(NULL, aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); - generator2.MoveMouseBy(-10, -10); + generator2.MoveMouseTo(15, 15); generator2.ClickLeftButton(); EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset()); EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset()); @@ -354,8 +347,7 @@ TEST_F(ExtendedDesktopTest, Capture) { } TEST_F(ExtendedDesktopTest, MoveWindow) { - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateDisplay("1000x600,600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); @@ -384,13 +376,10 @@ TEST_F(ExtendedDesktopTest, MoveWindow) { // TODO(oshima): This one probably should pick the closest root window. d1->SetBounds(gfx::Rect(200, 10, 100, 100)); EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); - - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); } TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateDisplay("1000x600,600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); views::Widget* w1_t1 = CreateTestWidgetWithParent( @@ -442,49 +431,67 @@ TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); EXPECT_EQ("10,50 50x50", w1_t1->GetWindowBoundsInScreen().ToString()); - - internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); } namespace internal { // Test if the Window::ConvertPointToWindow works across root windows. // TODO(oshima): Move multiple display suport and this test to aura. TEST_F(ExtendedDesktopTest, ConvertPoint) { - UpdateDisplay("0+0-1000x600,1001+0-600x400"); + UpdateDisplay("1000x600,600x400"); Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); gfx::Display& display_1 = display_manager()->FindDisplayForRootWindow(root_windows[0]); EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); gfx::Display& display_2 = display_manager()->FindDisplayForRootWindow(root_windows[1]); - Shell::GetInstance()->set_active_root_window(root_windows[0]); + EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); + aura::Window* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); - Shell::GetInstance()->set_active_root_window(root_windows[1]); aura::Window* d2 = - CreateTestWidget(gfx::Rect(20, 20, 100, 100))->GetNativeView(); - - // TODO(oshima): - // This is a hack to emulate virtual screen coordinates. Cleanup this - // when the virtual screen coordinates is implemented.a - gfx::Rect bounds = display_2.bounds(); - bounds.set_origin(gfx::Point(500, 500)); - display_2.set_bounds(bounds); + CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView(); + EXPECT_EQ(root_windows[0], d1->GetRootWindow()); + EXPECT_EQ(root_windows[1], d2->GetRootWindow()); + // Convert point in the Root2's window to the Root1's window Coord. gfx::Point p(0, 0); aura::Window::ConvertPointToWindow(root_windows[1], root_windows[0], &p); - EXPECT_EQ("500,500", p.ToString()); + EXPECT_EQ("1000,0", p.ToString()); p.SetPoint(0, 0); aura::Window::ConvertPointToWindow(d2, d1, &p); - EXPECT_EQ("510,510", p.ToString()); + EXPECT_EQ("1010,10", p.ToString()); // Convert point in the Root1's window to the Root2's window Coord. p.SetPoint(0, 0); aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p); - EXPECT_EQ("-500,-500", p.ToString()); + EXPECT_EQ("-1000,0", p.ToString()); p.SetPoint(0, 0); aura::Window::ConvertPointToWindow(d1, d2, &p); - EXPECT_EQ("-510,-510", p.ToString()); + EXPECT_EQ("-1010,-10", p.ToString()); + + // Move the 2nd display to the bottom and test again. + Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( + internal::DisplayController::BOTTOM); + + display_2 = display_manager()->FindDisplayForRootWindow(root_windows[1]); + EXPECT_EQ("0,600", display_2.bounds().origin().ToString()); + + // Convert point in Root2's window to Root1's window Coord. + p.SetPoint(0, 0); + aura::Window::ConvertPointToWindow(root_windows[1], root_windows[0], &p); + EXPECT_EQ("0,600", p.ToString()); + p.SetPoint(0, 0); + aura::Window::ConvertPointToWindow(d2, d1, &p); + EXPECT_EQ("10,610", p.ToString()); + + // Convert point in Root1's window to Root2's window Coord. + p.SetPoint(0, 0); + aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p); + EXPECT_EQ("0,-600", p.ToString()); + p.SetPoint(0, 0); + aura::Window::ConvertPointToWindow(d1, d2, &p); + EXPECT_EQ("-10,-610", p.ToString()); } + } // namespace internal } // namespace ash |