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

Unified Diff: ui/views/widget/widget_unittest.cc

Issue 23533030: rAc: Enforce a 3 second grace period for generated card bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add a test Created 7 years, 3 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 | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698