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

Side by Side Diff: ash/shelf/shelf_widget_unittest.cc

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/shelf/shelf_widget.h" 5 #include "ash/shelf/shelf_widget.h"
6 6
7 #include "ash/root_window_controller.h" 7 #include "ash/root_window_controller.h"
8 #include "ash/shelf/shelf.h" 8 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_button.h" 9 #include "ash/shelf/shelf_button.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 widget->Show(); 202 widget->Show();
203 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen(); 203 gfx::Rect widget_bounds = widget->GetWindowBoundsInScreen();
204 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds)); 204 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds));
205 205
206 ui::EventTarget* root = widget->GetNativeWindow()->GetRootWindow(); 206 ui::EventTarget* root = widget->GetNativeWindow()->GetRootWindow();
207 ui::EventTargeter* targeter = root->GetEventTargeter(); 207 ui::EventTargeter* targeter = root->GetEventTargeter();
208 { 208 {
209 // Create a mouse-event targeting the top of the shelf widget. The 209 // Create a mouse-event targeting the top of the shelf widget. The
210 // window-targeter should find |widget| as the target (instead of the 210 // window-targeter should find |widget| as the target (instead of the
211 // shelf). 211 // shelf).
212 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1); 212 gfx::PointF event_location(widget_bounds.x() + 5.f, shelf_bounds.y() + 1.f);
213 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 213 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
214 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 214 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
215 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); 215 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
216 EXPECT_EQ(widget->GetNativeWindow(), target); 216 EXPECT_EQ(widget->GetNativeWindow(), target);
217 } 217 }
218 218
219 // Change shelf alignment to verify that the targeter insets are updated. 219 // Change shelf alignment to verify that the targeter insets are updated.
220 shelf_layout_manager->SetAlignment(SHELF_ALIGNMENT_LEFT); 220 shelf_layout_manager->SetAlignment(SHELF_ALIGNMENT_LEFT);
221 shelf_layout_manager->LayoutShelf(); 221 shelf_layout_manager->LayoutShelf();
222 shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); 222 shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
223 { 223 {
224 // Create a mouse-event targeting the right edge of the shelf widget. The 224 // Create a mouse-event targeting the right edge of the shelf widget. The
225 // window-targeter should find |widget| as the target (instead of the 225 // window-targeter should find |widget| as the target (instead of the
226 // shelf). 226 // shelf).
227 gfx::Point event_location(shelf_bounds.right() - 1, widget_bounds.y() + 5); 227 gfx::PointF event_location(shelf_bounds.right() - 1.f,
228 widget_bounds.y() + 5.f);
228 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 229 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
229 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 230 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
230 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); 231 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
231 EXPECT_EQ(widget->GetNativeWindow(), target); 232 EXPECT_EQ(widget->GetNativeWindow(), target);
232 } 233 }
233 234
234 // Now restore shelf alignment (bottom) and auto-hide (hidden) the shelf. 235 // Now restore shelf alignment (bottom) and auto-hide (hidden) the shelf.
235 shelf_layout_manager->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 236 shelf_layout_manager->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
236 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 237 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
237 shelf_layout_manager->LayoutShelf(); 238 shelf_layout_manager->LayoutShelf();
238 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state()); 239 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state());
239 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state()); 240 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
240 shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); 241 shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
241 EXPECT_TRUE(!shelf_bounds.IsEmpty()); 242 EXPECT_TRUE(!shelf_bounds.IsEmpty());
242 243
243 // Move |widget| so it still overlaps the shelf. 244 // Move |widget| so it still overlaps the shelf.
244 widget->SetBounds(gfx::Rect(0, 245 widget->SetBounds(gfx::Rect(0,
245 shelf_bounds.y() - kWindowHeight + kOverlapSize, 246 shelf_bounds.y() - kWindowHeight + kOverlapSize,
246 kWindowWidth, kWindowHeight)); 247 kWindowWidth, kWindowHeight));
247 widget_bounds = widget->GetWindowBoundsInScreen(); 248 widget_bounds = widget->GetWindowBoundsInScreen();
248 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds)); 249 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds));
249 { 250 {
250 // Create a mouse-event targeting the top of the shelf widget. This time, 251 // Create a mouse-event targeting the top of the shelf widget. This time,
251 // window-target should find the shelf as the target. 252 // window-target should find the shelf as the target.
252 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1); 253 gfx::PointF event_location(widget_bounds.x() + 5.f, shelf_bounds.y() + 1.f);
253 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 254 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
254 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 255 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
255 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); 256 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
256 EXPECT_EQ(shelf_widget->GetNativeWindow(), target); 257 EXPECT_EQ(shelf_widget->GetNativeWindow(), target);
257 } 258 }
258 } 259 }
259 260
260 // Tests that the shelf has a slightly larger hit-region for touch-events when 261 // Tests that the shelf has a slightly larger hit-region for touch-events when
261 // it's in the auto-hidden state. 262 // it's in the auto-hidden state.
262 TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) { 263 TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) {
(...skipping 12 matching lines...) Expand all
275 params.context = CurrentContext(); 276 params.context = CurrentContext();
276 // Widget is now owned by the parent window. 277 // Widget is now owned by the parent window.
277 widget->Init(params); 278 widget->Init(params);
278 widget->Show(); 279 widget->Show();
279 280
280 ui::EventTarget* root = shelf_widget->GetNativeWindow()->GetRootWindow(); 281 ui::EventTarget* root = shelf_widget->GetNativeWindow()->GetRootWindow();
281 ui::EventTargeter* targeter = root->GetEventTargeter(); 282 ui::EventTargeter* targeter = root->GetEventTargeter();
282 // Touch just over the shelf. Since the shelf is visible, the window-targeter 283 // Touch just over the shelf. Since the shelf is visible, the window-targeter
283 // should not find the shelf as the target. 284 // should not find the shelf as the target.
284 { 285 {
285 gfx::Point event_location(20, shelf_bounds.y() - 1); 286 gfx::PointF event_location(20.f, shelf_bounds.y() - 1.f);
286 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0, 287 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0,
287 ui::EventTimeForNow()); 288 ui::EventTimeForNow());
288 EXPECT_NE(shelf_widget->GetNativeWindow(), 289 EXPECT_NE(shelf_widget->GetNativeWindow(),
289 targeter->FindTargetForEvent(root, &touch)); 290 targeter->FindTargetForEvent(root, &touch));
290 } 291 }
291 292
292 // Now auto-hide (hidden) the shelf. 293 // Now auto-hide (hidden) the shelf.
293 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 294 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
294 shelf_layout_manager->LayoutShelf(); 295 shelf_layout_manager->LayoutShelf();
295 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state()); 296 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state());
296 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state()); 297 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
297 shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); 298 shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
298 EXPECT_TRUE(!shelf_bounds.IsEmpty()); 299 EXPECT_TRUE(!shelf_bounds.IsEmpty());
299 300
300 // Touch just over the shelf again. This time, the targeter should find the 301 // Touch just over the shelf again. This time, the targeter should find the
301 // shelf as the target. 302 // shelf as the target.
302 { 303 {
303 gfx::Point event_location(20, shelf_bounds.y() - 1); 304 gfx::PointF event_location(20.f, shelf_bounds.y() - 1.f);
304 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0, 305 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0,
305 ui::EventTimeForNow()); 306 ui::EventTimeForNow());
306 EXPECT_EQ(shelf_widget->GetNativeWindow(), 307 EXPECT_EQ(shelf_widget->GetNativeWindow(),
307 targeter->FindTargetForEvent(root, &touch)); 308 targeter->FindTargetForEvent(root, &touch));
308 } 309 }
309 } 310 }
310 311
311 } // namespace ash 312 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698