| Index: ui/views/mus/window_manager_connection_unittest.cc
|
| diff --git a/ui/views/mus/window_manager_connection_unittest.cc b/ui/views/mus/window_manager_connection_unittest.cc
|
| index aba26448aa9698320c9a6c4597b9623114fd77d9..8d86447c5be714205ebc59c2c8dab1aa11163a75 100644
|
| --- a/ui/views/mus/window_manager_connection_unittest.cc
|
| +++ b/ui/views/mus/window_manager_connection_unittest.cc
|
| @@ -20,22 +20,29 @@ class TestPointerWatcher : public PointerWatcher {
|
| TestPointerWatcher() {}
|
| ~TestPointerWatcher() override {}
|
|
|
| - ui::Event* last_event() { return last_event_.get(); }
|
| + bool mouse_pressed() const { return mouse_pressed_; }
|
| + bool touch_pressed() const { return touch_pressed_; }
|
|
|
| - void Reset() { last_event_.reset(); }
|
| + void Reset() {
|
| + mouse_pressed_ = false;
|
| + touch_pressed_ = false;
|
| + }
|
|
|
| // PointerWatcher:
|
| void OnMousePressed(const ui::MouseEvent& event,
|
| - const gfx::Point& location_in_screen) override {
|
| - last_event_ = ui::Event::Clone(event);
|
| + const gfx::Point& location_in_screen,
|
| + Widget* target) override {
|
| + mouse_pressed_ = true;
|
| }
|
| void OnTouchPressed(const ui::TouchEvent& event,
|
| - const gfx::Point& location_in_screen) override {
|
| - last_event_ = ui::Event::Clone(event);
|
| + const gfx::Point& location_in_screen,
|
| + Widget* target) override {
|
| + touch_pressed_ = true;
|
| }
|
|
|
| private:
|
| - std::unique_ptr<ui::Event> last_event_;
|
| + bool mouse_pressed_ = false;
|
| + bool touch_pressed_ = false;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TestPointerWatcher);
|
| };
|
| @@ -48,7 +55,7 @@ class WindowManagerConnectionTest : public testing::Test {
|
| ~WindowManagerConnectionTest() override {}
|
|
|
| void OnEventObserved(const ui::Event& event) {
|
| - WindowManagerConnection::Get()->OnEventObserved(event);
|
| + WindowManagerConnection::Get()->OnEventObserved(event, nullptr);
|
| }
|
|
|
| private:
|
| @@ -70,41 +77,42 @@ TEST_F(WindowManagerConnectionTest, PointerWatcher) {
|
| TestPointerWatcher watcher1;
|
| connection->AddPointerWatcher(&watcher1);
|
| OnEventObserved(mouse_pressed);
|
| - EXPECT_EQ(ui::ET_MOUSE_PRESSED, watcher1.last_event()->type());
|
| + EXPECT_TRUE(watcher1.mouse_pressed());
|
| watcher1.Reset();
|
|
|
| // PointerWatchers receive touch events.
|
| OnEventObserved(touch_pressed);
|
| - EXPECT_EQ(ui::ET_TOUCH_PRESSED, watcher1.last_event()->type());
|
| + EXPECT_TRUE(watcher1.touch_pressed());
|
| watcher1.Reset();
|
|
|
| - // PointerWatchers do not receive key events.
|
| + // PointerWatchers do not trigger for key events.
|
| OnEventObserved(key_pressed);
|
| - EXPECT_FALSE(watcher1.last_event());
|
| + EXPECT_FALSE(watcher1.mouse_pressed());
|
| + EXPECT_FALSE(watcher1.touch_pressed());
|
| watcher1.Reset();
|
|
|
| // Two PointerWatchers can both receive a single observed event.
|
| TestPointerWatcher watcher2;
|
| connection->AddPointerWatcher(&watcher2);
|
| OnEventObserved(mouse_pressed);
|
| - EXPECT_EQ(ui::ET_MOUSE_PRESSED, watcher1.last_event()->type());
|
| - EXPECT_EQ(ui::ET_MOUSE_PRESSED, watcher2.last_event()->type());
|
| + EXPECT_TRUE(watcher1.mouse_pressed());
|
| + EXPECT_TRUE(watcher2.mouse_pressed());
|
| watcher1.Reset();
|
| watcher2.Reset();
|
|
|
| // Removing the first PointerWatcher stops sending events to it.
|
| connection->RemovePointerWatcher(&watcher1);
|
| OnEventObserved(mouse_pressed);
|
| - EXPECT_FALSE(watcher1.last_event());
|
| - EXPECT_EQ(ui::ET_MOUSE_PRESSED, watcher2.last_event()->type());
|
| + EXPECT_FALSE(watcher1.mouse_pressed());
|
| + EXPECT_TRUE(watcher2.mouse_pressed());
|
| watcher1.Reset();
|
| watcher2.Reset();
|
|
|
| // Removing the last PointerWatcher stops sending events to it.
|
| connection->RemovePointerWatcher(&watcher2);
|
| OnEventObserved(mouse_pressed);
|
| - EXPECT_FALSE(watcher1.last_event());
|
| - EXPECT_FALSE(watcher2.last_event());
|
| + EXPECT_FALSE(watcher1.mouse_pressed());
|
| + EXPECT_FALSE(watcher1.touch_pressed());
|
| }
|
|
|
| } // namespace views
|
|
|