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" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 private: | 61 private: |
62 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnectionTest); | 62 DISALLOW_COPY_AND_ASSIGN(WindowManagerConnectionTest); |
63 }; | 63 }; |
64 | 64 |
65 TEST_F(WindowManagerConnectionTest, PointerWatcher) { | 65 TEST_F(WindowManagerConnectionTest, PointerWatcher) { |
66 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); | 66 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); |
67 ScopedViewsTestHelper helper; | 67 ScopedViewsTestHelper helper; |
68 WindowManagerConnection* connection = WindowManagerConnection::Get(); | 68 WindowManagerConnection* connection = WindowManagerConnection::Get(); |
69 ASSERT_TRUE(connection); | 69 ASSERT_TRUE(connection); |
70 ui::MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 70 ui::MouseEvent mouse_pressed(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), |
71 base::TimeDelta(), ui::EF_NONE, 0); | 71 base::TimeTicks(), ui::EF_NONE, 0); |
72 ui::TouchEvent touch_pressed(ui::ET_TOUCH_PRESSED, gfx::Point(), 1, | 72 ui::TouchEvent touch_pressed(ui::ET_TOUCH_PRESSED, gfx::Point(), 1, |
73 base::TimeDelta()); | 73 base::TimeTicks()); |
74 ui::KeyEvent key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); | 74 ui::KeyEvent key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); |
75 | 75 |
76 // PointerWatchers receive mouse events. | 76 // PointerWatchers receive mouse events. |
77 TestPointerWatcher watcher1; | 77 TestPointerWatcher watcher1; |
78 connection->AddPointerWatcher(&watcher1); | 78 connection->AddPointerWatcher(&watcher1); |
79 OnEventObserved(mouse_pressed); | 79 OnEventObserved(mouse_pressed); |
80 EXPECT_TRUE(watcher1.mouse_pressed()); | 80 EXPECT_TRUE(watcher1.mouse_pressed()); |
81 watcher1.Reset(); | 81 watcher1.Reset(); |
82 | 82 |
83 // PointerWatchers receive touch events. | 83 // PointerWatchers receive touch events. |
(...skipping 25 matching lines...) Expand all Loading... |
109 watcher2.Reset(); | 109 watcher2.Reset(); |
110 | 110 |
111 // Removing the last PointerWatcher stops sending events to it. | 111 // Removing the last PointerWatcher stops sending events to it. |
112 connection->RemovePointerWatcher(&watcher2); | 112 connection->RemovePointerWatcher(&watcher2); |
113 OnEventObserved(mouse_pressed); | 113 OnEventObserved(mouse_pressed); |
114 EXPECT_FALSE(watcher1.mouse_pressed()); | 114 EXPECT_FALSE(watcher1.mouse_pressed()); |
115 EXPECT_FALSE(watcher1.touch_pressed()); | 115 EXPECT_FALSE(watcher1.touch_pressed()); |
116 } | 116 } |
117 | 117 |
118 } // namespace views | 118 } // namespace views |
OLD | NEW |