diff options
Diffstat (limited to 'ui/aura/window_unittest.cc')
-rw-r--r-- | ui/aura/window_unittest.cc | 77 |
1 files changed, 18 insertions, 59 deletions
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 4872373..1cfac96 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -540,58 +540,18 @@ TEST_F(WindowTest, StackChildAbove) { EXPECT_EQ(child3.layer(), parent.layer()->children()[2]); } -// Ensure capture of touch events works. -TEST_F(WindowTest, TouchCaptureTests) { -CaptureWindowDelegateImpl delegate; - scoped_ptr<Window> window(CreateTestWindowWithDelegate( - &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_MOUSE)); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_TOUCH)); - - delegate.ResetCounts(); - - // Capture touch events. - window->SetCapture(ui::CW_LOCK_TOUCH); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_MOUSE)); - EXPECT_TRUE(window->HasCapture(ui::CW_LOCK_TOUCH)); - EXPECT_EQ(0, delegate.capture_lost_count()); - EXPECT_EQ(0, delegate.capture_changed_event_count()); - EventGenerator generator(root_window(), gfx::Point(50, 50)); - generator.PressLeftButton(); - EXPECT_EQ(0, delegate.mouse_event_count()); - - TouchEvent touchev(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0, getTime()); - root_window()->DispatchTouchEvent(&touchev); - EXPECT_EQ(1, delegate.touch_event_count()); - delegate.ResetCounts(); - window->ReleaseCapture(); - - // Capture both touch and mouse events. - window->SetCapture(ui::CW_LOCK_TOUCH | ui::CW_LOCK_MOUSE); - EXPECT_TRUE(window->HasCapture(ui::CW_LOCK_MOUSE)); - EXPECT_TRUE(window->HasCapture(ui::CW_LOCK_TOUCH)); - generator.PressLeftButton(); - EXPECT_EQ(1, delegate.mouse_event_count()); - - TouchEvent touchev2(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 1, getTime()); - root_window()->DispatchTouchEvent(&touchev2); - EXPECT_EQ(1, delegate.touch_event_count()); -} - // Various capture assertions. TEST_F(WindowTest, CaptureTests) { CaptureWindowDelegateImpl delegate; scoped_ptr<Window> window(CreateTestWindowWithDelegate( &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_MOUSE)); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_TOUCH)); + EXPECT_FALSE(window->HasCapture()); delegate.ResetCounts(); // Do a capture. - window->SetCapture(ui::CW_LOCK_MOUSE); - EXPECT_TRUE(window->HasCapture(ui::CW_LOCK_MOUSE)); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_TOUCH)); + window->SetCapture(); + EXPECT_TRUE(window->HasCapture()); EXPECT_EQ(0, delegate.capture_lost_count()); EXPECT_EQ(0, delegate.capture_changed_event_count()); EventGenerator generator(root_window(), gfx::Point(50, 50)); @@ -604,29 +564,29 @@ TEST_F(WindowTest, CaptureTests) { TouchEvent touchev(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0, getTime()); root_window()->DispatchTouchEvent(&touchev); - EXPECT_EQ(0, delegate.touch_event_count()); + EXPECT_EQ(1, delegate.touch_event_count()); delegate.ResetCounts(); window->ReleaseCapture(); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_MOUSE)); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_TOUCH)); + EXPECT_FALSE(window->HasCapture()); EXPECT_EQ(1, delegate.capture_lost_count()); EXPECT_EQ(1, delegate.capture_changed_event_count()); EXPECT_EQ(1, delegate.mouse_event_count()); + EXPECT_EQ(1, delegate.touch_event_count()); generator.PressLeftButton(); EXPECT_EQ(1, delegate.mouse_event_count()); TouchEvent touchev2(ui::ET_TOUCH_PRESSED, gfx::Point(250, 250), 1, getTime()); root_window()->DispatchTouchEvent(&touchev2); - EXPECT_EQ(0, delegate.touch_event_count()); + EXPECT_EQ(1, delegate.touch_event_count()); // Removing the capture window from parent should reset the capture window // in the root window. - window->SetCapture(ui::CW_LOCK_MOUSE); + window->SetCapture(); EXPECT_EQ(window.get(), root_window()->capture_window()); window->parent()->RemoveChild(window.get()); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_MOUSE)); + EXPECT_FALSE(window->HasCapture()); EXPECT_EQ(NULL, root_window()->capture_window()); } @@ -644,7 +604,7 @@ TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) { root_window()->DispatchTouchEvent(&press); EXPECT_EQ(1, delegate1.gesture_event_count()); delegate1.ResetCounts(); - w2->SetCapture(ui::CW_LOCK_TOUCH); + w2->SetCapture(); // The touch was cancelled when the other window // attained a touch lock. @@ -689,7 +649,7 @@ TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) { EXPECT_EQ(1, delegate.gesture_event_count()); delegate.ResetCounts(); - window->SetCapture(ui::CW_LOCK_TOUCH); + window->SetCapture(); EXPECT_EQ(0, delegate.gesture_event_count()); delegate.ResetCounts(); @@ -715,13 +675,12 @@ TEST_F(WindowTest, ChangeCaptureWhileMouseDown) { // aggregated. RunAllPendingInMessageLoop(); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_MOUSE)); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_TOUCH)); + EXPECT_FALSE(window->HasCapture()); // Do a capture. delegate.ResetCounts(); - window->SetCapture(ui::CW_LOCK_MOUSE); - EXPECT_TRUE(window->HasCapture(ui::CW_LOCK_MOUSE)); + window->SetCapture(); + EXPECT_TRUE(window->HasCapture()); EXPECT_EQ(0, delegate.capture_lost_count()); EXPECT_EQ(0, delegate.capture_changed_event_count()); EventGenerator generator(root_window(), gfx::Point(50, 50)); @@ -733,7 +692,7 @@ TEST_F(WindowTest, ChangeCaptureWhileMouseDown) { // Set capture to |w2|, should implicitly unset capture for |window|. delegate.ResetCounts(); delegate2.ResetCounts(); - w2->SetCapture(ui::CW_LOCK_MOUSE); + w2->SetCapture(); generator.MoveMouseTo(gfx::Point(40, 40), 2); EXPECT_EQ(1, delegate.capture_lost_count()); @@ -747,11 +706,11 @@ TEST_F(WindowTest, ReleaseCaptureOnDestroy) { CaptureWindowDelegateImpl delegate; scoped_ptr<Window> window(CreateTestWindowWithDelegate( &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL)); - EXPECT_FALSE(window->HasCapture(ui::CW_LOCK_MOUSE)); + EXPECT_FALSE(window->HasCapture()); // Do a capture. - window->SetCapture(ui::CW_LOCK_MOUSE); - EXPECT_TRUE(window->HasCapture(ui::CW_LOCK_MOUSE)); + window->SetCapture(); + EXPECT_TRUE(window->HasCapture()); // Destroy the window. window.reset(); |