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

Unified Diff: ui/aura/window_unittest.cc

Issue 8892013: Properly cleans up state when mouse capture changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Spelling Created 9 years 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/aura/root_window.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_unittest.cc
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index f16fd54285e747b1b909ae3291e8a78af1850f57..d8124464cb8911baf057499741469529847cc892 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -371,7 +371,7 @@ TEST_F(WindowTest, StackChildAbove) {
EXPECT_EQ(child3.layer(), parent.layer()->children()[2]);
}
-// Various destruction assertions.
+// Various capture assertions.
TEST_F(WindowTest, CaptureTests) {
aura::RootWindow* root_window = aura::RootWindow::GetInstance();
CaptureWindowDelegateImpl delegate;
@@ -415,6 +415,35 @@ TEST_F(WindowTest, CaptureTests) {
EXPECT_EQ(NULL, root_window->capture_window());
}
+// Changes capture while capture is already ongoing.
+TEST_F(WindowTest, ChangeCaptureWhileMouseDown) {
+ CaptureWindowDelegateImpl delegate;
+ scoped_ptr<Window> window(CreateTestWindowWithDelegate(
+ &delegate, 0, gfx::Rect(0, 0, 20, 20), NULL));
+ CaptureWindowDelegateImpl delegate2;
+ scoped_ptr<Window> w2(CreateTestWindowWithDelegate(
+ &delegate2, 0, gfx::Rect(20, 20, 20, 20), NULL));
+ EXPECT_FALSE(window->HasCapture());
+
+ // Do a capture.
+ window->SetCapture();
+ delegate.set_mouse_event_count(0);
+ EXPECT_TRUE(window->HasCapture());
+ EXPECT_EQ(0, delegate.capture_lost_count());
+ EventGenerator generator(gfx::Point(50, 50));
+ generator.PressLeftButton();
+ EXPECT_EQ(1, delegate.mouse_event_count());
+ delegate.set_mouse_event_count(0);
+
+ // Reset the capture.
+ window->ReleaseCapture();
+ w2->SetCapture();
+ delegate2.set_mouse_event_count(0);
+ generator.MoveMouseTo(gfx::Point(40, 40));
+ EXPECT_EQ(0, delegate.mouse_event_count());
+ EXPECT_EQ(2, delegate2.mouse_event_count());
+}
+
// Verifies capture is reset when a window is destroyed.
TEST_F(WindowTest, ReleaseCaptureOnDestroy) {
RootWindow* root_window = RootWindow::GetInstance();
« no previous file with comments | « ui/aura/root_window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698