Chromium Code Reviews| 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 |