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

Unified Diff: ash/aura/pointer_watcher_adapter_unittest.cc

Issue 2271393002: Wires up drags to pointer watcher adapter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 4 years, 4 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
Index: ash/aura/pointer_watcher_adapter_unittest.cc
diff --git a/ash/aura/pointer_watcher_adapter_unittest.cc b/ash/aura/pointer_watcher_adapter_unittest.cc
index c0a67685e9c08867d78d3c4f964dde6716aab63e..bb6f8295b8c41651ae15e6fadb1486461a02611f 100644
--- a/ash/aura/pointer_watcher_adapter_unittest.cc
+++ b/ash/aura/pointer_watcher_adapter_unittest.cc
@@ -18,8 +18,8 @@ using PointerWatcherAdapterTest = test::AshTestBase;
// calls to OnMouseCaptureChanged() to |capture_changed_count_|.
class TestPointerWatcher : public views::PointerWatcher {
public:
- explicit TestPointerWatcher(bool wants_moves) {
- WmShell::Get()->AddPointerWatcher(this, wants_moves);
+ explicit TestPointerWatcher(bool wants_moves, bool wants_drags) {
+ WmShell::Get()->AddPointerWatcher(this, wants_moves, wants_drags);
}
~TestPointerWatcher() override { WmShell::Get()->RemovePointerWatcher(this); }
@@ -43,17 +43,23 @@ class TestPointerWatcher : public views::PointerWatcher {
DISALLOW_COPY_AND_ASSIGN(TestPointerWatcher);
};
-// Creates two TestPointerWatchers, one that wants moves and one that doesn't.
+// Creates three TestPointerWatchers, one that wants moves and one that wants
+// drags, and one that does not want either.
class TestHelper {
public:
- TestHelper() : non_move_watcher_(false), move_watcher_(true) {}
+ TestHelper()
+ : non_move_watcher_(false, false),
+ move_watcher_(true, false),
+ drag_watcher_(true, true) {}
~TestHelper() {}
// Used to verify call counts.
void ExpectCallCount(int non_move_pointer_event_count,
int non_move_capture_changed_count,
int move_pointer_event_count,
- int move_capture_changed_count) {
+ int move_capture_changed_count,
+ int drag_pointer_event_count,
+ int drag_capture_changed_count) {
EXPECT_EQ(non_move_pointer_event_count,
non_move_watcher_.pointer_event_count());
EXPECT_EQ(non_move_capture_changed_count,
@@ -61,14 +67,19 @@ class TestHelper {
EXPECT_EQ(move_pointer_event_count, move_watcher_.pointer_event_count());
EXPECT_EQ(move_capture_changed_count,
move_watcher_.capture_changed_count());
+ EXPECT_EQ(drag_pointer_event_count, drag_watcher_.pointer_event_count());
+ EXPECT_EQ(drag_capture_changed_count,
+ drag_watcher_.capture_changed_count());
non_move_watcher_.ClearCounts();
move_watcher_.ClearCounts();
+ drag_watcher_.ClearCounts();
}
private:
TestPointerWatcher non_move_watcher_;
TestPointerWatcher move_watcher_;
+ TestPointerWatcher drag_watcher_;
DISALLOW_COPY_AND_ASSIGN(TestHelper);
};
@@ -76,41 +87,41 @@ class TestHelper {
TEST_F(PointerWatcherAdapterTest, MouseEvents) {
TestHelper helper;
- // Move: only the move PointerWatcher should get the event.
+ // Move: only the move and drag PointerWatcher should get the event.
GetEventGenerator().MoveMouseTo(gfx::Point(10, 10));
- helper.ExpectCallCount(0, 0, 1, 0);
+ helper.ExpectCallCount(0, 0, 1, 0, 1, 0);
- // Press: both.
+ // Press: all.
GetEventGenerator().PressLeftButton();
- helper.ExpectCallCount(1, 0, 1, 0);
+ helper.ExpectCallCount(1, 0, 1, 0, 1, 0);
- // Drag: none.
+ // Drag: only drag PointerWatcher should get the event.
GetEventGenerator().MoveMouseTo(gfx::Point(20, 30));
- helper.ExpectCallCount(0, 0, 0, 0);
+ helper.ExpectCallCount(0, 0, 0, 0, 1, 0);
- // Release: both (aura generates a capture event here).
+ // Release: all (aura generates a capture event here).
GetEventGenerator().ReleaseLeftButton();
- helper.ExpectCallCount(1, 1, 1, 1);
+ helper.ExpectCallCount(1, 1, 1, 1, 1, 1);
// Exit: none.
GetEventGenerator().SendMouseExit();
- helper.ExpectCallCount(0, 0, 0, 0);
+ helper.ExpectCallCount(0, 0, 0, 0, 0, 0);
// Enter: none.
ui::MouseEvent enter_event(ui::ET_MOUSE_ENTERED, gfx::Point(), gfx::Point(),
ui::EventTimeForNow(), 0, 0);
GetEventGenerator().Dispatch(&enter_event);
- helper.ExpectCallCount(0, 0, 0, 0);
+ helper.ExpectCallCount(0, 0, 0, 0, 0, 0);
// Wheel: none
GetEventGenerator().MoveMouseWheel(10, 11);
- helper.ExpectCallCount(0, 0, 0, 0);
+ helper.ExpectCallCount(0, 0, 0, 0, 0, 0);
- // Capture: both.
+ // Capture: all.
ui::MouseEvent capture_event(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(),
gfx::Point(), ui::EventTimeForNow(), 0, 0);
GetEventGenerator().Dispatch(&capture_event);
- helper.ExpectCallCount(0, 1, 0, 1);
+ helper.ExpectCallCount(0, 1, 0, 1, 0, 1);
}
TEST_F(PointerWatcherAdapterTest, TouchEvents) {
@@ -119,16 +130,16 @@ TEST_F(PointerWatcherAdapterTest, TouchEvents) {
// Press: both.
const int touch_id = 11;
GetEventGenerator().PressTouchId(touch_id);
- helper.ExpectCallCount(1, 0, 1, 0);
+ helper.ExpectCallCount(1, 0, 1, 0, 1, 0);
- // Drag: none.
+ // Drag: none, no drags for touch.
sky 2016/08/24 23:32:30 Drag should include pointer move.
sammiequon 2016/08/25 23:11:18 Done.
GetEventGenerator().MoveTouchId(gfx::Point(20, 30), touch_id);
- helper.ExpectCallCount(0, 0, 0, 0);
+ helper.ExpectCallCount(0, 0, 0, 0, 0, 0);
// Release: both (contrary to mouse above, touch does not implicitly generate
// capture).
GetEventGenerator().ReleaseTouchId(touch_id);
- helper.ExpectCallCount(1, 0, 1, 0);
+ helper.ExpectCallCount(1, 0, 1, 0, 1, 0);
}
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698