| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/utility/screenshot_controller.h" | 5 #include "ash/utility/screenshot_controller.h" |
| 6 | 6 |
| 7 #include "ash/display/cursor_window_controller.h" | 7 #include "ash/display/cursor_window_controller.h" |
| 8 #include "ash/display/mouse_cursor_event_filter.h" | 8 #include "ash/display/mouse_cursor_event_filter.h" |
| 9 #include "ash/display/window_tree_host_manager.h" | 9 #include "ash/display/window_tree_host_manager.h" |
| 10 #include "ash/screenshot_delegate.h" | 10 #include "ash/screenshot_delegate.h" |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); | 249 EXPECT_EQ(1, GetScreenshotDelegate()->handle_take_partial_screenshot_count()); |
| 250 | 250 |
| 251 RunAllPendingInMessageLoop(); | 251 RunAllPendingInMessageLoop(); |
| 252 EXPECT_FALSE(IsActive()); | 252 EXPECT_FALSE(IsActive()); |
| 253 } | 253 } |
| 254 | 254 |
| 255 // Make sure ScreenshotController doesn't allow taking screenshot | 255 // Make sure ScreenshotController doesn't allow taking screenshot |
| 256 // across multiple monitors | 256 // across multiple monitors |
| 257 // cursor. See http://crbug.com/462229 | 257 // cursor. See http://crbug.com/462229 |
| 258 TEST_F(PartialScreenshotControllerTest, MouseWarpTest) { | 258 TEST_F(PartialScreenshotControllerTest, MouseWarpTest) { |
| 259 if (!SupportsMultipleDisplays()) | |
| 260 return; | |
| 261 | |
| 262 // Create two displays. | 259 // Create two displays. |
| 263 Shell* shell = Shell::GetInstance(); | 260 Shell* shell = Shell::GetInstance(); |
| 264 UpdateDisplay("500x500,500x500"); | 261 UpdateDisplay("500x500,500x500"); |
| 265 EXPECT_EQ(2U, shell->display_manager()->GetNumDisplays()); | 262 EXPECT_EQ(2U, shell->display_manager()->GetNumDisplays()); |
| 266 | 263 |
| 267 StartPartialScreenshotSession(); | 264 StartPartialScreenshotSession(); |
| 268 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(499, 11))); | 265 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(499, 11))); |
| 269 EXPECT_EQ(gfx::Point(499, 11), | 266 EXPECT_EQ(gfx::Point(499, 11), |
| 270 aura::Env::GetInstance()->last_mouse_location()); | 267 aura::Env::GetInstance()->last_mouse_location()); |
| 271 | 268 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 StartWindowScreenshotSession(); | 408 StartWindowScreenshotSession(); |
| 412 generator.MoveMouseTo(10, 10); | 409 generator.MoveMouseTo(10, 10); |
| 413 EXPECT_EQ(window1.get(), GetCurrentSelectedWindow()); | 410 EXPECT_EQ(window1.get(), GetCurrentSelectedWindow()); |
| 414 window1.reset(); | 411 window1.reset(); |
| 415 EXPECT_FALSE(GetCurrentSelectedWindow()); | 412 EXPECT_FALSE(GetCurrentSelectedWindow()); |
| 416 generator.ClickLeftButton(); | 413 generator.ClickLeftButton(); |
| 417 EXPECT_FALSE(test_delegate->GetSelectedWindowAndReset()); | 414 EXPECT_FALSE(test_delegate->GetSelectedWindowAndReset()); |
| 418 } | 415 } |
| 419 | 416 |
| 420 TEST_F(WindowScreenshotControllerTest, MultiDisplays) { | 417 TEST_F(WindowScreenshotControllerTest, MultiDisplays) { |
| 421 if (!SupportsMultipleDisplays()) | |
| 422 return; | |
| 423 | |
| 424 UpdateDisplay("400x400,500x500"); | 418 UpdateDisplay("400x400,500x500"); |
| 425 | 419 |
| 426 ui::test::EventGenerator& generator(GetEventGenerator()); | 420 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 427 test::TestScreenshotDelegate* test_delegate = GetScreenshotDelegate(); | 421 test::TestScreenshotDelegate* test_delegate = GetScreenshotDelegate(); |
| 428 | 422 |
| 429 std::unique_ptr<aura::Window> window1( | 423 std::unique_ptr<aura::Window> window1( |
| 430 CreateSelectableWindow(gfx::Rect(100, 100, 100, 100))); | 424 CreateSelectableWindow(gfx::Rect(100, 100, 100, 100))); |
| 431 std::unique_ptr<aura::Window> window2( | 425 std::unique_ptr<aura::Window> window2( |
| 432 CreateSelectableWindow(gfx::Rect(600, 200, 100, 100))); | 426 CreateSelectableWindow(gfx::Rect(600, 200, 100, 100))); |
| 433 EXPECT_NE(window1.get()->GetRootWindow(), window2.get()->GetRootWindow()); | 427 EXPECT_NE(window1.get()->GetRootWindow(), window2.get()->GetRootWindow()); |
| 434 | 428 |
| 435 StartWindowScreenshotSession(); | 429 StartWindowScreenshotSession(); |
| 436 generator.MoveMouseTo(150, 150); | 430 generator.MoveMouseTo(150, 150); |
| 437 EXPECT_EQ(window1.get(), GetCurrentSelectedWindow()); | 431 EXPECT_EQ(window1.get(), GetCurrentSelectedWindow()); |
| 438 generator.MoveMouseTo(650, 250); | 432 generator.MoveMouseTo(650, 250); |
| 439 EXPECT_EQ(window2.get(), GetCurrentSelectedWindow()); | 433 EXPECT_EQ(window2.get(), GetCurrentSelectedWindow()); |
| 440 generator.ClickLeftButton(); | 434 generator.ClickLeftButton(); |
| 441 EXPECT_EQ(window2.get(), test_delegate->GetSelectedWindowAndReset()); | 435 EXPECT_EQ(window2.get(), test_delegate->GetSelectedWindowAndReset()); |
| 442 | 436 |
| 443 window2->SetCapture(); | 437 window2->SetCapture(); |
| 444 wm::ActivateWindow(window2.get()); | 438 wm::ActivateWindow(window2.get()); |
| 445 StartWindowScreenshotSession(); | 439 StartWindowScreenshotSession(); |
| 446 generator.MoveMouseTo(150, 150); | 440 generator.MoveMouseTo(150, 150); |
| 447 EXPECT_EQ(window1.get(), GetCurrentSelectedWindow()); | 441 EXPECT_EQ(window1.get(), GetCurrentSelectedWindow()); |
| 448 generator.ClickLeftButton(); | 442 generator.ClickLeftButton(); |
| 449 EXPECT_EQ(window1.get(), test_delegate->GetSelectedWindowAndReset()); | 443 EXPECT_EQ(window1.get(), test_delegate->GetSelectedWindowAndReset()); |
| 450 } | 444 } |
| 451 | 445 |
| 452 TEST_F(ScreenshotControllerTest, MultipleDisplays) { | 446 TEST_F(ScreenshotControllerTest, MultipleDisplays) { |
| 453 if (!SupportsMultipleDisplays()) | |
| 454 return; | |
| 455 | |
| 456 StartPartialScreenshotSession(); | 447 StartPartialScreenshotSession(); |
| 457 EXPECT_TRUE(IsActive()); | 448 EXPECT_TRUE(IsActive()); |
| 458 UpdateDisplay("400x400,500x500"); | 449 UpdateDisplay("400x400,500x500"); |
| 459 RunAllPendingInMessageLoop(); | 450 RunAllPendingInMessageLoop(); |
| 460 EXPECT_FALSE(IsActive()); | 451 EXPECT_FALSE(IsActive()); |
| 461 | 452 |
| 462 StartPartialScreenshotSession(); | 453 StartPartialScreenshotSession(); |
| 463 EXPECT_TRUE(IsActive()); | 454 EXPECT_TRUE(IsActive()); |
| 464 UpdateDisplay("400x400"); | 455 UpdateDisplay("400x400"); |
| 465 RunAllPendingInMessageLoop(); | 456 RunAllPendingInMessageLoop(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 485 CreateSelectableWindow(gfx::Rect(100, 100, 100, 100))); | 476 CreateSelectableWindow(gfx::Rect(100, 100, 100, 100))); |
| 486 window->SetCapture(); | 477 window->SetCapture(); |
| 487 EXPECT_TRUE(window->HasCapture()); | 478 EXPECT_TRUE(window->HasCapture()); |
| 488 StartWindowScreenshotSession(); | 479 StartWindowScreenshotSession(); |
| 489 EXPECT_TRUE(window->HasCapture()); | 480 EXPECT_TRUE(window->HasCapture()); |
| 490 Cancel(); | 481 Cancel(); |
| 491 EXPECT_FALSE(window->HasCapture()); | 482 EXPECT_FALSE(window->HasCapture()); |
| 492 } | 483 } |
| 493 | 484 |
| 494 } // namespace ash | 485 } // namespace ash |
| OLD | NEW |