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

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

Issue 10829180: Move cursor when it's hidden so that UX can update correctly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test Created 8 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 unified diff | Download patch | Annotate | Revision Log
« ui/aura/root_window.cc ('K') | « ui/aura/root_window.cc ('k') | no next file » | no next file with comments »
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 "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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location()); 139 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location());
140 // Mouse event was received by target window. 140 // Mouse event was received by target window.
141 EXPECT_EQ(1, delegate1->mouse_event_count()); 141 EXPECT_EQ(1, delegate1->mouse_event_count());
142 EXPECT_EQ(0, delegate2->mouse_event_count()); 142 EXPECT_EQ(0, delegate2->mouse_event_count());
143 // Event was in local coordinates. 143 // Event was in local coordinates.
144 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location()); 144 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location());
145 // Non-client flag was set. 145 // Non-client flag was set.
146 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT); 146 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT);
147 } 147 }
148 148
149 TEST_F(RootWindowTest, HideCursor) {
150 scoped_ptr<NonClientDelegate> delegate(new NonClientDelegate());
151 const int kWindowWidth = 123;
152 const int kWindowHeight = 45;
153 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight);
154 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
155 delegate.get(), -1234, bounds, NULL));
156 aura::Window* window_ptr = &*window;
157
158 root_window()->ShowCursor(true);
159 // Send a mouse event to window.
160 gfx::Point point(101, 201);
161 gfx::Point local_point;
162 MouseEvent event(ui::ET_MOUSE_MOVED, point, point, 0);
163 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&event);
164
165 // Location was in window.
166 local_point = delegate->mouse_event_location();
167 aura::Window::ConvertPointToWindow(window_ptr, root_window(), &local_point);
168 EXPECT_TRUE(window->bounds().Contains(local_point));
169
170 // Location is now out of window.
171 root_window()->ShowCursor(false);
172 local_point = delegate->mouse_event_location();
173 aura::Window::ConvertPointToWindow(window_ptr, root_window(), &local_point);
174 EXPECT_FALSE(window->bounds().Contains(local_point));
175
176 // Location is back in window.
177 root_window()->ShowCursor(true);
178 local_point = delegate->mouse_event_location();
179 aura::Window::ConvertPointToWindow(window_ptr, root_window(), &local_point);
180 EXPECT_TRUE(window->bounds().Contains(local_point));
181 }
182
149 // Check that we correctly track the state of the mouse buttons in response to 183 // Check that we correctly track the state of the mouse buttons in response to
150 // button press and release events. 184 // button press and release events.
151 TEST_F(RootWindowTest, MouseButtonState) { 185 TEST_F(RootWindowTest, MouseButtonState) {
152 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); 186 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down());
153 187
154 gfx::Point location; 188 gfx::Point location;
155 scoped_ptr<MouseEvent> event; 189 scoped_ptr<MouseEvent> event;
156 190
157 // Press the left button. 191 // Press the left button.
158 event.reset(new MouseEvent( 192 event.reset(new MouseEvent(
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 root_window()->ReleaseMouseMoves(); 569 root_window()->ReleaseMouseMoves();
536 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( 570 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(
537 &mouse_dragged_event2); 571 &mouse_dragged_event2);
538 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events())); 572 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events()));
539 filter->events().clear(); 573 filter->events().clear();
540 RunAllPendingInMessageLoop(); 574 RunAllPendingInMessageLoop();
541 EXPECT_TRUE(filter->events().empty()); 575 EXPECT_TRUE(filter->events().empty());
542 } 576 }
543 577
544 } // namespace aura 578 } // namespace aura
OLDNEW
« ui/aura/root_window.cc ('K') | « ui/aura/root_window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698