Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: ash/wm/window_manager_unittest.cc

Issue 11888003: Differentiate invisible cursor mode and disabled mouse events mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/shell_test_api.h" 8 #include "ash/test/shell_test_api.h"
9 #include "ash/test/test_activation_delegate.h" 9 #include "ash/test/test_activation_delegate.h"
10 #include "ash/wm/activation_controller.h" 10 #include "ash/wm/activation_controller.h"
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 EXPECT_EQ(0, f1->num_mouse_events()); 635 EXPECT_EQ(0, f1->num_mouse_events());
636 EXPECT_EQ(1, f2->num_key_events()); 636 EXPECT_EQ(1, f2->num_key_events());
637 EXPECT_EQ(1, f2->num_mouse_events()); 637 EXPECT_EQ(1, f2->num_mouse_events());
638 638
639 env_filter->RemoveHandler(f2.get()); 639 env_filter->RemoveHandler(f2.get());
640 } 640 }
641 641
642 // We should show and hide the cursor in response to mouse and touch events as 642 // We should show and hide the cursor in response to mouse and touch events as
643 // requested. 643 // requested.
644 TEST_F(WindowManagerTest, UpdateCursorVisibility) { 644 TEST_F(WindowManagerTest, UpdateCursorVisibility) {
645 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); 645 aura::test::EventGenerator& generator = GetEventGenerator();
646 root_window->SetBounds(gfx::Rect(0, 0, 500, 500));
647 scoped_ptr<aura::Window> window(CreateTestWindowInShell(
648 SK_ColorWHITE, -1, gfx::Rect(0, 0, 500, 500)));
649
650 ash::CursorManager* cursor_manager = 646 ash::CursorManager* cursor_manager =
651 ash::Shell::GetInstance()->cursor_manager(); 647 ash::Shell::GetInstance()->cursor_manager();
652 648
653 ui::MouseEvent mouse_moved( 649 generator.MoveMouseTo(gfx::Point(0, 0));
654 ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0);
655 ui::TouchEvent touch_pressed1(
656 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, getTime());
657 ui::TouchEvent touch_pressed2(
658 ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1, getTime());
659 ui::TouchEvent touch_released1(
660 ui::ET_TOUCH_RELEASED, gfx::Point(0, 0), 0, getTime());
661 ui::TouchEvent touch_released2(
662 ui::ET_TOUCH_RELEASED, gfx::Point(0, 0), 1, getTime());
663
664 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
665 EXPECT_TRUE(cursor_manager->IsCursorVisible()); 650 EXPECT_TRUE(cursor_manager->IsCursorVisible());
666 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed1); 651 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
652 generator.PressTouch();
667 EXPECT_FALSE(cursor_manager->IsCursorVisible()); 653 EXPECT_FALSE(cursor_manager->IsCursorVisible());
668 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); 654 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
655 generator.MoveMouseTo(gfx::Point(0, 0));
669 EXPECT_TRUE(cursor_manager->IsCursorVisible()); 656 EXPECT_TRUE(cursor_manager->IsCursorVisible());
670 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released1); 657 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
658 generator.ReleaseTouch();
671 EXPECT_TRUE(cursor_manager->IsCursorVisible()); 659 EXPECT_TRUE(cursor_manager->IsCursorVisible());
660 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
672 661
673 // If someone else made cursor invisible keep it invisible even after it 662 // If someone else made cursor invisible keep it invisible even after it
674 // received mouse events. 663 // received mouse events.
675 cursor_manager->DisableMouseEvents(); 664 cursor_manager->EnableMouseEvents();
676 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); 665 cursor_manager->HideCursor();
666 generator.MoveMouseTo(gfx::Point(0, 0));
677 EXPECT_FALSE(cursor_manager->IsCursorVisible()); 667 EXPECT_FALSE(cursor_manager->IsCursorVisible());
678 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); 668 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
669 generator.PressTouch();
679 EXPECT_FALSE(cursor_manager->IsCursorVisible()); 670 EXPECT_FALSE(cursor_manager->IsCursorVisible());
680 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); 671 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
672 generator.MoveMouseTo(gfx::Point(0, 0));
681 EXPECT_FALSE(cursor_manager->IsCursorVisible()); 673 EXPECT_FALSE(cursor_manager->IsCursorVisible());
682 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2); 674 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
675 generator.ReleaseTouch();
683 EXPECT_FALSE(cursor_manager->IsCursorVisible()); 676 EXPECT_FALSE(cursor_manager->IsCursorVisible());
677 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
684 678
685 // Back to normal. 679 // Back to normal.
686 cursor_manager->EnableMouseEvents(); 680 cursor_manager->EnableMouseEvents();
687 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); 681 cursor_manager->ShowCursor();
682 generator.MoveMouseTo(gfx::Point(0, 0));
688 EXPECT_TRUE(cursor_manager->IsCursorVisible()); 683 EXPECT_TRUE(cursor_manager->IsCursorVisible());
689 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2); 684 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
685 generator.PressTouch();
690 EXPECT_FALSE(cursor_manager->IsCursorVisible()); 686 EXPECT_FALSE(cursor_manager->IsCursorVisible());
691 root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved); 687 EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
688 generator.MoveMouseTo(gfx::Point(0, 0));
692 EXPECT_TRUE(cursor_manager->IsCursorVisible()); 689 EXPECT_TRUE(cursor_manager->IsCursorVisible());
693 root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2); 690 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
691 generator.ReleaseTouch();
694 EXPECT_TRUE(cursor_manager->IsCursorVisible()); 692 EXPECT_TRUE(cursor_manager->IsCursorVisible());
693 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
694 }
695
696 TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) {
697 aura::test::EventGenerator& generator = GetEventGenerator();
698 ash::CursorManager* cursor_manager =
699 ash::Shell::GetInstance()->cursor_manager();
700
701 // Pressing a key hides the cursor but does not disable mouse events.
702 generator.PressKey(ui::VKEY_A, ui::EF_NONE);
703 EXPECT_FALSE(cursor_manager->IsCursorVisible());
704 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
705 // Moving mouse shows the cursor.
706 generator.MoveMouseTo(gfx::Point(0, 0));
707 EXPECT_TRUE(cursor_manager->IsCursorVisible());
708 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
709 // Releasing a key also hides the cursor but does not disable mouse events.
710 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE);
711 EXPECT_FALSE(cursor_manager->IsCursorVisible());
712 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
713 // Moving mouse shows the cursor again.
714 generator.MoveMouseTo(gfx::Point(0, 0));
715 EXPECT_TRUE(cursor_manager->IsCursorVisible());
716 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
695 } 717 }
696 718
697 } // namespace ash 719 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/session_state_controller_impl2.cc ('k') | content/browser/renderer_host/render_view_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698