Chromium Code Reviews| 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/multi_display_manager.h" | 6 #include "ash/display/multi_display_manager.h" |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/wm/window_cycle_controller.h" | 9 #include "ash/wm/window_cycle_controller.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 aura::Env::GetInstance()->display_manager()); | 81 aura::Env::GetInstance()->display_manager()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 private: | 84 private: |
| 85 DISALLOW_COPY_AND_ASSIGN(ExtendedDesktopTest); | 85 DISALLOW_COPY_AND_ASSIGN(ExtendedDesktopTest); |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 // Test conditions that root windows in extended desktop mode | 88 // Test conditions that root windows in extended desktop mode |
| 89 // must satisfy. | 89 // must satisfy. |
| 90 TEST_F(ExtendedDesktopTest, Basic) { | 90 TEST_F(ExtendedDesktopTest, Basic) { |
| 91 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | 91 UpdateDisplay("1000x600,600x400"); |
| 92 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 92 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 93 | 93 |
| 94 // All root windows must have the root window controller. | 94 // All root windows must have the root window controller. |
| 95 ASSERT_EQ(2U, root_windows.size()); | 95 ASSERT_EQ(2U, root_windows.size()); |
| 96 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); | 96 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); |
| 97 iter != root_windows.end(); ++iter) { | 97 iter != root_windows.end(); ++iter) { |
| 98 EXPECT_TRUE(wm::GetRootWindowController(*iter) != NULL); | 98 EXPECT_TRUE(wm::GetRootWindowController(*iter) != NULL); |
| 99 } | 99 } |
| 100 // Make sure root windows share the same controllers. | 100 // Make sure root windows share the same controllers. |
| 101 EXPECT_EQ(root_windows[0]->GetFocusManager(), | 101 EXPECT_EQ(root_windows[0]->GetFocusManager(), |
| 102 root_windows[1]->GetFocusManager()); | 102 root_windows[1]->GetFocusManager()); |
| 103 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]), | 103 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]), |
| 104 aura::client::GetActivationClient(root_windows[1])); | 104 aura::client::GetActivationClient(root_windows[1])); |
| 105 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]), | 105 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]), |
| 106 aura::client::GetCaptureClient(root_windows[1])); | 106 aura::client::GetCaptureClient(root_windows[1])); |
| 107 } | 107 } |
| 108 | 108 |
| 109 TEST_F(ExtendedDesktopTest, Activation) { | 109 TEST_F(ExtendedDesktopTest, Activation) { |
| 110 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | 110 UpdateDisplay("1000x600,600x400"); |
| 111 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 111 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 112 | 112 |
| 113 // Move the active root window to the secondary. | 113 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 114 Shell::GetInstance()->set_active_root_window(root_windows[1]); | 114 views::Widget* widget_on_2nd = |
| 115 | 115 CreateTestWidget(gfx::Rect(1200, 10, 100, 100)); |
| 116 views::Widget* widget_on_2nd = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 116 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); |
| 117 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow()); | 117 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow()); |
| 118 | 118 |
| 119 // Move the active root window back to the primary. | 119 EXPECT_EQ(widget_on_2nd->GetNativeView(), |
| 120 Shell::GetInstance()->set_active_root_window(root_windows[0]); | 120 root_windows[0]->GetFocusManager()->GetFocusedWindow()); |
| 121 | 121 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); |
| 122 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | |
| 123 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); | |
| 124 | 122 |
| 125 aura::test::EventGenerator generator_1st(root_windows[0]); | 123 aura::test::EventGenerator generator_1st(root_windows[0]); |
| 126 aura::test::EventGenerator generator_2nd(root_windows[1]); | 124 aura::test::EventGenerator generator_2nd(root_windows[1]); |
| 127 | 125 |
| 128 // Clicking a window changes the active window and active root window. | 126 // Clicking a window changes the active window and active root window. |
| 127 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); | |
| 128 generator_1st.ClickLeftButton(); | |
| 129 | |
| 130 EXPECT_EQ(widget_on_1st->GetNativeView(), | |
| 131 root_windows[0]->GetFocusManager()->GetFocusedWindow()); | |
| 132 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); | |
| 133 | |
| 129 generator_2nd.MoveMouseToCenterOf(widget_on_2nd->GetNativeView()); | 134 generator_2nd.MoveMouseToCenterOf(widget_on_2nd->GetNativeView()); |
| 130 generator_2nd.ClickLeftButton(); | 135 generator_2nd.ClickLeftButton(); |
| 131 | 136 |
| 132 EXPECT_EQ(widget_on_2nd->GetNativeView(), | 137 EXPECT_EQ(widget_on_2nd->GetNativeView(), |
| 133 root_windows[0]->GetFocusManager()->GetFocusedWindow()); | 138 root_windows[0]->GetFocusManager()->GetFocusedWindow()); |
| 134 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); | 139 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); |
| 135 | |
| 136 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); | |
| 137 generator_1st.ClickLeftButton(); | |
| 138 | |
| 139 EXPECT_EQ(widget_on_1st->GetNativeView(), | |
| 140 root_windows[0]->GetFocusManager()->GetFocusedWindow()); | |
| 141 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); | |
| 142 } | 140 } |
| 143 | 141 |
| 144 TEST_F(ExtendedDesktopTest, SystemModal) { | 142 TEST_F(ExtendedDesktopTest, SystemModal) { |
| 145 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | 143 UpdateDisplay("1000x600,600x400"); |
| 146 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 144 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 147 Shell::GetInstance()->set_active_root_window(root_windows[0]); | |
| 148 | 145 |
| 149 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 146 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 150 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); | 147 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); |
| 151 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); | 148 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); |
| 152 | 149 |
| 153 // Change the active root window to 2nd. | |
| 154 Shell::GetInstance()->set_active_root_window(root_windows[1]); | |
| 155 | |
| 156 // Open system modal. Make sure it's on 2nd root window and active. | 150 // Open system modal. Make sure it's on 2nd root window and active. |
| 157 views::Widget* modal_widget = views::Widget::CreateWindowWithParent( | 151 views::Widget* modal_widget = views::Widget::CreateWindowWithBounds( |
| 158 new ModalWidgetDelegate(), NULL); | 152 new ModalWidgetDelegate(), gfx::Rect(1200, 100, 100, 100)); |
| 159 modal_widget->Show(); | 153 modal_widget->Show(); |
| 160 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView())); | 154 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView())); |
| 161 EXPECT_EQ(root_windows[1], modal_widget->GetNativeView()->GetRootWindow()); | 155 EXPECT_EQ(root_windows[1], modal_widget->GetNativeView()->GetRootWindow()); |
| 162 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow()); | 156 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow()); |
| 163 | 157 |
| 164 // Clicking a widget on widget_on_1st display should not change activation. | 158 // Clicking a widget on widget_on_1st display should not change activation. |
| 165 aura::test::EventGenerator generator_1st(root_windows[0]); | 159 aura::test::EventGenerator generator_1st(root_windows[0]); |
| 166 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); | 160 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); |
| 167 generator_1st.ClickLeftButton(); | 161 generator_1st.ClickLeftButton(); |
| 168 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView())); | 162 EXPECT_TRUE(wm::IsActiveWindow(modal_widget->GetNativeView())); |
| 169 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow()); | 163 EXPECT_EQ(root_windows[1], Shell::GetActiveRootWindow()); |
| 170 | 164 |
| 171 // Close system modal and so clicking a widget should work now. | 165 // Close system modal and so clicking a widget should work now. |
| 172 modal_widget->Close(); | 166 modal_widget->Close(); |
| 173 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); | 167 generator_1st.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); |
| 174 generator_1st.ClickLeftButton(); | 168 generator_1st.ClickLeftButton(); |
| 175 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); | 169 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); |
| 176 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); | 170 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); |
| 177 } | 171 } |
| 178 | 172 |
| 179 TEST_F(ExtendedDesktopTest, TestCursor) { | 173 TEST_F(ExtendedDesktopTest, TestCursor) { |
| 180 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | 174 UpdateDisplay("1000x600,600x400"); |
| 181 Shell::GetInstance()->ShowCursor(false); | 175 Shell::GetInstance()->ShowCursor(false); |
| 182 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 176 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 183 EXPECT_FALSE(root_windows[0]->cursor_shown()); | 177 EXPECT_FALSE(root_windows[0]->cursor_shown()); |
| 184 EXPECT_FALSE(root_windows[1]->cursor_shown()); | 178 EXPECT_FALSE(root_windows[1]->cursor_shown()); |
| 185 Shell::GetInstance()->ShowCursor(true); | 179 Shell::GetInstance()->ShowCursor(true); |
| 186 EXPECT_TRUE(root_windows[0]->cursor_shown()); | 180 EXPECT_TRUE(root_windows[0]->cursor_shown()); |
| 187 EXPECT_TRUE(root_windows[1]->cursor_shown()); | 181 EXPECT_TRUE(root_windows[1]->cursor_shown()); |
| 188 | 182 |
| 189 EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type()); | 183 EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type()); |
| 190 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type()); | 184 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type()); |
| 191 Shell::GetInstance()->SetCursor(ui::kCursorCopy); | 185 Shell::GetInstance()->SetCursor(ui::kCursorCopy); |
| 192 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type()); | 186 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type()); |
| 193 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); | 187 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); |
| 194 } | 188 } |
| 195 | 189 |
| 196 TEST_F(ExtendedDesktopTest, CycleWindows) { | 190 TEST_F(ExtendedDesktopTest, CycleWindows) { |
| 197 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); | 191 UpdateDisplay("700x500,500x500"); |
| 198 UpdateDisplay("0+0-700x500,0+0-500x500"); | |
| 199 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 192 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 200 | 193 |
| 201 WindowCycleController* controller = | 194 WindowCycleController* controller = |
| 202 Shell::GetInstance()->window_cycle_controller(); | 195 Shell::GetInstance()->window_cycle_controller(); |
| 203 | 196 |
| 204 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 197 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 205 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); | 198 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); |
| 206 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | 199 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); |
| 207 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); | 200 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); |
| 208 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | 201 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 233 | 226 |
| 234 // Backwards | 227 // Backwards |
| 235 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 228 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 236 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | 229 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); |
| 237 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 230 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 238 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); | 231 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); |
| 239 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 232 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 240 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | 233 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
| 241 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 234 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 242 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); | 235 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); |
| 243 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); | |
| 244 } | 236 } |
| 245 | 237 |
| 246 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 238 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
| 247 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); | 239 UpdateDisplay("700x500,500x500"); |
| 248 UpdateDisplay("0+0-700x500,0+0-500x500"); | |
| 249 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 240 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
| 250 internal::DisplayController::LEFT); | 241 internal::DisplayController::LEFT); |
| 251 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 242 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 252 | 243 |
| 253 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-400, 100))); | 244 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-400, 100))); |
| 254 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-1, 100))); | 245 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-1, 100))); |
| 255 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 300))); | 246 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 300))); |
| 256 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(700,300))); | 247 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(700,300))); |
| 257 | 248 |
| 258 // Zero origin. | 249 // Zero origin. |
| 259 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 0))); | 250 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 0))); |
| 260 | 251 |
| 261 // Out of range point should return the primary root window | 252 // Out of range point should return the primary root window |
| 262 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(-600, 0))); | 253 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(-600, 0))); |
| 263 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(701, 100))); | 254 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(701, 100))); |
| 264 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); | |
| 265 } | 255 } |
| 266 | 256 |
| 267 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { | 257 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { |
| 268 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); | 258 UpdateDisplay("700x500,500x500"); |
| 269 UpdateDisplay("0+0-700x500,0+0-500x500"); | |
| 270 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 259 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
| 271 internal::DisplayController::LEFT); | 260 internal::DisplayController::LEFT); |
| 272 | 261 |
| 273 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 262 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 274 | 263 |
| 275 // Containing rect. | 264 // Containing rect. |
| 276 EXPECT_EQ(root_windows[1], | 265 EXPECT_EQ(root_windows[1], |
| 277 Shell::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); | 266 Shell::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); |
| 278 EXPECT_EQ(root_windows[0], | 267 EXPECT_EQ(root_windows[0], |
| 279 Shell::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); | 268 Shell::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 294 EXPECT_EQ(root_windows[1], | 283 EXPECT_EQ(root_windows[1], |
| 295 Shell::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0))); | 284 Shell::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0))); |
| 296 EXPECT_EQ(root_windows[0], | 285 EXPECT_EQ(root_windows[0], |
| 297 Shell::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); | 286 Shell::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); |
| 298 | 287 |
| 299 // Out of range rect should return the primary root window. | 288 // Out of range rect should return the primary root window. |
| 300 EXPECT_EQ(root_windows[0], | 289 EXPECT_EQ(root_windows[0], |
| 301 Shell::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); | 290 Shell::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); |
| 302 EXPECT_EQ(root_windows[0], | 291 EXPECT_EQ(root_windows[0], |
| 303 Shell::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); | 292 Shell::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); |
| 304 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); | |
| 305 } | 293 } |
| 306 | 294 |
| 307 TEST_F(ExtendedDesktopTest, Capture) { | 295 TEST_F(ExtendedDesktopTest, Capture) { |
| 308 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | 296 UpdateDisplay("1000x600,600x400"); |
| 309 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 297 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 310 | 298 |
| 311 aura::test::EventCountDelegate r1_d1; | 299 aura::test::EventCountDelegate r1_d1; |
| 312 aura::test::EventCountDelegate r1_d2; | 300 aura::test::EventCountDelegate r1_d2; |
| 313 aura::test::EventCountDelegate r2_d1; | 301 aura::test::EventCountDelegate r2_d1; |
| 314 | 302 |
| 315 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( | 303 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( |
| 316 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); | 304 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); |
| 317 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( | 305 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( |
| 318 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); | 306 &r1_d2, 0, gfx::Rect(10, 100, 100, 100), root_windows[0])); |
| 319 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( | 307 scoped_ptr<aura::Window> r2_w1(aura::test::CreateTestWindowWithDelegate( |
| 320 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); | 308 &r2_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[1])); |
| 309 | |
| 321 r1_w1->SetCapture(); | 310 r1_w1->SetCapture(); |
| 322 | 311 |
| 323 EXPECT_EQ(r1_w1.get(), | 312 EXPECT_EQ(r1_w1.get(), |
| 324 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); | 313 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); |
| 325 aura::test::EventGenerator generator2(root_windows[1]); | 314 aura::test::EventGenerator generator2(root_windows[1]); |
| 326 generator2.MoveMouseToCenterOf(r2_w1.get()); | 315 generator2.MoveMouseToCenterOf(r2_w1.get()); |
| 327 generator2.ClickLeftButton(); | 316 generator2.ClickLeftButton(); |
| 328 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset()); | 317 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset()); |
| 329 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset()); | 318 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset()); |
| 330 EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset()); | 319 // the mouse is outside, so no move event will be sent. |
|
Daniel Erat
2012/07/23 20:47:57
nit: capitalize "The"
oshima
2012/07/23 21:15:39
Done.
| |
| 320 EXPECT_EQ("1 0 0", r1_d1.GetMouseMotionCountsAndReset()); | |
| 331 EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset()); | 321 EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset()); |
| 322 // (15,15) on 1st display is (-985,15) on 2nd display. | |
| 323 generator2.MoveMouseTo(-985, 15); | |
| 324 EXPECT_EQ("0 1 0", r1_d1.GetMouseMotionCountsAndReset()); | |
| 332 | 325 |
| 333 r1_w2->SetCapture(); | 326 r1_w2->SetCapture(); |
| 334 EXPECT_EQ(r1_w2.get(), | 327 EXPECT_EQ(r1_w2.get(), |
| 335 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); | 328 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); |
| 336 generator2.MoveMouseBy(10, 10); | 329 generator2.MoveMouseBy(10, 10); |
| 337 generator2.ClickLeftButton(); | 330 generator2.ClickLeftButton(); |
| 338 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset()); | 331 EXPECT_EQ("0 0 0", r2_d1.GetMouseMotionCountsAndReset()); |
| 339 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset()); | 332 EXPECT_EQ("0 0", r2_d1.GetMouseButtonCountsAndReset()); |
| 340 // mouse is already entered. | 333 // mouse is already entered. |
| 341 EXPECT_EQ("0 1 0", r1_d2.GetMouseMotionCountsAndReset()); | 334 EXPECT_EQ("0 1 0", r1_d2.GetMouseMotionCountsAndReset()); |
| 342 EXPECT_EQ("1 1", r1_d2.GetMouseButtonCountsAndReset()); | 335 EXPECT_EQ("1 1", r1_d2.GetMouseButtonCountsAndReset()); |
| 343 | 336 |
| 344 r1_w2->ReleaseCapture(); | 337 r1_w2->ReleaseCapture(); |
| 345 EXPECT_EQ(NULL, | 338 EXPECT_EQ(NULL, |
| 346 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); | 339 aura::client::GetCaptureWindow(r2_w1->GetRootWindow())); |
| 347 generator2.MoveMouseBy(-10, -10); | 340 generator2.MoveMouseTo(15, 15); |
| 348 generator2.ClickLeftButton(); | 341 generator2.ClickLeftButton(); |
| 349 EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset()); | 342 EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset()); |
| 350 EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset()); | 343 EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset()); |
| 351 // Make sure the mouse_moved_handler_ is properly reset. | 344 // Make sure the mouse_moved_handler_ is properly reset. |
| 352 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset()); | 345 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset()); |
| 353 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset()); | 346 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset()); |
| 354 } | 347 } |
| 355 | 348 |
| 356 TEST_F(ExtendedDesktopTest, MoveWindow) { | 349 TEST_F(ExtendedDesktopTest, MoveWindow) { |
| 357 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); | 350 UpdateDisplay("1000x600,600x400"); |
| 358 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | |
| 359 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 351 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 360 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 352 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 361 | 353 |
| 362 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 354 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 363 | 355 |
| 364 d1->SetBounds(gfx::Rect(1010, 10, 100, 100)); | 356 d1->SetBounds(gfx::Rect(1010, 10, 100, 100)); |
| 365 EXPECT_EQ("1010,10 100x100", | 357 EXPECT_EQ("1010,10 100x100", |
| 366 d1->GetWindowBoundsInScreen().ToString()); | 358 d1->GetWindowBoundsInScreen().ToString()); |
| 367 | 359 |
| 368 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); | 360 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); |
| 369 | 361 |
| 370 d1->SetBounds(gfx::Rect(10, 10, 100, 100)); | 362 d1->SetBounds(gfx::Rect(10, 10, 100, 100)); |
| 371 EXPECT_EQ("10,10 100x100", | 363 EXPECT_EQ("10,10 100x100", |
| 372 d1->GetWindowBoundsInScreen().ToString()); | 364 d1->GetWindowBoundsInScreen().ToString()); |
| 373 | 365 |
| 374 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 366 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 375 | 367 |
| 376 // Make sure the bounds which doesn't fit to the root window | 368 // Make sure the bounds which doesn't fit to the root window |
| 377 // works correctly. | 369 // works correctly. |
| 378 d1->SetBounds(gfx::Rect(1560, 30, 100, 100)); | 370 d1->SetBounds(gfx::Rect(1560, 30, 100, 100)); |
| 379 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); | 371 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); |
| 380 EXPECT_EQ("1560,30 100x100", | 372 EXPECT_EQ("1560,30 100x100", |
| 381 d1->GetWindowBoundsInScreen().ToString()); | 373 d1->GetWindowBoundsInScreen().ToString()); |
| 382 | 374 |
| 383 // Setting outside of root windows will be moved to primary root window. | 375 // Setting outside of root windows will be moved to primary root window. |
| 384 // TODO(oshima): This one probably should pick the closest root window. | 376 // TODO(oshima): This one probably should pick the closest root window. |
| 385 d1->SetBounds(gfx::Rect(200, 10, 100, 100)); | 377 d1->SetBounds(gfx::Rect(200, 10, 100, 100)); |
| 386 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 378 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 387 | |
| 388 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); | |
| 389 } | 379 } |
| 390 | 380 |
| 391 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { | 381 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { |
| 392 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true); | 382 UpdateDisplay("1000x600,600x400"); |
| 393 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | |
| 394 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 383 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 395 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 384 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 396 views::Widget* w1_t1 = CreateTestWidgetWithParent( | 385 views::Widget* w1_t1 = CreateTestWidgetWithParent( |
| 397 w1, gfx::Rect(50, 50, 50, 50), false /* transient */); | 386 w1, gfx::Rect(50, 50, 50, 50), false /* transient */); |
| 398 // Transient child of the transient child. | 387 // Transient child of the transient child. |
| 399 views::Widget* w1_t11 = CreateTestWidgetWithParent( | 388 views::Widget* w1_t11 = CreateTestWidgetWithParent( |
| 400 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */); | 389 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */); |
| 401 | 390 |
| 402 views::Widget* w11 = CreateTestWidgetWithParent( | 391 views::Widget* w11 = CreateTestWidgetWithParent( |
| 403 w1, gfx::Rect(10, 10, 40, 40), true /* child */); | 392 w1, gfx::Rect(10, 10, 40, 40), true /* child */); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 w1_t11->GetWindowBoundsInScreen().ToString()); | 424 w1_t11->GetWindowBoundsInScreen().ToString()); |
| 436 EXPECT_EQ("1300,100 80x80", | 425 EXPECT_EQ("1300,100 80x80", |
| 437 w11_t1->GetWindowBoundsInScreen().ToString()); | 426 w11_t1->GetWindowBoundsInScreen().ToString()); |
| 438 | 427 |
| 439 // Transient window doesn't move between root window unless | 428 // Transient window doesn't move between root window unless |
| 440 // its transient parent moves. | 429 // its transient parent moves. |
| 441 w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50)); | 430 w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50)); |
| 442 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); | 431 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); |
| 443 EXPECT_EQ("10,50 50x50", | 432 EXPECT_EQ("10,50 50x50", |
| 444 w1_t1->GetWindowBoundsInScreen().ToString()); | 433 w1_t1->GetWindowBoundsInScreen().ToString()); |
| 445 | |
| 446 internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false); | |
| 447 } | 434 } |
| 448 | 435 |
| 449 namespace internal { | 436 namespace internal { |
| 450 // Test if the Window::ConvertPointToWindow works across root windows. | 437 // Test if the Window::ConvertPointToWindow works across root windows. |
| 451 // TODO(oshima): Move multiple display suport and this test to aura. | 438 // TODO(oshima): Move multiple display suport and this test to aura. |
| 452 TEST_F(ExtendedDesktopTest, ConvertPoint) { | 439 TEST_F(ExtendedDesktopTest, ConvertPoint) { |
| 453 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | 440 UpdateDisplay("1000x600,600x400"); |
| 454 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 441 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 455 gfx::Display& display_1 = | 442 gfx::Display& display_1 = |
| 456 display_manager()->FindDisplayForRootWindow(root_windows[0]); | 443 display_manager()->FindDisplayForRootWindow(root_windows[0]); |
| 457 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); | 444 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); |
| 458 gfx::Display& display_2 = | 445 gfx::Display& display_2 = |
| 459 display_manager()->FindDisplayForRootWindow(root_windows[1]); | 446 display_manager()->FindDisplayForRootWindow(root_windows[1]); |
| 460 Shell::GetInstance()->set_active_root_window(root_windows[0]); | 447 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); |
| 448 | |
| 461 aura::Window* d1 = | 449 aura::Window* d1 = |
| 462 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); | 450 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); |
| 463 Shell::GetInstance()->set_active_root_window(root_windows[1]); | |
| 464 aura::Window* d2 = | 451 aura::Window* d2 = |
| 465 CreateTestWidget(gfx::Rect(20, 20, 100, 100))->GetNativeView(); | 452 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView(); |
| 453 EXPECT_EQ(root_windows[0], d1->GetRootWindow()); | |
| 454 EXPECT_EQ(root_windows[1], d2->GetRootWindow()); | |
| 466 | 455 |
| 467 // TODO(oshima): | |
| 468 // This is a hack to emulate virtual screen coordinates. Cleanup this | |
| 469 // when the virtual screen coordinates is implemented.a | |
|
Daniel Erat
2012/07/23 20:47:57
nit: s/Cleanup/Clean up/, s/is/are/, remove traili
| |
| 470 gfx::Rect bounds = display_2.bounds(); | |
| 471 bounds.set_origin(gfx::Point(500, 500)); | |
| 472 display_2.set_bounds(bounds); | |
| 473 // Convert point in the Root2's window to the Root1's window Coord. | 456 // Convert point in the Root2's window to the Root1's window Coord. |
| 474 gfx::Point p(0, 0); | 457 gfx::Point p(0, 0); |
| 475 aura::Window::ConvertPointToWindow(root_windows[1], root_windows[0], &p); | 458 aura::Window::ConvertPointToWindow(root_windows[1], root_windows[0], &p); |
| 476 EXPECT_EQ("500,500", p.ToString()); | 459 EXPECT_EQ("1000,0", p.ToString()); |
| 477 p.SetPoint(0, 0); | 460 p.SetPoint(0, 0); |
| 478 aura::Window::ConvertPointToWindow(d2, d1, &p); | 461 aura::Window::ConvertPointToWindow(d2, d1, &p); |
| 479 EXPECT_EQ("510,510", p.ToString()); | 462 EXPECT_EQ("1010,10", p.ToString()); |
| 480 | 463 |
| 481 // Convert point in the Root1's window to the Root2's window Coord. | 464 // Convert point in the Root1's window to the Root2's window Coord. |
| 482 p.SetPoint(0, 0); | 465 p.SetPoint(0, 0); |
| 483 aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p); | 466 aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p); |
| 484 EXPECT_EQ("-500,-500", p.ToString()); | 467 EXPECT_EQ("-1000,0", p.ToString()); |
| 485 p.SetPoint(0, 0); | 468 p.SetPoint(0, 0); |
| 486 aura::Window::ConvertPointToWindow(d1, d2, &p); | 469 aura::Window::ConvertPointToWindow(d1, d2, &p); |
| 487 EXPECT_EQ("-510,-510", p.ToString()); | 470 EXPECT_EQ("-1010,-10", p.ToString()); |
| 471 | |
| 472 // Move the 2nd display to the bottom and test again. | |
| 473 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | |
| 474 internal::DisplayController::BOTTOM); | |
| 475 | |
| 476 display_2 = display_manager()->FindDisplayForRootWindow(root_windows[1]); | |
| 477 EXPECT_EQ("0,600", display_2.bounds().origin().ToString()); | |
| 478 | |
| 479 // Convert point in the Root2's window to the Root1's window Coord. | |
|
Daniel Erat
2012/07/23 20:47:57
nit: remove the "the"s in this comment
oshima
2012/07/23 21:15:39
Done.
| |
| 480 p.SetPoint(0, 0); | |
| 481 aura::Window::ConvertPointToWindow(root_windows[1], root_windows[0], &p); | |
| 482 EXPECT_EQ("0,600", p.ToString()); | |
| 483 p.SetPoint(0, 0); | |
| 484 aura::Window::ConvertPointToWindow(d2, d1, &p); | |
| 485 EXPECT_EQ("10,610", p.ToString()); | |
| 486 | |
| 487 // Convert point in the Root1's window to the Root2's window Coord. | |
|
Daniel Erat
2012/07/23 20:47:57
nit: ditto
oshima
2012/07/23 21:15:39
Done.
| |
| 488 p.SetPoint(0, 0); | |
| 489 aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p); | |
| 490 EXPECT_EQ("0,-600", p.ToString()); | |
| 491 p.SetPoint(0, 0); | |
| 492 aura::Window::ConvertPointToWindow(d1, d2, &p); | |
| 493 EXPECT_EQ("-10,-610", p.ToString()); | |
| 488 } | 494 } |
| 495 | |
| 489 } // namespace internal | 496 } // namespace internal |
| 490 } // namespace ash | 497 } // namespace ash |
| OLD | NEW |