summaryrefslogtreecommitdiffstats
path: root/ui/aura/window_unittest.cc
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-11 20:46:11 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-11 20:46:11 +0000
commit759017e03abb02554ad06a1745290631c43d7751 (patch)
tree72e1dba4bff28d67a55401c04e49f992bc857a46 /ui/aura/window_unittest.cc
parentd871f21cb2266670edc0ff636a2d65e4c30b55f7 (diff)
downloadchromium_src-759017e03abb02554ad06a1745290631c43d7751.zip
chromium_src-759017e03abb02554ad06a1745290631c43d7751.tar.gz
chromium_src-759017e03abb02554ad06a1745290631c43d7751.tar.bz2
1) Invoke RootWindow::SetCapture(NULL) as a result from OS level mouse capture lost (eg from a popup)
2) Invoke OS level SetCapture, ReleaseCapture as a result of setting capture on root window BUG=107875 TEST= 1) Make sure that bug 105993 does not repro Review URL: https://chromiumcodereview.appspot.com/9228004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121655 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/aura/window_unittest.cc')
-rw-r--r--ui/aura/window_unittest.cc50
1 files changed, 34 insertions, 16 deletions
diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc
index 18e85f4..372dc3f 100644
--- a/ui/aura/window_unittest.cc
+++ b/ui/aura/window_unittest.cc
@@ -116,20 +116,27 @@ class DestroyOrphanDelegate : public TestWindowDelegate {
// Used in verifying mouse capture.
class CaptureWindowDelegateImpl : public TestWindowDelegate {
public:
- explicit CaptureWindowDelegateImpl()
- : capture_lost_count_(0),
- mouse_event_count_(0),
- touch_event_count_(0) {
+ CaptureWindowDelegateImpl() {
+ ResetCounts();
}
+ void ResetCounts() {
+ capture_changed_event_count_ = 0;
+ capture_lost_count_ = 0;
+ mouse_event_count_ = 0;
+ touch_event_count_ = 0;
+ }
+
+ int capture_changed_event_count() const {
+ return capture_changed_event_count_;
+ }
int capture_lost_count() const { return capture_lost_count_; }
- void set_capture_lost_count(int value) { capture_lost_count_ = value; }
int mouse_event_count() const { return mouse_event_count_; }
- void set_mouse_event_count(int value) { mouse_event_count_ = value; }
int touch_event_count() const { return touch_event_count_; }
- void set_touch_event_count(int value) { touch_event_count_ = value; }
virtual bool OnMouseEvent(MouseEvent* event) OVERRIDE {
+ if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED)
+ capture_changed_event_count_++;
mouse_event_count_++;
return false;
}
@@ -145,6 +152,7 @@ class CaptureWindowDelegateImpl : public TestWindowDelegate {
}
private:
+ int capture_changed_event_count_;
int capture_lost_count_;
int mouse_event_count_;
int touch_event_count_;
@@ -483,29 +491,34 @@ TEST_F(WindowTest, CaptureTests) {
&delegate, 0, gfx::Rect(0, 0, 20, 20), NULL));
EXPECT_FALSE(window->HasCapture());
+ delegate.ResetCounts();
+
// Do a capture.
window->SetCapture();
EXPECT_TRUE(window->HasCapture());
EXPECT_EQ(0, delegate.capture_lost_count());
+ EXPECT_EQ(0, delegate.capture_changed_event_count());
EventGenerator generator(gfx::Point(50, 50));
generator.PressLeftButton();
EXPECT_EQ(1, delegate.mouse_event_count());
generator.ReleaseLeftButton();
EXPECT_EQ(2, delegate.mouse_event_count());
- delegate.set_mouse_event_count(0);
+ delegate.ResetCounts();
TouchEvent touchev(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), 0);
root_window->DispatchTouchEvent(&touchev);
EXPECT_EQ(1, delegate.touch_event_count());
- delegate.set_touch_event_count(0);
+ delegate.ResetCounts();
window->ReleaseCapture();
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());
generator.PressLeftButton();
- EXPECT_EQ(0, delegate.mouse_event_count());
+ EXPECT_EQ(1, delegate.mouse_event_count());
root_window->DispatchTouchEvent(&touchev);
EXPECT_EQ(0, delegate.touch_event_count());
@@ -530,21 +543,26 @@ TEST_F(WindowTest, ChangeCaptureWhileMouseDown) {
EXPECT_FALSE(window->HasCapture());
// Do a capture.
+ delegate.ResetCounts();
window->SetCapture();
- delegate.set_mouse_event_count(0);
EXPECT_TRUE(window->HasCapture());
EXPECT_EQ(0, delegate.capture_lost_count());
+ EXPECT_EQ(0, delegate.capture_changed_event_count());
EventGenerator generator(gfx::Point(50, 50));
generator.PressLeftButton();
+ EXPECT_EQ(0, delegate.capture_lost_count());
+ EXPECT_EQ(0, delegate.capture_changed_event_count());
EXPECT_EQ(1, delegate.mouse_event_count());
- delegate.set_mouse_event_count(0);
- // Reset the capture.
- window->ReleaseCapture();
+ // Set capture to |w2|, should implicitly unset capture for |window|.
+ delegate.ResetCounts();
+ delegate2.ResetCounts();
w2->SetCapture();
- delegate2.set_mouse_event_count(0);
+
generator.MoveMouseTo(gfx::Point(40, 40), 2);
- EXPECT_EQ(0, delegate.mouse_event_count());
+ EXPECT_EQ(1, delegate.capture_lost_count());
+ EXPECT_EQ(1, delegate.capture_changed_event_count());
+ EXPECT_EQ(1, delegate.mouse_event_count());
EXPECT_EQ(2, delegate2.mouse_event_count());
}