| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 views::Widget* widget = new views::Widget; | 150 views::Widget* widget = new views::Widget; |
| 151 widget->Init(params); | 151 widget->Init(params); |
| 152 widget->Show(); | 152 widget->Show(); |
| 153 return widget; | 153 return widget; |
| 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 RETURN_IF_WIN8; |
| 161 |
| 160 UpdateDisplay("1000x600,600x400"); | 162 UpdateDisplay("1000x600,600x400"); |
| 161 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 163 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 162 | 164 |
| 163 // All root windows must have the root window controller. | 165 // All root windows must have the root window controller. |
| 164 ASSERT_EQ(2U, root_windows.size()); | 166 ASSERT_EQ(2U, root_windows.size()); |
| 165 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); | 167 for (Shell::RootWindowList::const_iterator iter = root_windows.begin(); |
| 166 iter != root_windows.end(); ++iter) { | 168 iter != root_windows.end(); ++iter) { |
| 167 EXPECT_TRUE(GetRootWindowController(*iter) != NULL); | 169 EXPECT_TRUE(GetRootWindowController(*iter) != NULL); |
| 168 } | 170 } |
| 169 // Make sure root windows share the same controllers. | 171 // Make sure root windows share the same controllers. |
| 170 EXPECT_EQ(aura::client::GetFocusClient(root_windows[0]), | 172 EXPECT_EQ(aura::client::GetFocusClient(root_windows[0]), |
| 171 aura::client::GetFocusClient(root_windows[1])); | 173 aura::client::GetFocusClient(root_windows[1])); |
| 172 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]), | 174 EXPECT_EQ(aura::client::GetActivationClient(root_windows[0]), |
| 173 aura::client::GetActivationClient(root_windows[1])); | 175 aura::client::GetActivationClient(root_windows[1])); |
| 174 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]), | 176 EXPECT_EQ(aura::client::GetCaptureClient(root_windows[0]), |
| 175 aura::client::GetCaptureClient(root_windows[1])); | 177 aura::client::GetCaptureClient(root_windows[1])); |
| 176 } | 178 } |
| 177 | 179 |
| 178 TEST_F(ExtendedDesktopTest, Activation) { | 180 TEST_F(ExtendedDesktopTest, Activation) { |
| 181 RETURN_IF_WIN8; |
| 182 |
| 179 UpdateDisplay("1000x600,600x400"); | 183 UpdateDisplay("1000x600,600x400"); |
| 180 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 184 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 181 | 185 |
| 182 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 186 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 183 views::Widget* widget_on_2nd = | 187 views::Widget* widget_on_2nd = |
| 184 CreateTestWidget(gfx::Rect(1200, 10, 100, 100)); | 188 CreateTestWidget(gfx::Rect(1200, 10, 100, 100)); |
| 185 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); | 189 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); |
| 186 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow()); | 190 EXPECT_EQ(root_windows[1], widget_on_2nd->GetNativeView()->GetRootWindow()); |
| 187 | 191 |
| 188 EXPECT_EQ(widget_on_2nd->GetNativeView(), | 192 EXPECT_EQ(widget_on_2nd->GetNativeView(), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 200 | 204 |
| 201 event_generator.MoveMouseToCenterOf(widget_on_2nd->GetNativeView()); | 205 event_generator.MoveMouseToCenterOf(widget_on_2nd->GetNativeView()); |
| 202 event_generator.ClickLeftButton(); | 206 event_generator.ClickLeftButton(); |
| 203 | 207 |
| 204 EXPECT_EQ(widget_on_2nd->GetNativeView(), | 208 EXPECT_EQ(widget_on_2nd->GetNativeView(), |
| 205 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow()); | 209 aura::client::GetFocusClient(root_windows[0])->GetFocusedWindow()); |
| 206 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); | 210 EXPECT_TRUE(wm::IsActiveWindow(widget_on_2nd->GetNativeView())); |
| 207 } | 211 } |
| 208 | 212 |
| 209 TEST_F(ExtendedDesktopTest, SystemModal) { | 213 TEST_F(ExtendedDesktopTest, SystemModal) { |
| 214 RETURN_IF_WIN8; |
| 215 |
| 210 UpdateDisplay("1000x600,600x400"); | 216 UpdateDisplay("1000x600,600x400"); |
| 211 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 217 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 212 | 218 |
| 213 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 219 views::Widget* widget_on_1st = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 214 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); | 220 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); |
| 215 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); | 221 EXPECT_EQ(root_windows[0], widget_on_1st->GetNativeView()->GetRootWindow()); |
| 216 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); | 222 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); |
| 217 | 223 |
| 218 // Open system modal. Make sure it's on 2nd root window and active. | 224 // Open system modal. Make sure it's on 2nd root window and active. |
| 219 views::Widget* modal_widget = views::Widget::CreateWindowWithContextAndBounds( | 225 views::Widget* modal_widget = views::Widget::CreateWindowWithContextAndBounds( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 235 | 241 |
| 236 // Close system modal and so clicking a widget should work now. | 242 // Close system modal and so clicking a widget should work now. |
| 237 modal_widget->Close(); | 243 modal_widget->Close(); |
| 238 event_generator.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); | 244 event_generator.MoveMouseToCenterOf(widget_on_1st->GetNativeView()); |
| 239 event_generator.ClickLeftButton(); | 245 event_generator.ClickLeftButton(); |
| 240 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); | 246 EXPECT_TRUE(wm::IsActiveWindow(widget_on_1st->GetNativeView())); |
| 241 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); | 247 EXPECT_EQ(root_windows[0], Shell::GetActiveRootWindow()); |
| 242 } | 248 } |
| 243 | 249 |
| 244 TEST_F(ExtendedDesktopTest, TestCursor) { | 250 TEST_F(ExtendedDesktopTest, TestCursor) { |
| 251 RETURN_IF_WIN8; |
| 252 |
| 245 UpdateDisplay("1000x600,600x400"); | 253 UpdateDisplay("1000x600,600x400"); |
| 246 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 254 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 247 EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type()); | 255 EXPECT_EQ(ui::kCursorPointer, root_windows[0]->last_cursor().native_type()); |
| 248 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type()); | 256 EXPECT_EQ(ui::kCursorPointer, root_windows[1]->last_cursor().native_type()); |
| 249 Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorCopy); | 257 Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorCopy); |
| 250 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type()); | 258 EXPECT_EQ(ui::kCursorCopy, root_windows[0]->last_cursor().native_type()); |
| 251 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); | 259 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); |
| 252 } | 260 } |
| 253 | 261 |
| 254 TEST_F(ExtendedDesktopTest, TestCursorLocation) { | 262 TEST_F(ExtendedDesktopTest, TestCursorLocation) { |
| 263 RETURN_IF_WIN8; |
| 264 |
| 255 UpdateDisplay("1000x600,600x400"); | 265 UpdateDisplay("1000x600,600x400"); |
| 256 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 266 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 257 aura::test::WindowTestApi root_window0_test_api(root_windows[0]); | 267 aura::test::WindowTestApi root_window0_test_api(root_windows[0]); |
| 258 aura::test::WindowTestApi root_window1_test_api(root_windows[1]); | 268 aura::test::WindowTestApi root_window1_test_api(root_windows[1]); |
| 259 | 269 |
| 260 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); | 270 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); |
| 261 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 271 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); |
| 262 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 272 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
| 263 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 273 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
| 264 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); | 274 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); |
| 265 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 275 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); |
| 266 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); | 276 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); |
| 267 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); | 277 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); |
| 268 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); | 278 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); |
| 269 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 279 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); |
| 270 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 280 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
| 271 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 281 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
| 272 } | 282 } |
| 273 | 283 |
| 274 TEST_F(ExtendedDesktopTest, CycleWindows) { | 284 TEST_F(ExtendedDesktopTest, CycleWindows) { |
| 285 RETURN_IF_WIN8; |
| 286 |
| 275 UpdateDisplay("700x500,500x500"); | 287 UpdateDisplay("700x500,500x500"); |
| 276 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 288 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 277 | 289 |
| 278 WindowCycleController* controller = | 290 WindowCycleController* controller = |
| 279 Shell::GetInstance()->window_cycle_controller(); | 291 Shell::GetInstance()->window_cycle_controller(); |
| 280 | 292 |
| 281 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 293 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 282 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); | 294 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); |
| 283 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | 295 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); |
| 284 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); | 296 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 313 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | 325 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); |
| 314 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 326 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 315 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | 327 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); |
| 316 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 328 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 317 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); | 329 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); |
| 318 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 330 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
| 319 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); | 331 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); |
| 320 } | 332 } |
| 321 | 333 |
| 322 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 334 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
| 335 RETURN_IF_WIN8; |
| 336 |
| 323 UpdateDisplay("700x500,500x500"); | 337 UpdateDisplay("700x500,500x500"); |
| 324 SetSecondaryDisplayLayout(DisplayLayout::LEFT); | 338 SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
| 325 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 339 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 326 | 340 |
| 327 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); | 341 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); |
| 328 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); | 342 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); |
| 329 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); | 343 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); |
| 330 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); | 344 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); |
| 331 | 345 |
| 332 // Zero origin. | 346 // Zero origin. |
| 333 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); | 347 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); |
| 334 | 348 |
| 335 // Out of range point should return the primary root window | 349 // Out of range point should return the primary root window |
| 336 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); | 350 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); |
| 337 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); | 351 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); |
| 338 } | 352 } |
| 339 | 353 |
| 340 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { | 354 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { |
| 355 RETURN_IF_WIN8; |
| 356 |
| 341 UpdateDisplay("700x500,500x500"); | 357 UpdateDisplay("700x500,500x500"); |
| 342 SetSecondaryDisplayLayout(DisplayLayout::LEFT); | 358 SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
| 343 | 359 |
| 344 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 360 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 345 | 361 |
| 346 // Containing rect. | 362 // Containing rect. |
| 347 EXPECT_EQ(root_windows[1], | 363 EXPECT_EQ(root_windows[1], |
| 348 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); | 364 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); |
| 349 EXPECT_EQ(root_windows[0], | 365 EXPECT_EQ(root_windows[0], |
| 350 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); | 366 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 368 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); | 384 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); |
| 369 | 385 |
| 370 // Out of range rect should return the primary root window. | 386 // Out of range rect should return the primary root window. |
| 371 EXPECT_EQ(root_windows[0], | 387 EXPECT_EQ(root_windows[0], |
| 372 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); | 388 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); |
| 373 EXPECT_EQ(root_windows[0], | 389 EXPECT_EQ(root_windows[0], |
| 374 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); | 390 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); |
| 375 } | 391 } |
| 376 | 392 |
| 377 TEST_F(ExtendedDesktopTest, Capture) { | 393 TEST_F(ExtendedDesktopTest, Capture) { |
| 394 RETURN_IF_WIN8; |
| 395 |
| 378 UpdateDisplay("1000x600,600x400"); | 396 UpdateDisplay("1000x600,600x400"); |
| 379 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 397 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 380 | 398 |
| 381 aura::test::EventCountDelegate r1_d1; | 399 aura::test::EventCountDelegate r1_d1; |
| 382 aura::test::EventCountDelegate r1_d2; | 400 aura::test::EventCountDelegate r1_d2; |
| 383 aura::test::EventCountDelegate r2_d1; | 401 aura::test::EventCountDelegate r2_d1; |
| 384 | 402 |
| 385 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( | 403 scoped_ptr<aura::Window> r1_w1(aura::test::CreateTestWindowWithDelegate( |
| 386 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); | 404 &r1_d1, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); |
| 387 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( | 405 scoped_ptr<aura::Window> r1_w2(aura::test::CreateTestWindowWithDelegate( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 generator2.MoveMouseTo(15, 15); | 442 generator2.MoveMouseTo(15, 15); |
| 425 generator2.ClickLeftButton(); | 443 generator2.ClickLeftButton(); |
| 426 EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset()); | 444 EXPECT_EQ("1 1 0", r2_d1.GetMouseMotionCountsAndReset()); |
| 427 EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset()); | 445 EXPECT_EQ("1 1", r2_d1.GetMouseButtonCountsAndReset()); |
| 428 // Make sure the mouse_moved_handler_ is properly reset. | 446 // Make sure the mouse_moved_handler_ is properly reset. |
| 429 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset()); | 447 EXPECT_EQ("0 0 0", r1_d2.GetMouseMotionCountsAndReset()); |
| 430 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset()); | 448 EXPECT_EQ("0 0", r1_d2.GetMouseButtonCountsAndReset()); |
| 431 } | 449 } |
| 432 | 450 |
| 433 TEST_F(ExtendedDesktopTest, MoveWindow) { | 451 TEST_F(ExtendedDesktopTest, MoveWindow) { |
| 452 RETURN_IF_WIN8; |
| 453 |
| 434 UpdateDisplay("1000x600,600x400"); | 454 UpdateDisplay("1000x600,600x400"); |
| 435 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 455 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 436 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 456 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 437 | 457 |
| 438 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 458 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 439 | 459 |
| 440 d1->SetBounds(gfx::Rect(1010, 10, 100, 100)); | 460 d1->SetBounds(gfx::Rect(1010, 10, 100, 100)); |
| 441 EXPECT_EQ("1010,10 100x100", | 461 EXPECT_EQ("1010,10 100x100", |
| 442 d1->GetWindowBoundsInScreen().ToString()); | 462 d1->GetWindowBoundsInScreen().ToString()); |
| 443 | 463 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 458 | 478 |
| 459 // Setting outside of root windows will be moved to primary root window. | 479 // Setting outside of root windows will be moved to primary root window. |
| 460 // TODO(oshima): This one probably should pick the closest root window. | 480 // TODO(oshima): This one probably should pick the closest root window. |
| 461 d1->SetBounds(gfx::Rect(200, 10, 100, 100)); | 481 d1->SetBounds(gfx::Rect(200, 10, 100, 100)); |
| 462 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 482 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 463 } | 483 } |
| 464 | 484 |
| 465 // Verifies if the mouse event arrives to the window even when the window | 485 // Verifies if the mouse event arrives to the window even when the window |
| 466 // moves to another root in a pre-target handler. See: crbug.com/157583 | 486 // moves to another root in a pre-target handler. See: crbug.com/157583 |
| 467 TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) { | 487 TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) { |
| 488 RETURN_IF_WIN8; |
| 489 |
| 468 UpdateDisplay("1000x600,600x400"); | 490 UpdateDisplay("1000x600,600x400"); |
| 469 | 491 |
| 470 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 492 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 471 aura::test::EventCountDelegate delegate; | 493 aura::test::EventCountDelegate delegate; |
| 472 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( | 494 scoped_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( |
| 473 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); | 495 &delegate, 0, gfx::Rect(10, 10, 100, 100), root_windows[0])); |
| 474 MoveWindowByClickEventHandler event_handler(window.get()); | 496 MoveWindowByClickEventHandler event_handler(window.get()); |
| 475 window->AddPreTargetHandler(&event_handler); | 497 window->AddPreTargetHandler(&event_handler); |
| 476 | 498 |
| 477 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 499 aura::test::EventGenerator& event_generator(GetEventGenerator()); |
| 478 | 500 |
| 479 event_generator.MoveMouseToCenterOf(window.get()); | 501 event_generator.MoveMouseToCenterOf(window.get()); |
| 480 event_generator.ClickLeftButton(); | 502 event_generator.ClickLeftButton(); |
| 481 // Both mouse pressed and released arrive at the window and its delegate. | 503 // Both mouse pressed and released arrive at the window and its delegate. |
| 482 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset()); | 504 EXPECT_EQ("1 1", delegate.GetMouseButtonCountsAndReset()); |
| 483 // Also event_handler moves the window to another root at mouse release. | 505 // Also event_handler moves the window to another root at mouse release. |
| 484 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 506 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
| 485 } | 507 } |
| 486 | 508 |
| 487 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { | 509 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { |
| 510 RETURN_IF_WIN8; |
| 511 |
| 488 UpdateDisplay("1000x1000,1000x1000"); | 512 UpdateDisplay("1000x1000,1000x1000"); |
| 489 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 513 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 490 | 514 |
| 491 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching( | 515 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching( |
| 492 root_windows[0]->GetBoundsInScreen()); | 516 root_windows[0]->GetBoundsInScreen()); |
| 493 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching( | 517 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching( |
| 494 root_windows[1]->GetBoundsInScreen()); | 518 root_windows[1]->GetBoundsInScreen()); |
| 495 EXPECT_NE(display0.id(), display1.id()); | 519 EXPECT_NE(display0.id(), display1.id()); |
| 496 | 520 |
| 497 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); | 521 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); |
| 498 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 522 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 499 | 523 |
| 500 // Move the window where the window spans both root windows. Since the second | 524 // Move the window where the window spans both root windows. Since the second |
| 501 // parameter is |display1|, the window should be shown on the secondary root. | 525 // parameter is |display1|, the window should be shown on the secondary root. |
| 502 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), | 526 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), |
| 503 display1); | 527 display1); |
| 504 EXPECT_EQ("500,10 1000x100", | 528 EXPECT_EQ("500,10 1000x100", |
| 505 d1->GetWindowBoundsInScreen().ToString()); | 529 d1->GetWindowBoundsInScreen().ToString()); |
| 506 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); | 530 EXPECT_EQ(root_windows[1], d1->GetNativeView()->GetRootWindow()); |
| 507 | 531 |
| 508 // Move to the primary root. | 532 // Move to the primary root. |
| 509 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), | 533 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), |
| 510 display0); | 534 display0); |
| 511 EXPECT_EQ("500,10 1000x100", | 535 EXPECT_EQ("500,10 1000x100", |
| 512 d1->GetWindowBoundsInScreen().ToString()); | 536 d1->GetWindowBoundsInScreen().ToString()); |
| 513 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 537 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 514 } | 538 } |
| 515 | 539 |
| 516 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { | 540 TEST_F(ExtendedDesktopTest, MoveWindowWithTransient) { |
| 541 RETURN_IF_WIN8; |
| 542 |
| 517 UpdateDisplay("1000x600,600x400"); | 543 UpdateDisplay("1000x600,600x400"); |
| 518 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 544 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 519 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | 545 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); |
| 520 views::Widget* w1_t1 = CreateTestWidgetWithParent( | 546 views::Widget* w1_t1 = CreateTestWidgetWithParent( |
| 521 w1, gfx::Rect(50, 50, 50, 50), false /* transient */); | 547 w1, gfx::Rect(50, 50, 50, 50), false /* transient */); |
| 522 // Transient child of the transient child. | 548 // Transient child of the transient child. |
| 523 views::Widget* w1_t11 = CreateTestWidgetWithParent( | 549 views::Widget* w1_t11 = CreateTestWidgetWithParent( |
| 524 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */); | 550 w1_t1, gfx::Rect(1200, 70, 30, 30), false /* transient */); |
| 525 | 551 |
| 526 views::Widget* w11 = CreateTestWidgetWithParent( | 552 views::Widget* w11 = CreateTestWidgetWithParent( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50)); | 591 w1_t1->SetBounds(gfx::Rect(10, 50, 50, 50)); |
| 566 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); | 592 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); |
| 567 EXPECT_EQ("10,50 50x50", | 593 EXPECT_EQ("10,50 50x50", |
| 568 w1_t1->GetWindowBoundsInScreen().ToString()); | 594 w1_t1->GetWindowBoundsInScreen().ToString()); |
| 569 } | 595 } |
| 570 | 596 |
| 571 namespace internal { | 597 namespace internal { |
| 572 // Test if the Window::ConvertPointToTarget works across root windows. | 598 // Test if the Window::ConvertPointToTarget works across root windows. |
| 573 // TODO(oshima): Move multiple display suport and this test to aura. | 599 // TODO(oshima): Move multiple display suport and this test to aura. |
| 574 TEST_F(ExtendedDesktopTest, ConvertPoint) { | 600 TEST_F(ExtendedDesktopTest, ConvertPoint) { |
| 601 RETURN_IF_WIN8; |
| 602 |
| 575 UpdateDisplay("1000x600,600x400"); | 603 UpdateDisplay("1000x600,600x400"); |
| 576 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 604 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 577 gfx::Display& display_1 = | 605 gfx::Display& display_1 = |
| 578 GetDisplayManager()->FindDisplayForRootWindow(root_windows[0]); | 606 GetDisplayManager()->FindDisplayForRootWindow(root_windows[0]); |
| 579 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); | 607 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); |
| 580 gfx::Display& display_2 = | 608 gfx::Display& display_2 = |
| 581 GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); | 609 GetDisplayManager()->FindDisplayForRootWindow(root_windows[1]); |
| 582 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); | 610 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); |
| 583 | 611 |
| 584 aura::Window* d1 = | 612 aura::Window* d1 = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 // Convert point in Root1's window to Root2's window Coord. | 649 // Convert point in Root1's window to Root2's window Coord. |
| 622 p.SetPoint(0, 0); | 650 p.SetPoint(0, 0); |
| 623 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); | 651 aura::Window::ConvertPointToTarget(root_windows[0], root_windows[1], &p); |
| 624 EXPECT_EQ("0,-600", p.ToString()); | 652 EXPECT_EQ("0,-600", p.ToString()); |
| 625 p.SetPoint(0, 0); | 653 p.SetPoint(0, 0); |
| 626 aura::Window::ConvertPointToTarget(d1, d2, &p); | 654 aura::Window::ConvertPointToTarget(d1, d2, &p); |
| 627 EXPECT_EQ("-10,-610", p.ToString()); | 655 EXPECT_EQ("-10,-610", p.ToString()); |
| 628 } | 656 } |
| 629 | 657 |
| 630 TEST_F(ExtendedDesktopTest, OpenSystemTray) { | 658 TEST_F(ExtendedDesktopTest, OpenSystemTray) { |
| 659 RETURN_IF_WIN8; |
| 660 |
| 631 UpdateDisplay("500x600,600x400"); | 661 UpdateDisplay("500x600,600x400"); |
| 632 SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 662 SystemTray* tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 633 ASSERT_FALSE(tray->HasSystemBubble()); | 663 ASSERT_FALSE(tray->HasSystemBubble()); |
| 634 | 664 |
| 635 aura::test::EventGenerator& event_generator(GetEventGenerator()); | 665 aura::test::EventGenerator& event_generator(GetEventGenerator()); |
| 636 | 666 |
| 637 // Opens the tray by a dummy click event and makes sure that adding/removing | 667 // Opens the tray by a dummy click event and makes sure that adding/removing |
| 638 // displays doesn't break anything. | 668 // displays doesn't break anything. |
| 639 event_generator.MoveMouseToCenterOf(tray->GetWidget()->GetNativeWindow()); | 669 event_generator.MoveMouseToCenterOf(tray->GetWidget()->GetNativeWindow()); |
| 640 event_generator.ClickLeftButton(); | 670 event_generator.ClickLeftButton(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 652 | 682 |
| 653 EXPECT_FALSE(tray->HasSystemBubble()); | 683 EXPECT_FALSE(tray->HasSystemBubble()); |
| 654 | 684 |
| 655 UpdateDisplay("500x600"); | 685 UpdateDisplay("500x600"); |
| 656 EXPECT_FALSE(tray->HasSystemBubble()); | 686 EXPECT_FALSE(tray->HasSystemBubble()); |
| 657 UpdateDisplay("500x600,600x400"); | 687 UpdateDisplay("500x600,600x400"); |
| 658 EXPECT_FALSE(tray->HasSystemBubble()); | 688 EXPECT_FALSE(tray->HasSystemBubble()); |
| 659 } | 689 } |
| 660 | 690 |
| 661 TEST_F(ExtendedDesktopTest, StayInSameRootWindow) { | 691 TEST_F(ExtendedDesktopTest, StayInSameRootWindow) { |
| 692 RETURN_IF_WIN8; |
| 693 |
| 662 UpdateDisplay("100x100,200x200"); | 694 UpdateDisplay("100x100,200x200"); |
| 663 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 695 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 664 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 50, 50)); | 696 views::Widget* w1 = CreateTestWidget(gfx::Rect(10, 10, 50, 50)); |
| 665 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); | 697 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); |
| 666 w1->SetBounds(gfx::Rect(150, 10, 50, 50)); | 698 w1->SetBounds(gfx::Rect(150, 10, 50, 50)); |
| 667 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); | 699 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); |
| 668 | 700 |
| 669 // The widget stays in the same root if kStayInSameRootWindowKey is set to | 701 // The widget stays in the same root if kStayInSameRootWindowKey is set to |
| 670 // true. | 702 // true. |
| 671 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true); | 703 w1->GetNativeView()->SetProperty(internal::kStayInSameRootWindowKey, true); |
| 672 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); | 704 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); |
| 673 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); | 705 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); |
| 674 | 706 |
| 675 // The widget should now move to the 1st root window without the property. | 707 // The widget should now move to the 1st root window without the property. |
| 676 w1->GetNativeView()->ClearProperty(internal::kStayInSameRootWindowKey); | 708 w1->GetNativeView()->ClearProperty(internal::kStayInSameRootWindowKey); |
| 677 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); | 709 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); |
| 678 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); | 710 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); |
| 679 } | 711 } |
| 680 | 712 |
| 681 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { | 713 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { |
| 714 RETURN_IF_WIN8; |
| 715 |
| 682 UpdateDisplay("100x100,200x200"); | 716 UpdateDisplay("100x100,200x200"); |
| 683 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 717 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 684 | 718 |
| 685 // Create normal windows on both displays. | 719 // Create normal windows on both displays. |
| 686 views::Widget* widget1 = CreateTestWidget( | 720 views::Widget* widget1 = CreateTestWidget( |
| 687 Shell::GetScreen()->GetPrimaryDisplay().bounds()); | 721 Shell::GetScreen()->GetPrimaryDisplay().bounds()); |
| 688 widget1->Show(); | 722 widget1->Show(); |
| 689 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); | 723 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); |
| 690 views::Widget* widget2 = CreateTestWidget( | 724 views::Widget* widget2 = CreateTestWidget( |
| 691 ScreenAsh::GetSecondaryDisplay().bounds()); | 725 ScreenAsh::GetSecondaryDisplay().bounds()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text())); | 776 EXPECT_EQ("abcd", UTF16ToASCII(textfield->text())); |
| 743 | 777 |
| 744 event_generator.set_current_root_window(root_windows[1]); | 778 event_generator.set_current_root_window(root_windows[1]); |
| 745 event_generator.PressKey(ui::VKEY_E, 0); | 779 event_generator.PressKey(ui::VKEY_E, 0); |
| 746 event_generator.ReleaseKey(ui::VKEY_E, 0); | 780 event_generator.ReleaseKey(ui::VKEY_E, 0); |
| 747 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); | 781 EXPECT_EQ(lock_widget->GetNativeView(), focus_client->GetFocusedWindow()); |
| 748 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); | 782 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); |
| 749 } | 783 } |
| 750 | 784 |
| 751 TEST_F(ExtendedDesktopTest, PassiveGrab) { | 785 TEST_F(ExtendedDesktopTest, PassiveGrab) { |
| 786 RETURN_IF_WIN8; |
| 787 |
| 752 EventLocationRecordingEventHandler event_handler; | 788 EventLocationRecordingEventHandler event_handler; |
| 753 ash::Shell::GetInstance()->AddPreTargetHandler(&event_handler); | 789 ash::Shell::GetInstance()->AddPreTargetHandler(&event_handler); |
| 754 | 790 |
| 755 UpdateDisplay("300x300,200x200"); | 791 UpdateDisplay("300x300,200x200"); |
| 756 | 792 |
| 757 views::Widget* widget = CreateTestWidget(gfx::Rect(50, 50, 200, 200)); | 793 views::Widget* widget = CreateTestWidget(gfx::Rect(50, 50, 200, 200)); |
| 758 widget->Show(); | 794 widget->Show(); |
| 759 ASSERT_EQ("50,50 200x200", widget->GetWindowBoundsInScreen().ToString()); | 795 ASSERT_EQ("50,50 200x200", widget->GetWindowBoundsInScreen().ToString()); |
| 760 | 796 |
| 761 aura::test::EventGenerator& generator(GetEventGenerator()); | 797 aura::test::EventGenerator& generator(GetEventGenerator()); |
| 762 generator.MoveMouseTo(150, 150); | 798 generator.MoveMouseTo(150, 150); |
| 763 EXPECT_EQ("100,100 150,150", event_handler.GetLocationsAndReset()); | 799 EXPECT_EQ("100,100 150,150", event_handler.GetLocationsAndReset()); |
| 764 | 800 |
| 765 generator.PressLeftButton(); | 801 generator.PressLeftButton(); |
| 766 generator.MoveMouseTo(400, 150); | 802 generator.MoveMouseTo(400, 150); |
| 767 | 803 |
| 768 EXPECT_EQ("350,100 400,150", event_handler.GetLocationsAndReset()); | 804 EXPECT_EQ("350,100 400,150", event_handler.GetLocationsAndReset()); |
| 769 | 805 |
| 770 generator.ReleaseLeftButton(); | 806 generator.ReleaseLeftButton(); |
| 771 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 807 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
| 772 | 808 |
| 773 generator.MoveMouseTo(400, 150); | 809 generator.MoveMouseTo(400, 150); |
| 774 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 810 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
| 775 | 811 |
| 776 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 812 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 777 } | 813 } |
| 778 | 814 |
| 779 } // namespace internal | 815 } // namespace internal |
| 780 } // namespace ash | 816 } // namespace ash |
| OLD | NEW |