| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/mus/window_manager_connection.h" | 5 #include "ui/views/mus/window_manager_connection.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
| 12 #include "ui/views/pointer_watcher.h" | 12 #include "ui/views/pointer_watcher.h" |
| 13 #include "ui/views/test/scoped_views_test_helper.h" | 13 #include "ui/views/test/scoped_views_test_helper.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 class TestPointerWatcher : public PointerWatcher { | 18 class TestPointerWatcher : public PointerWatcher { |
| 19 public: | 19 public: |
| 20 TestPointerWatcher() {} | 20 TestPointerWatcher() {} |
| 21 ~TestPointerWatcher() override {} | 21 ~TestPointerWatcher() override {} |
| 22 | 22 |
| 23 ui::Event* last_event() { return last_event_.get(); } | 23 ui::Event* last_event() { return last_event_.get(); } |
| 24 | 24 |
| 25 void Reset() { last_event_.reset(); } | 25 void Reset() { last_event_.reset(); } |
| 26 | 26 |
| 27 // PointerWatcher: | 27 // PointerWatcher: |
| 28 void OnMousePressed(const ui::MouseEvent& event) override { | 28 void OnMousePressed(const ui::MouseEvent& event, |
| 29 const gfx::Point& location_in_screen) override { |
| 29 last_event_ = ui::Event::Clone(event); | 30 last_event_ = ui::Event::Clone(event); |
| 30 } | 31 } |
| 31 void OnTouchPressed(const ui::TouchEvent& event) override { | 32 void OnTouchPressed(const ui::TouchEvent& event, |
| 33 const gfx::Point& location_in_screen) override { |
| 32 last_event_ = ui::Event::Clone(event); | 34 last_event_ = ui::Event::Clone(event); |
| 33 } | 35 } |
| 34 | 36 |
| 35 private: | 37 private: |
| 36 std::unique_ptr<ui::Event> last_event_; | 38 std::unique_ptr<ui::Event> last_event_; |
| 37 | 39 |
| 38 DISALLOW_COPY_AND_ASSIGN(TestPointerWatcher); | 40 DISALLOW_COPY_AND_ASSIGN(TestPointerWatcher); |
| 39 }; | 41 }; |
| 40 | 42 |
| 41 } // namespace | 43 } // namespace |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 watcher2.Reset(); | 101 watcher2.Reset(); |
| 100 | 102 |
| 101 // Removing the last PointerWatcher stops sending events to it. | 103 // Removing the last PointerWatcher stops sending events to it. |
| 102 connection->RemovePointerWatcher(&watcher2); | 104 connection->RemovePointerWatcher(&watcher2); |
| 103 OnEventObserved(mouse_pressed); | 105 OnEventObserved(mouse_pressed); |
| 104 EXPECT_FALSE(watcher1.last_event()); | 106 EXPECT_FALSE(watcher1.last_event()); |
| 105 EXPECT_FALSE(watcher2.last_event()); | 107 EXPECT_FALSE(watcher2.last_event()); |
| 106 } | 108 } |
| 107 | 109 |
| 108 } // namespace views | 110 } // namespace views |
| OLD | NEW |