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

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

Issue 2017413002: ash: Fix variable names and setters in ShelfLayoutManager and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shellshelf
Patch Set: review comments 3 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 | « ash/shelf/shelf_view_unittest.cc ('k') | ash/system/toast/toast_manager_unittest.cc » ('j') | 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) 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_delegate.h" 9 #include "ash/shelf/shelf_delegate.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // window-targeter should find |widget| as the target (instead of the 221 // window-targeter should find |widget| as the target (instead of the
222 // shelf). 222 // shelf).
223 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1); 223 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1);
224 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 224 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
225 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 225 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
226 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); 226 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
227 EXPECT_EQ(widget->GetNativeWindow(), target); 227 EXPECT_EQ(widget->GetNativeWindow(), target);
228 } 228 }
229 229
230 // Change shelf alignment to verify that the targeter insets are updated. 230 // Change shelf alignment to verify that the targeter insets are updated.
231 shelf_layout_manager->SetAlignment(wm::SHELF_ALIGNMENT_LEFT); 231 Shelf* shelf = Shelf::ForPrimaryDisplay();
232 shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
232 shelf_layout_manager->LayoutShelf(); 233 shelf_layout_manager->LayoutShelf();
233 shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); 234 shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
234 { 235 {
235 // Create a mouse-event targeting the right edge of the shelf widget. The 236 // Create a mouse-event targeting the right edge of the shelf widget. The
236 // window-targeter should find |widget| as the target (instead of the 237 // window-targeter should find |widget| as the target (instead of the
237 // shelf). 238 // shelf).
238 gfx::Point event_location(shelf_bounds.right() - 1, widget_bounds.y() + 5); 239 gfx::Point event_location(shelf_bounds.right() - 1, widget_bounds.y() + 5);
239 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 240 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
240 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 241 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
241 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); 242 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
242 EXPECT_EQ(widget->GetNativeWindow(), target); 243 EXPECT_EQ(widget->GetNativeWindow(), target);
243 } 244 }
244 245
245 // Now restore shelf alignment (bottom) and auto-hide (hidden) the shelf. 246 // Now restore shelf alignment (bottom) and auto-hide (hidden) the shelf.
246 shelf_layout_manager->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM); 247 shelf->SetAlignment(wm::SHELF_ALIGNMENT_BOTTOM);
247 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 248 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
248 shelf_layout_manager->LayoutShelf(); 249 shelf_layout_manager->LayoutShelf();
249 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state()); 250 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state());
250 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state()); 251 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
251 shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); 252 shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
252 EXPECT_TRUE(!shelf_bounds.IsEmpty()); 253 EXPECT_TRUE(!shelf_bounds.IsEmpty());
253 254
254 // Move |widget| so it still overlaps the shelf. 255 // Move |widget| so it still overlaps the shelf.
255 widget->SetBounds(gfx::Rect(0, 256 widget->SetBounds(gfx::Rect(0,
256 shelf_bounds.y() - kWindowHeight + kOverlapSize, 257 shelf_bounds.y() - kWindowHeight + kOverlapSize,
257 kWindowWidth, kWindowHeight)); 258 kWindowWidth, kWindowHeight));
258 widget_bounds = widget->GetWindowBoundsInScreen(); 259 widget_bounds = widget->GetWindowBoundsInScreen();
259 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds)); 260 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds));
260 { 261 {
261 // Create a mouse-event targeting the top of the shelf widget. This time, 262 // Create a mouse-event targeting the top of the shelf widget. This time,
262 // window-target should find the shelf as the target. 263 // window-target should find the shelf as the target.
263 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1); 264 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1);
264 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 265 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location,
265 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 266 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
266 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); 267 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
267 EXPECT_EQ(shelf_widget->GetNativeWindow(), target); 268 EXPECT_EQ(shelf_widget->GetNativeWindow(), target);
268 } 269 }
269 } 270 }
270 271
271 // Tests that the shelf has a slightly larger hit-region for touch-events when 272 // Tests that the shelf has a slightly larger hit-region for touch-events when
272 // it's in the auto-hidden state. 273 // it's in the auto-hidden state.
273 TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) { 274 TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) {
275 Shelf* shelf = Shelf::ForPrimaryDisplay();
274 ShelfWidget* shelf_widget = GetShelfWidget(); 276 ShelfWidget* shelf_widget = GetShelfWidget();
275 gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); 277 gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
276 EXPECT_TRUE(!shelf_bounds.IsEmpty()); 278 EXPECT_TRUE(!shelf_bounds.IsEmpty());
277 ShelfLayoutManager* shelf_layout_manager = 279 ShelfLayoutManager* shelf_layout_manager =
278 shelf_widget->shelf_layout_manager(); 280 shelf_widget->shelf_layout_manager();
279 ASSERT_TRUE(shelf_layout_manager); 281 ASSERT_TRUE(shelf_layout_manager);
280 EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state()); 282 EXPECT_EQ(SHELF_VISIBLE, shelf_layout_manager->visibility_state());
281 283
282 // Create a widget to make sure that the shelf does auto-hide. 284 // Create a widget to make sure that the shelf does auto-hide.
283 views::Widget* widget = new views::Widget; 285 views::Widget* widget = new views::Widget;
(...skipping 10 matching lines...) Expand all
294 // should not find the shelf as the target. 296 // should not find the shelf as the target.
295 { 297 {
296 gfx::Point event_location(20, shelf_bounds.y() - 1); 298 gfx::Point event_location(20, shelf_bounds.y() - 1);
297 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0, 299 ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0,
298 ui::EventTimeForNow()); 300 ui::EventTimeForNow());
299 EXPECT_NE(shelf_widget->GetNativeWindow(), 301 EXPECT_NE(shelf_widget->GetNativeWindow(),
300 targeter->FindTargetForEvent(root, &touch)); 302 targeter->FindTargetForEvent(root, &touch));
301 } 303 }
302 304
303 // Now auto-hide (hidden) the shelf. 305 // Now auto-hide (hidden) the shelf.
304 shelf_layout_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 306 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
305 shelf_layout_manager->LayoutShelf(); 307 shelf_layout_manager->LayoutShelf();
306 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state()); 308 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state());
307 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state()); 309 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
308 shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); 310 shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
309 EXPECT_TRUE(!shelf_bounds.IsEmpty()); 311 EXPECT_TRUE(!shelf_bounds.IsEmpty());
310 312
311 // Touch just over the shelf again. This time, the targeter should find the 313 // Touch just over the shelf again. This time, the targeter should find the
312 // shelf as the target. 314 // shelf as the target.
313 { 315 {
314 gfx::Point event_location(20, shelf_bounds.y() - 1); 316 gfx::Point event_location(20, shelf_bounds.y() - 1);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 SetSessionStarted(true); 411 SetSessionStarted(true);
410 412
411 ShelfWidget* shelf_widget = GetShelfWidget(); 413 ShelfWidget* shelf_widget = GetShelfWidget();
412 ASSERT_NE(nullptr, shelf_widget); 414 ASSERT_NE(nullptr, shelf_widget);
413 Shelf* shelf = shelf_widget->shelf(); 415 Shelf* shelf = shelf_widget->shelf();
414 ASSERT_NE(nullptr, shelf); 416 ASSERT_NE(nullptr, shelf);
415 ShelfLayoutManager* shelf_layout_manager = 417 ShelfLayoutManager* shelf_layout_manager =
416 shelf_widget->shelf_layout_manager(); 418 shelf_widget->shelf_layout_manager();
417 ASSERT_NE(nullptr, shelf_layout_manager); 419 ASSERT_NE(nullptr, shelf_layout_manager);
418 420
419 EXPECT_EQ(initial_alignment, shelf_layout_manager->GetAlignment()); 421 EXPECT_EQ(initial_alignment, shelf->alignment());
420 EXPECT_EQ(initial_auto_hide_behavior, 422 EXPECT_EQ(initial_auto_hide_behavior, shelf->auto_hide_behavior());
421 shelf_layout_manager->auto_hide_behavior());
422 EXPECT_EQ(expected_shelf_visibility_state, 423 EXPECT_EQ(expected_shelf_visibility_state,
423 shelf_layout_manager->visibility_state()); 424 shelf_layout_manager->visibility_state());
424 EXPECT_EQ(expected_shelf_auto_hide_state, 425 EXPECT_EQ(expected_shelf_auto_hide_state,
425 shelf_layout_manager->auto_hide_state()); 426 shelf_layout_manager->auto_hide_state());
426 } 427 }
427 428
428 private: 429 private:
429 ShelfWidgetTestShellDelegate* shelf_widget_test_shell_delegate_; 430 ShelfWidgetTestShellDelegate* shelf_widget_test_shell_delegate_;
430 DISALLOW_COPY_AND_ASSIGN(ShelfWidgetTestWithDelegate); 431 DISALLOW_COPY_AND_ASSIGN(ShelfWidgetTestWithDelegate);
431 }; 432 };
(...skipping 22 matching lines...) Expand all
454 } 455 }
455 456
456 TEST_F(ShelfWidgetTestWithDelegate, CreateLockedShelf) { 457 TEST_F(ShelfWidgetTestWithDelegate, CreateLockedShelf) {
457 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. 458 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior.
458 TestCreateShelfWithInitialValues(wm::SHELF_ALIGNMENT_BOTTOM_LOCKED, 459 TestCreateShelfWithInitialValues(wm::SHELF_ALIGNMENT_BOTTOM_LOCKED,
459 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, 460 SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
460 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); 461 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN);
461 } 462 }
462 463
463 } // namespace ash 464 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view_unittest.cc ('k') | ash/system/toast/toast_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698