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

Side by Side Diff: ui/aura/root_window_unittest.cc

Issue 11412315: Make the cursor have separate mode for disabled mouse events and invisible. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 8 years 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 | Annotate | Revision Log
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 "ui/aura/root_window.h" 5 #include "ui/aura/root_window.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/aura/client/event_client.h" 10 #include "ui/aura/client/event_client.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location()); 137 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location());
138 // Mouse event was received by target window. 138 // Mouse event was received by target window.
139 EXPECT_EQ(1, delegate1->mouse_event_count()); 139 EXPECT_EQ(1, delegate1->mouse_event_count());
140 EXPECT_EQ(0, delegate2->mouse_event_count()); 140 EXPECT_EQ(0, delegate2->mouse_event_count());
141 // Event was in local coordinates. 141 // Event was in local coordinates.
142 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location()); 142 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location());
143 // Non-client flag was set. 143 // Non-client flag was set.
144 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT); 144 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT);
145 } 145 }
146 146
147 #if defined(OS_WIN)
148 // Temporarily disabled for windows. See crbug.com/112222.
149 TEST_F(RootWindowTest, DISABLED_HideCursor) {
150 #else
151 TEST_F(RootWindowTest, HideCursor) {
152 #endif // defined(OS_WIN)
153 scoped_ptr<NonClientDelegate> delegate(new NonClientDelegate());
154 const int kWindowWidth = 123;
155 const int kWindowHeight = 45;
156 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
157 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
158 delegate.get(), -1234, bounds, root_window()));
159 aura::Window* window_ptr = &*window;
160
161 root_window()->OnCursorVisibilityChanged(true);
162 // Send a mouse event to window.
163 gfx::Point point(101, 201);
164 gfx::Point local_point;
165 ui::MouseEvent event(ui::ET_MOUSE_MOVED, point, point, 0);
166 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&event);
167
168 // Location was in window.
169 local_point = delegate->mouse_event_location();
170 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point);
171 EXPECT_TRUE(window->bounds().Contains(local_point));
172
173 // Location is now out of window.
174 root_window()->OnCursorVisibilityChanged(false);
175 RunAllPendingInMessageLoop();
176 local_point = delegate->mouse_event_location();
177 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point);
178 EXPECT_FALSE(window->bounds().Contains(local_point));
179
180 // Location is back in window.
181 root_window()->OnCursorVisibilityChanged(true);
182 RunAllPendingInMessageLoop();
183 local_point = delegate->mouse_event_location();
184 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point);
185 EXPECT_TRUE(window->bounds().Contains(local_point));
186 }
187
188 // Check that we correctly track the state of the mouse buttons in response to 147 // Check that we correctly track the state of the mouse buttons in response to
189 // button press and release events. 148 // button press and release events.
190 TEST_F(RootWindowTest, MouseButtonState) { 149 TEST_F(RootWindowTest, MouseButtonState) {
191 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); 150 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down());
192 151
193 gfx::Point location; 152 gfx::Point location;
194 scoped_ptr<ui::MouseEvent> event; 153 scoped_ptr<ui::MouseEvent> event;
195 154
196 // Press the left button. 155 // Press the left button.
197 event.reset(new ui::MouseEvent( 156 event.reset(new ui::MouseEvent(
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 TEST_F(RootWindowTest, GestureRecognizerResetsTargetWhenParentHides) { 727 TEST_F(RootWindowTest, GestureRecognizerResetsTargetWhenParentHides) {
769 scoped_ptr<Window> w1(CreateWindow(1, root_window(), NULL)); 728 scoped_ptr<Window> w1(CreateWindow(1, root_window(), NULL));
770 DetachesParentOnTapDelegate delegate; 729 DetachesParentOnTapDelegate delegate;
771 scoped_ptr<Window> parent(CreateWindow(22, w1.get(), NULL)); 730 scoped_ptr<Window> parent(CreateWindow(22, w1.get(), NULL));
772 Window* child = CreateWindow(11, parent.get(), &delegate); 731 Window* child = CreateWindow(11, parent.get(), &delegate);
773 test::EventGenerator generator(root_window(), child); 732 test::EventGenerator generator(root_window(), child);
774 generator.GestureTapAt(gfx::Point(40, 40)); 733 generator.GestureTapAt(gfx::Point(40, 40));
775 } 734 }
776 735
777 } // namespace aura 736 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698