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/shell.h" | 5 #include "ash/shell.h" |
6 #include "ash/shell_window_ids.h" | 6 #include "ash/shell_window_ids.h" |
7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "ash/test/test_activation_delegate.h" | 8 #include "ash/test/test_activation_delegate.h" |
9 #include "ash/wm/activation_controller.h" | 9 #include "ash/wm/activation_controller.h" |
10 #include "ash/wm/cursor_manager.h" | 10 #include "ash/wm/cursor_manager.h" |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 582 } |
583 | 583 |
584 // We should show and hide the cursor in response to mouse and touch events as | 584 // We should show and hide the cursor in response to mouse and touch events as |
585 // requested. | 585 // requested. |
586 TEST_F(WindowManagerTest, UpdateCursorVisibility) { | 586 TEST_F(WindowManagerTest, UpdateCursorVisibility) { |
587 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); | 587 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
588 root_window->SetBounds(gfx::Rect(0, 0, 500, 500)); | 588 root_window->SetBounds(gfx::Rect(0, 0, 500, 500)); |
589 scoped_ptr<aura::Window> window(aura::test::CreateTestWindow( | 589 scoped_ptr<aura::Window> window(aura::test::CreateTestWindow( |
590 SK_ColorWHITE, -1, gfx::Rect(0, 0, 500, 500), NULL)); | 590 SK_ColorWHITE, -1, gfx::Rect(0, 0, 500, 500), NULL)); |
591 | 591 |
592 aura::shared::CompoundEventFilter* env_filter = | |
593 Shell::GetInstance()->env_filter(); | |
594 ash::CursorManager* cursor_manager = | 592 ash::CursorManager* cursor_manager = |
595 ash::Shell::GetInstance()->cursor_manager(); | 593 ash::Shell::GetInstance()->cursor_manager(); |
596 | 594 |
597 ui::MouseEvent mouse_moved( | 595 ui::MouseEvent mouse_moved( |
598 ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); | 596 ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); |
599 ui::TouchEvent touch_pressed1( | 597 ui::TouchEvent touch_pressed1( |
600 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, getTime()); | 598 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, getTime()); |
601 ui::TouchEvent touch_pressed2( | 599 ui::TouchEvent touch_pressed2( |
602 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1, getTime()); | 600 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1, getTime()); |
603 | 601 |
604 env_filter->set_update_cursor_visibility(true); | |
605 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); | 602 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); |
606 EXPECT_TRUE(cursor_manager->cursor_visible()); | 603 EXPECT_TRUE(cursor_manager->cursor_visible()); |
607 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed1); | 604 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed1); |
608 EXPECT_FALSE(cursor_manager->cursor_visible()); | 605 EXPECT_FALSE(cursor_manager->cursor_visible()); |
609 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); | 606 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); |
610 EXPECT_TRUE(cursor_manager->cursor_visible()); | 607 EXPECT_TRUE(cursor_manager->cursor_visible()); |
611 | 608 |
612 env_filter->set_update_cursor_visibility(false); | 609 // If someone else made cursor invisible keep it invisible even after it |
| 610 // received mouse events. |
613 cursor_manager->ShowCursor(false); | 611 cursor_manager->ShowCursor(false); |
614 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); | 612 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); |
615 EXPECT_FALSE(cursor_manager->cursor_visible()); | 613 EXPECT_FALSE(cursor_manager->cursor_visible()); |
| 614 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); |
| 615 EXPECT_FALSE(cursor_manager->cursor_visible()); |
| 616 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); |
| 617 EXPECT_FALSE(cursor_manager->cursor_visible()); |
| 618 |
| 619 // Back to normal. |
616 cursor_manager->ShowCursor(true); | 620 cursor_manager->ShowCursor(true); |
| 621 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); |
| 622 EXPECT_TRUE(cursor_manager->cursor_visible()); |
617 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); | 623 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); |
| 624 EXPECT_FALSE(cursor_manager->cursor_visible()); |
| 625 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); |
618 EXPECT_TRUE(cursor_manager->cursor_visible()); | 626 EXPECT_TRUE(cursor_manager->cursor_visible()); |
619 } | 627 } |
620 | 628 |
621 } // namespace ash | 629 } // namespace ash |
OLD | NEW |