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

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: rewrote tests using EventGenerator 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..ebab1e699e81fc2e65205c186899908687d99aa9 100644
--- a/ash/wm/window_manager_unittest.cc
+++ b/ash/wm/window_manager_unittest.cc
@@ -646,52 +646,82 @@ TEST_F(WindowManagerTest, UpdateCursorVisibility) {
root_window->SetBounds(gfx::Rect(0, 0, 500, 500));
scoped_ptr<aura::Window> window(CreateTestWindowInShell(
SK_ColorWHITE, -1, gfx::Rect(0, 0, 500, 500)));
-
+ aura::test::EventGenerator generator(root_window, window.get());
oshima 2013/01/18 21:59:56 You should be able to use AshTestBase::GetEventGen
mazda 2013/01/18 22:44:39 Done.
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::TouchEvent touch_pressed1(
- ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 0, getTime());
- ui::TouchEvent touch_pressed2(
- ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), 1, getTime());
- ui::TouchEvent touch_released1(
- ui::ET_TOUCH_RELEASED, gfx::Point(0, 0), 0, getTime());
- ui::TouchEvent touch_released2(
- ui::ET_TOUCH_RELEASED, gfx::Point(0, 0), 1, getTime());
-
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
+ generator.MoveMouseTo(gfx::Point(0, 0));
EXPECT_TRUE(cursor_manager->IsCursorVisible());
- root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed1);
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ generator.PressTouch();
EXPECT_FALSE(cursor_manager->IsCursorVisible());
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
+ EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
+ generator.MoveMouseTo(gfx::Point(0, 0));
EXPECT_TRUE(cursor_manager->IsCursorVisible());
- root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released1);
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ generator.ReleaseTouch();
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();
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
+ cursor_manager->EnableMouseEvents();
+ cursor_manager->HideCursor();
+ generator.MoveMouseTo(gfx::Point(0, 0));
EXPECT_FALSE(cursor_manager->IsCursorVisible());
- root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2);
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ generator.PressTouch();
EXPECT_FALSE(cursor_manager->IsCursorVisible());
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
+ EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
+ generator.MoveMouseTo(gfx::Point(0, 0));
EXPECT_FALSE(cursor_manager->IsCursorVisible());
- root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2);
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ generator.ReleaseTouch();
EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
// Back to normal.
cursor_manager->EnableMouseEvents();
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
+ cursor_manager->ShowCursor();
+ generator.MoveMouseTo(gfx::Point(0, 0));
EXPECT_TRUE(cursor_manager->IsCursorVisible());
- root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_pressed2);
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ generator.PressTouch();
EXPECT_FALSE(cursor_manager->IsCursorVisible());
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_moved);
+ EXPECT_FALSE(cursor_manager->IsMouseEventsEnabled());
+ generator.MoveMouseTo(gfx::Point(0, 0));
EXPECT_TRUE(cursor_manager->IsCursorVisible());
- root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touch_released2);
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ generator.ReleaseTouch();
+ 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)));
+ aura::test::EventGenerator generator(root_window, window.get());
oshima 2013/01/18 21:59:56 ditto
mazda 2013/01/18 22:44:39 Done.
+ ash::CursorManager* cursor_manager =
+ ash::Shell::GetInstance()->cursor_manager();
+
+ // Pressing a key hides the cursor but does not disable mouse events.
+ generator.PressKey(ui::VKEY_A, ui::EF_NONE);
+ EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ // Moving mouse shows the cursor.
+ generator.MoveMouseTo(gfx::Point(0, 0));
+ EXPECT_TRUE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ // Releasing a key also hides the cursor but does not disable mouse events.
+ generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE);
+ EXPECT_FALSE(cursor_manager->IsCursorVisible());
+ EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled());
+ // Moving mouse shows the cursor again.
+ generator.MoveMouseTo(gfx::Point(0, 0));
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