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

Unified Diff: ash/aura/pointer_watcher_adapter_unittest.cc

Issue 2256343003: Update ui::PointerEvent to support mouse wheel and capture change events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
« no previous file with comments | « ash/aura/pointer_watcher_adapter.cc ('k') | ash/shared/immersive_fullscreen_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8f95473edfeec783507e27ffe978ca8f1458f7c6 100644
--- a/ash/aura/pointer_watcher_adapter_unittest.cc
+++ b/ash/aura/pointer_watcher_adapter_unittest.cc
@@ -14,8 +14,9 @@ namespace ash {
using PointerWatcherAdapterTest = test::AshTestBase;
-// Records calls to OnPointerEventObserved() in |pointer_event_count_| and
-// calls to OnMouseCaptureChanged() to |capture_changed_count_|.
+// Records calls to OnPointerEventObserved() in |mouse_wheel_event_count| for a
+// mouse wheel event, in |capture_changed_count_| for a mouse capture change
+// event and in |pointer_event_count_| for all other pointer events.
class TestPointerWatcher : public views::PointerWatcher {
public:
explicit TestPointerWatcher(bool wants_moves) {
@@ -23,22 +24,31 @@ class TestPointerWatcher : public views::PointerWatcher {
}
~TestPointerWatcher() override { WmShell::Get()->RemovePointerWatcher(this); }
- void ClearCounts() { pointer_event_count_ = capture_changed_count_ = 0; }
+ void ClearCounts() {
+ pointer_event_count_ = capture_changed_count_ = mouse_wheel_event_count_ =
+ 0;
+ }
int pointer_event_count() const { return pointer_event_count_; }
int capture_changed_count() const { return capture_changed_count_; }
+ int mouse_wheel_event_count() const { return mouse_wheel_event_count_; }
// views::PointerWatcher:
void OnPointerEventObserved(const ui::PointerEvent& event,
const gfx::Point& location_in_screen,
views::Widget* target) override {
- pointer_event_count_++;
+ if (event.type() == ui::ET_POINTER_WHEEL_CHANGED)
+ mouse_wheel_event_count_++;
+ else if (event.type() == ui::ET_POINTER_CAPTURE_CHANGED)
+ capture_changed_count_++;
+ else
+ pointer_event_count_++;
}
- void OnMouseCaptureChanged() override { capture_changed_count_++; }
private:
int pointer_event_count_ = 0;
int capture_changed_count_ = 0;
+ int mouse_wheel_event_count_ = 0;
DISALLOW_COPY_AND_ASSIGN(TestPointerWatcher);
};
@@ -52,15 +62,21 @@ class TestHelper {
// Used to verify call counts.
void ExpectCallCount(int non_move_pointer_event_count,
int non_move_capture_changed_count,
+ int non_move_mouse_wheel_event_count,
int move_pointer_event_count,
- int move_capture_changed_count) {
+ int move_capture_changed_count,
+ int move_mouse_wheel_event_count) {
EXPECT_EQ(non_move_pointer_event_count,
non_move_watcher_.pointer_event_count());
EXPECT_EQ(non_move_capture_changed_count,
non_move_watcher_.capture_changed_count());
+ EXPECT_EQ(non_move_mouse_wheel_event_count,
+ non_move_watcher_.mouse_wheel_event_count());
EXPECT_EQ(move_pointer_event_count, move_watcher_.pointer_event_count());
EXPECT_EQ(move_capture_changed_count,
move_watcher_.capture_changed_count());
+ EXPECT_EQ(move_mouse_wheel_event_count,
+ move_watcher_.mouse_wheel_event_count());
non_move_watcher_.ClearCounts();
move_watcher_.ClearCounts();
@@ -78,39 +94,39 @@ TEST_F(PointerWatcherAdapterTest, MouseEvents) {
// Move: only the move PointerWatcher should get the event.
GetEventGenerator().MoveMouseTo(gfx::Point(10, 10));
- helper.ExpectCallCount(0, 0, 1, 0);
+ helper.ExpectCallCount(0, 0, 0, 1, 0, 0);
// Press: both.
GetEventGenerator().PressLeftButton();
- helper.ExpectCallCount(1, 0, 1, 0);
+ helper.ExpectCallCount(1, 0, 0, 1, 0, 0);
// Drag: none.
GetEventGenerator().MoveMouseTo(gfx::Point(20, 30));
- helper.ExpectCallCount(0, 0, 0, 0);
+ helper.ExpectCallCount(0, 0, 0, 0, 0, 0);
// Release: both (aura generates a capture event here).
GetEventGenerator().ReleaseLeftButton();
- helper.ExpectCallCount(1, 1, 1, 1);
+ helper.ExpectCallCount(1, 1, 0, 1, 1, 0);
// 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
+ // Wheel: both
GetEventGenerator().MoveMouseWheel(10, 11);
- helper.ExpectCallCount(0, 0, 0, 0);
+ helper.ExpectCallCount(0, 0, 1, 0, 0, 1);
// Capture: both.
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, 0, 1, 0);
}
TEST_F(PointerWatcherAdapterTest, TouchEvents) {
@@ -119,16 +135,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, 0, 1, 0, 0);
// Drag: none.
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, 0, 1, 0, 0);
}
} // namespace ash
« no previous file with comments | « ash/aura/pointer_watcher_adapter.cc ('k') | ash/shared/immersive_fullscreen_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698