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

Unified Diff: ui/views/mus/pointer_watcher_event_router_unittest.cc

Issue 2248263003: Updates PointerEventRouter to handle switching move type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge again 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 | « ui/views/mus/pointer_watcher_event_router.cc ('k') | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/mus/pointer_watcher_event_router_unittest.cc
diff --git a/ui/views/mus/pointer_watcher_event_router_unittest.cc b/ui/views/mus/pointer_watcher_event_router_unittest.cc
index ee3df4eb3138ab1686bcd54028d8a7c6b8d3695d..4dd31442bf6ae488210f901803fd2df26d55f27a 100644
--- a/ui/views/mus/pointer_watcher_event_router_unittest.cc
+++ b/ui/views/mus/pointer_watcher_event_router_unittest.cc
@@ -7,6 +7,7 @@
#include <memory>
#include "base/message_loop/message_loop.h"
+#include "services/ui/public/cpp/tests/window_tree_client_private.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/event.h"
#include "ui/views/mus/window_manager_connection.h"
@@ -51,10 +52,69 @@ class PointerWatcherEventRouterTest : public testing::Test {
->OnPointerEventObserved(event, nullptr);
}
+ PointerWatcherEventRouter::EventTypes event_types() const {
+ return WindowManagerConnection::Get()
+ ->pointer_watcher_event_router()
+ ->event_types_;
+ }
+
private:
DISALLOW_COPY_AND_ASSIGN(PointerWatcherEventRouterTest);
};
+TEST_F(PointerWatcherEventRouterTest, EventTypes) {
+ base::MessageLoop message_loop(base::MessageLoop::TYPE_UI);
+ ScopedViewsTestHelper helper;
+ TestPointerWatcher pointer_watcher1, pointer_watcher2;
+ PointerWatcherEventRouter* pointer_watcher_event_router =
+ WindowManagerConnection::Get()->pointer_watcher_event_router();
+ ui::WindowTreeClientPrivate test_api(
+ WindowManagerConnection::Get()->client());
+ EXPECT_FALSE(test_api.HasPointerWatcher());
+
+ // Start with no moves.
+ pointer_watcher_event_router->AddPointerWatcher(&pointer_watcher1, false);
+ EXPECT_EQ(PointerWatcherEventRouter::EventTypes::NON_MOVE_EVENTS,
+ event_types());
+ EXPECT_TRUE(test_api.HasPointerWatcher());
+
+ // Add moves.
+ pointer_watcher_event_router->AddPointerWatcher(&pointer_watcher2, true);
+ EXPECT_EQ(PointerWatcherEventRouter::EventTypes::MOVE_EVENTS, event_types());
+ EXPECT_TRUE(test_api.HasPointerWatcher());
+
+ // Remove no-moves.
+ pointer_watcher_event_router->RemovePointerWatcher(&pointer_watcher1);
+ EXPECT_EQ(PointerWatcherEventRouter::EventTypes::MOVE_EVENTS, event_types());
+ EXPECT_TRUE(test_api.HasPointerWatcher());
+
+ // Remove moves.
+ pointer_watcher_event_router->RemovePointerWatcher(&pointer_watcher2);
+ EXPECT_EQ(PointerWatcherEventRouter::EventTypes::NONE, event_types());
+ EXPECT_FALSE(test_api.HasPointerWatcher());
+
+ // Add moves.
+ pointer_watcher_event_router->AddPointerWatcher(&pointer_watcher2, true);
+ EXPECT_EQ(PointerWatcherEventRouter::EventTypes::MOVE_EVENTS, event_types());
+ EXPECT_TRUE(test_api.HasPointerWatcher());
+
+ // Add no moves.
+ pointer_watcher_event_router->AddPointerWatcher(&pointer_watcher1, false);
+ EXPECT_EQ(PointerWatcherEventRouter::EventTypes::MOVE_EVENTS, event_types());
+ EXPECT_TRUE(test_api.HasPointerWatcher());
+
+ // Remove moves.
+ pointer_watcher_event_router->RemovePointerWatcher(&pointer_watcher2);
+ EXPECT_EQ(PointerWatcherEventRouter::EventTypes::NON_MOVE_EVENTS,
+ event_types());
+ EXPECT_TRUE(test_api.HasPointerWatcher());
+
+ // Remove no-moves.
+ pointer_watcher_event_router->RemovePointerWatcher(&pointer_watcher1);
+ EXPECT_EQ(PointerWatcherEventRouter::EventTypes::NONE, event_types());
+ EXPECT_FALSE(test_api.HasPointerWatcher());
+}
+
TEST_F(PointerWatcherEventRouterTest, PointerWatcherNoMove) {
base::MessageLoop message_loop(base::MessageLoop::TYPE_UI);
ScopedViewsTestHelper helper;
« no previous file with comments | « ui/views/mus/pointer_watcher_event_router.cc ('k') | ui/views/mus/window_manager_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698