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

Side by Side Diff: ash/wm/window_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: for comment #13 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/exo/pointer.h » ('j') | ui/aura/client/cursor_client_observer.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/common/shell_window_ids.h" 5 #include "ash/common/shell_window_ids.h"
6 #include "ash/shell.h" 6 #include "ash/shell.h"
7 #include "ash/test/ash_test_base.h" 7 #include "ash/test/ash_test_base.h"
8 #include "ash/test/test_activation_delegate.h" 8 #include "ash/test/test_activation_delegate.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "ui/aura/client/cursor_client_observer.h" 10 #include "ui/aura/client/cursor_client_observer.h"
(...skipping 13 matching lines...) Expand all
24 #include "ui/wm/core/compound_event_filter.h" 24 #include "ui/wm/core/compound_event_filter.h"
25 #include "ui/wm/public/activation_client.h" 25 #include "ui/wm/public/activation_client.h"
26 #include "ui/wm/public/activation_delegate.h" 26 #include "ui/wm/public/activation_delegate.h"
27 27
28 namespace { 28 namespace {
29 29
30 class TestingCursorClientObserver : public aura::client::CursorClientObserver { 30 class TestingCursorClientObserver : public aura::client::CursorClientObserver {
31 public: 31 public:
32 TestingCursorClientObserver() 32 TestingCursorClientObserver()
33 : cursor_visibility_(false), 33 : cursor_visibility_(false),
34 did_visibility_change_(false) {} 34 did_visibility_change_(false),
35 void reset() { cursor_visibility_ = did_visibility_change_ = false; } 35 cursor_set_(ui::CURSOR_SET_NORMAL),
36 did_cursor_set_change_(false) {}
37 void reset() {
38 cursor_visibility_ = did_visibility_change_ = false;
sky 2016/06/20 15:27:51 Shouldn't you reset cursor_set_ too?
yoshiki 2016/06/28 02:12:42 Done.
39 did_cursor_set_change_ = false;
40 }
36 bool is_cursor_visible() const { return cursor_visibility_; } 41 bool is_cursor_visible() const { return cursor_visibility_; }
42 ui::CursorSetType cursor_set() const { return cursor_set_; }
37 bool did_visibility_change() const { return did_visibility_change_; } 43 bool did_visibility_change() const { return did_visibility_change_; }
44 bool did_cursor_set_change() const { return did_cursor_set_change_; }
38 45
39 // Overridden from aura::client::CursorClientObserver: 46 // Overridden from aura::client::CursorClientObserver:
40 void OnCursorVisibilityChanged(bool is_visible) override { 47 void OnCursorVisibilityChanged(bool is_visible) override {
41 cursor_visibility_ = is_visible; 48 cursor_visibility_ = is_visible;
42 did_visibility_change_ = true; 49 did_visibility_change_ = true;
43 } 50 }
51 void OnCursorSetChanged(ui::CursorSetType new_cursor_set) override {
52 cursor_set_ = new_cursor_set;
53 did_cursor_set_change_ = true;
54 }
44 55
45 private: 56 private:
46 bool cursor_visibility_; 57 bool cursor_visibility_;
47 bool did_visibility_change_; 58 bool did_visibility_change_;
59 ui::CursorSetType cursor_set_;
60 bool did_cursor_set_change_;
48 61
49 DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver); 62 DISALLOW_COPY_AND_ASSIGN(TestingCursorClientObserver);
50 }; 63 };
51 64
52 base::TimeTicks getTime() { 65 base::TimeTicks getTime() {
53 return ui::EventTimeForNow(); 66 return ui::EventTimeForNow();
54 } 67 }
55 68
56 // A slightly changed TestEventHandler which can be configured to return a 69 // A slightly changed TestEventHandler which can be configured to return a
57 // specified value for key/mouse event handling. 70 // specified value for key/mouse event handling.
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 cursor_manager->AddObserver(&observer_a); 821 cursor_manager->AddObserver(&observer_a);
809 cursor_manager->AddObserver(&observer_b); 822 cursor_manager->AddObserver(&observer_b);
810 823
811 // Initial state before any events have been sent. 824 // Initial state before any events have been sent.
812 observer_a.reset(); 825 observer_a.reset();
813 observer_b.reset(); 826 observer_b.reset();
814 EXPECT_FALSE(observer_a.did_visibility_change()); 827 EXPECT_FALSE(observer_a.did_visibility_change());
815 EXPECT_FALSE(observer_b.did_visibility_change()); 828 EXPECT_FALSE(observer_b.did_visibility_change());
816 EXPECT_FALSE(observer_a.is_cursor_visible()); 829 EXPECT_FALSE(observer_a.is_cursor_visible());
817 EXPECT_FALSE(observer_b.is_cursor_visible()); 830 EXPECT_FALSE(observer_b.is_cursor_visible());
831 EXPECT_FALSE(observer_a.did_cursor_set_change());
832 EXPECT_FALSE(observer_b.did_cursor_set_change());
833 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer_a.cursor_set());
834 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer_b.cursor_set());
818 835
819 // Keypress should hide the cursor. 836 // Keypress should hide the cursor.
820 generator.PressKey(ui::VKEY_A, ui::EF_NONE); 837 generator.PressKey(ui::VKEY_A, ui::EF_NONE);
821 EXPECT_TRUE(observer_a.did_visibility_change()); 838 EXPECT_TRUE(observer_a.did_visibility_change());
822 EXPECT_TRUE(observer_b.did_visibility_change()); 839 EXPECT_TRUE(observer_b.did_visibility_change());
823 EXPECT_FALSE(observer_a.is_cursor_visible()); 840 EXPECT_FALSE(observer_a.is_cursor_visible());
824 EXPECT_FALSE(observer_b.is_cursor_visible()); 841 EXPECT_FALSE(observer_b.is_cursor_visible());
825 842
843 // Set cursor set.
844 cursor_manager->SetCursorSet(ui::CURSOR_SET_LARGE);
845 EXPECT_TRUE(observer_a.did_cursor_set_change());
846 EXPECT_TRUE(observer_b.did_cursor_set_change());
847 EXPECT_EQ(ui::CURSOR_SET_LARGE, observer_a.cursor_set());
848 EXPECT_EQ(ui::CURSOR_SET_LARGE, observer_b.cursor_set());
849
826 // Mouse move should show the cursor. 850 // Mouse move should show the cursor.
827 observer_a.reset(); 851 observer_a.reset();
828 observer_b.reset(); 852 observer_b.reset();
829 generator.MoveMouseTo(50, 50); 853 generator.MoveMouseTo(50, 50);
830 EXPECT_TRUE(observer_a.did_visibility_change()); 854 EXPECT_TRUE(observer_a.did_visibility_change());
831 EXPECT_TRUE(observer_b.did_visibility_change()); 855 EXPECT_TRUE(observer_b.did_visibility_change());
832 EXPECT_TRUE(observer_a.is_cursor_visible()); 856 EXPECT_TRUE(observer_a.is_cursor_visible());
833 EXPECT_TRUE(observer_b.is_cursor_visible()); 857 EXPECT_TRUE(observer_b.is_cursor_visible());
834 858
835 // Remove observer_b. Its OnCursorVisibilityChanged() should 859 // Remove observer_b. Its OnCursorVisibilityChanged() should
836 // not be invoked past this point. 860 // not be invoked past this point.
837 cursor_manager->RemoveObserver(&observer_b); 861 cursor_manager->RemoveObserver(&observer_b);
838 862
839 // Gesture tap should hide the cursor. 863 // Gesture tap should hide the cursor.
840 observer_a.reset(); 864 observer_a.reset();
841 observer_b.reset(); 865 observer_b.reset();
842 generator.GestureTapAt(gfx::Point(25, 25)); 866 generator.GestureTapAt(gfx::Point(25, 25));
843 EXPECT_TRUE(observer_a.did_visibility_change()); 867 EXPECT_TRUE(observer_a.did_visibility_change());
844 EXPECT_FALSE(observer_b.did_visibility_change()); 868 EXPECT_FALSE(observer_b.did_visibility_change());
845 EXPECT_FALSE(observer_a.is_cursor_visible()); 869 EXPECT_FALSE(observer_a.is_cursor_visible());
846 870
871 // Set back cursor set to normal.
872 cursor_manager->SetCursorSet(ui::CURSOR_SET_NORMAL);
873 EXPECT_TRUE(observer_a.did_cursor_set_change());
874 EXPECT_FALSE(observer_b.did_cursor_set_change());
875 EXPECT_EQ(ui::CURSOR_SET_NORMAL, observer_a.cursor_set());
876 EXPECT_EQ(ui::CURSOR_SET_LARGE, observer_b.cursor_set());
877
847 // Mouse move should show the cursor. 878 // Mouse move should show the cursor.
848 observer_a.reset(); 879 observer_a.reset();
849 observer_b.reset(); 880 observer_b.reset();
850 generator.MoveMouseTo(50, 50); 881 generator.MoveMouseTo(50, 50);
851 EXPECT_TRUE(observer_a.did_visibility_change()); 882 EXPECT_TRUE(observer_a.did_visibility_change());
852 EXPECT_FALSE(observer_b.did_visibility_change()); 883 EXPECT_FALSE(observer_b.did_visibility_change());
853 EXPECT_TRUE(observer_a.is_cursor_visible()); 884 EXPECT_TRUE(observer_a.is_cursor_visible());
854 885
855 cursor_manager->RemoveObserver(&observer_a); 886 cursor_manager->RemoveObserver(&observer_a);
856 } 887 }
857 #endif // defined(OS_CHROMEOS) 888 #endif // defined(OS_CHROMEOS)
858 889
859 } // namespace ash 890 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | components/exo/pointer.h » ('j') | ui/aura/client/cursor_client_observer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698