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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/window_manager_unittest.cc
diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc
index bf1317ad957939e52763985e34156c5a3b30c5c9..11b7379c509bc57e2c927ec2676b0a0140fbbfe9 100644
--- a/ash/wm/window_manager_unittest.cc
+++ b/ash/wm/window_manager_unittest.cc
@@ -663,35 +663,81 @@ TEST_F(WindowManagerTest, UpdateCursorVisibility) {
root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
EXPECT_TRUE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed1);
EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
EXPECT_TRUE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released1);
EXPECT_TRUE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
// If someone else made cursor invisible keep it invisible even after it
// received mouse events.
- cursor_manager->DisableMouseEvents();
+ cursor_manager->EnableMouseEvents();
+ cursor_manager->HideCursor();
root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2);
EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2);
EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
// Back to normal.
cursor_manager->EnableMouseEvents();
+ cursor_manager->ShowCursor();
root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
EXPECT_TRUE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2);
EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
EXPECT_TRUE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2);
EXPECT_TRUE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+}
+
+TEST_F(WindowManagerTest, UpdateCursorVisibilityOnKeyEvent) {
+ aura::RootWindow* root_window = Shell::GetPrimaryRootWindow();
+ root_window->SetBounds(gfx::Rect(0, 0, 500, 500));
+ scoped_ptr<aura::Window> window(CreateTestWindowInShell(
+ SK_ColorWHITE, -1, gfx::Rect(0, 0, 500, 500)));
+
+ ash::CursorManager* cursor_manager =
+ ash::Shell::GetInstance()->cursor_manager();
+
+ ui::MouseEvent mouse_moved(
+ ui::ET_MOUSE_MOVED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0);
+ ui::KeyEvent key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false);
+ ui::KeyEvent key_released(ui::ET_KEY_RELEASED, ui::VKEY_A, ui::EF_NONE,
+ false);
oshima 2013/01/17 18:57:02 can you use event generator?
mazda 2013/01/18 20:34:54 Rewrote tests using EventGenerator. Thanks.
+ // Pressing a key hides the cursor but does not disable mouse events.
+ root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_pressed);
+ EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ // Moving mouse shows the cursor.
+ root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
+ EXPECT_TRUE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ // Releasing a key also hides the cursor but does not disable mouse events.
+ root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_pressed);
+ EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ // Moving mouse shows the cursor again.
+ root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
+ EXPECT_TRUE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
}
} // namespace ash
« 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