Chromium Code Reviews| Index: ui/views/widget/widget_unittest.cc |
| diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc |
| index d21d64f0561abb292d08882b9cb7e2931a7e9aa7..e38df9f41973bc60940f927ac0c7b385571ade41 100644 |
| --- a/ui/views/widget/widget_unittest.cc |
| +++ b/ui/views/widget/widget_unittest.cc |
| @@ -1355,10 +1355,14 @@ TEST_F(WidgetTest, ResetCaptureOnGestureEnd) { |
| ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location, |
| ui::EF_LEFT_MOUSE_BUTTON); |
| + EXPECT_TRUE(toplevel->HasCapture()); |
| + |
| toplevel->OnMouseEvent(&press); |
| toplevel->OnMouseEvent(&release); |
| EXPECT_EQ(0, mouse->pressed()); |
| + EXPECT_FALSE(toplevel->HasCapture()); |
| + |
| // The end of the gesture should release the capture, and pressing on |mouse| |
| // should now reach |mouse|. |
| toplevel->OnGestureEvent(&end); |
| @@ -1370,6 +1374,35 @@ TEST_F(WidgetTest, ResetCaptureOnGestureEnd) { |
| RunPendingMessages(); |
| } |
| +TEST_F(WidgetTest, CaptureAutoReset) { |
|
sky
2013/09/04 23:32:15
Any time you're messing with capture your window n
Evan Stade
2013/09/04 23:35:52
how does the test above it get away with it?
|
| + Widget* toplevel = CreateTopLevelFramelessPlatformWidget(); |
| + View* container = new View; |
| + toplevel->SetContentsView(container); |
| + |
| + EXPECT_FALSE(toplevel->HasCapture()); |
| + toplevel->SetCapture(NULL); |
| + EXPECT_TRUE(toplevel->HasCapture()); |
| + |
| + // By default, mouse release removes capture. |
| + gfx::Point click_location(45, 15); |
| + ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location, |
| + ui::EF_LEFT_MOUSE_BUTTON); |
| + toplevel->OnMouseEvent(&release); |
| + EXPECT_FALSE(toplevel->HasCapture()); |
| + |
| + // Now a mouse release shouldn't remove capture. |
| + toplevel->set_auto_release_capture(false); |
| + toplevel->SetCapture(NULL); |
| + EXPECT_TRUE(toplevel->HasCapture()); |
| + toplevel->OnMouseEvent(&release); |
| + EXPECT_TRUE(toplevel->HasCapture()); |
| + toplevel->ReleaseCapture(); |
| + EXPECT_FALSE(toplevel->HasCapture()); |
| + |
| + toplevel->Close(); |
| + RunPendingMessages(); |
| +} |
| + |
| #if defined(USE_AURA) |
| // The key-event propagation from Widget happens differently on aura and |
| // non-aura systems because of the difference in IME. So this test works only on |