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

Unified Diff: ui/wm/core/cursor_manager_unittest.cc

Issue 2071553002: Initial support of large mouse cursor on Exosphere (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 6 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
Index: ui/wm/core/cursor_manager_unittest.cc
diff --git a/ui/wm/core/cursor_manager_unittest.cc b/ui/wm/core/cursor_manager_unittest.cc
index c55ebe0a1c879fe03ea59a79f73b743f1ae81e49..df18de8350d8a25743224cb71a3354a73f70fe50 100644
--- a/ui/wm/core/cursor_manager_unittest.cc
+++ b/ui/wm/core/cursor_manager_unittest.cc
@@ -9,6 +9,7 @@
#include "ui/aura/client/cursor_client_observer.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/wm/core/native_cursor_manager.h"
+#include "ui/wm/test/testing_cursor_client_observer.h"
namespace {
@@ -52,28 +53,6 @@ class CursorManagerTest : public aura::test::AuraTestBase {
wm::CursorManager cursor_manager_;
};
-class TestingCursorClientObserver : public aura::client::CursorClientObserver {
- public:
- TestingCursorClientObserver()
- : cursor_visibility_(false),
- did_visibility_change_(false) {}
- void reset() { cursor_visibility_ = did_visibility_change_ = false; }
- bool is_cursor_visible() const { return cursor_visibility_; }
- bool did_visibility_change() const { return did_visibility_change_; }
-
- // Overridden from aura::client::CursorClientObserver:
- void OnCursorVisibilityChanged(bool is_visible) override {
- cursor_visibility_ = is_visible;
- did_visibility_change_ = true;
- }
-
- private:
- bool cursor_visibility_;
- bool did_visibility_change_;
-
- DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver);
-};
-
TEST_F(CursorManagerTest, ShowHideCursor) {
cursor_manager_.SetCursor(ui::kCursorCopy);
EXPECT_EQ(ui::kCursorCopy, cursor_manager_.GetCursor().native_type());
@@ -175,16 +154,23 @@ TEST_F(CursorManagerTest, EnableDisableMouseEvents) {
}
TEST_F(CursorManagerTest, SetCursorSet) {
+ wm::TestingCursorClientObserver observer;
+ cursor_manager_.AddObserver(&observer);
+
EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet());
+ EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer.cursor_set());
cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL);
EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet());
+ EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer.cursor_set());
cursor_manager_.SetCursorSet(ui::CURSOR_SET_LARGE);
EXPECT_EQ(ui::CURSOR_SET_LARGE, cursor_manager_.GetCursorSet());
+ EXPECT_EQ(ui::CURSOR_SET_LARGE, observer.cursor_set());
cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL);
EXPECT_EQ(ui::CURSOR_SET_NORMAL, cursor_manager_.GetCursorSet());
+ EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer.cursor_set());
}
TEST_F(CursorManagerTest, IsMouseEventsEnabled) {
@@ -275,8 +261,8 @@ TEST_F(CursorManagerTest, MultipleEnableMouseEvents) {
TEST_F(CursorManagerTest, TestCursorClientObserver) {
// Add two observers. Both should have OnCursorVisibilityChanged()
// invoked when the visibility of the cursor changes.
- TestingCursorClientObserver observer_a;
- TestingCursorClientObserver observer_b;
+ wm::TestingCursorClientObserver observer_a;
+ wm::TestingCursorClientObserver observer_b;
cursor_manager_.AddObserver(&observer_a);
cursor_manager_.AddObserver(&observer_b);
@@ -287,6 +273,8 @@ TEST_F(CursorManagerTest, TestCursorClientObserver) {
EXPECT_FALSE(observer_b.did_visibility_change());
EXPECT_FALSE(observer_a.is_cursor_visible());
EXPECT_FALSE(observer_b.is_cursor_visible());
+ EXPECT_FALSE(observer_a.did_cursor_set_change());
+ EXPECT_FALSE(observer_b.did_cursor_set_change());
// Hide the cursor using HideCursor().
cursor_manager_.HideCursor();
@@ -295,6 +283,13 @@ TEST_F(CursorManagerTest, TestCursorClientObserver) {
EXPECT_FALSE(observer_a.is_cursor_visible());
EXPECT_FALSE(observer_b.is_cursor_visible());
+ // Set the cursor set.
+ cursor_manager_.SetCursorSet(ui::CURSOR_SET_LARGE);
+ EXPECT_TRUE(observer_a.did_cursor_set_change());
+ EXPECT_EQ(ui::CURSOR_SET_LARGE, observer_a.cursor_set());
+ EXPECT_TRUE(observer_b.did_cursor_set_change());
+ EXPECT_EQ(ui::CURSOR_SET_LARGE, observer_b.cursor_set());
+
// Show the cursor using ShowCursor().
observer_a.reset();
observer_b.reset();
@@ -316,6 +311,12 @@ TEST_F(CursorManagerTest, TestCursorClientObserver) {
EXPECT_FALSE(observer_b.did_visibility_change());
EXPECT_FALSE(observer_a.is_cursor_visible());
+ // Set back the cursor set to normal.
+ cursor_manager_.SetCursorSet(ui::CURSOR_SET_NORMAL);
+ EXPECT_TRUE(observer_a.did_cursor_set_change());
+ EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer_a.cursor_set());
+ EXPECT_FALSE(observer_b.did_cursor_set_change());
+
// Show the cursor using ShowCursor().
observer_a.reset();
observer_b.reset();

Powered by Google App Engine
This is Rietveld 408576698