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

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

Issue 2676673005: ash: Clean up shelf GetAlignment() and IsHorizontalAlignment() calls (Closed)
Patch Set: Created 3 years, 10 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) 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/shelf/shelf_layout_manager.h" 5 #include "ash/common/shelf/shelf_layout_manager.h"
6 6
7 #include "ash/common/accelerators/accelerator_controller.h" 7 #include "ash/common/accelerators/accelerator_controller.h"
8 #include "ash/common/accelerators/accelerator_table.h" 8 #include "ash/common/accelerators/accelerator_table.h"
9 #include "ash/common/focus_cycler.h" 9 #include "ash/common/focus_cycler.h"
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return; 149 return;
150 } 150 }
151 151
152 // The state of the shelf at the end of the gesture is tested separately. 152 // The state of the shelf at the end of the gesture is tested separately.
153 if (type == ui::ET_GESTURE_SCROLL_END) 153 if (type == ui::ET_GESTURE_SCROLL_END)
154 return; 154 return;
155 155
156 if (type == ui::ET_GESTURE_SCROLL_UPDATE) 156 if (type == ui::ET_GESTURE_SCROLL_UPDATE)
157 scroll_.Add(delta); 157 scroll_.Add(delta);
158 158
159 WmShelf* shelf = test::AshTestBase::GetPrimaryShelf();
159 gfx::Rect shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); 160 gfx::Rect shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
160 if (GetShelfLayoutManager()->IsHorizontalAlignment()) { 161 if (shelf->IsHorizontalAlignment()) {
161 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.bottom(), 162 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.bottom(),
162 shelf_bounds.bottom()); 163 shelf_bounds.bottom());
163 EXPECT_EQ(shelf_widget_bounds_.bottom(), shelf_bounds.bottom()); 164 EXPECT_EQ(shelf_widget_bounds_.bottom(), shelf_bounds.bottom());
164 } else if (SHELF_ALIGNMENT_RIGHT == 165 } else if (SHELF_ALIGNMENT_RIGHT == shelf->GetAlignment()) {
165 GetShelfLayoutManager()->GetAlignment()) {
166 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.right(), shelf_bounds.right()); 166 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.right(), shelf_bounds.right());
167 EXPECT_EQ(shelf_widget_bounds_.right(), shelf_bounds.right()); 167 EXPECT_EQ(shelf_widget_bounds_.right(), shelf_bounds.right());
168 } else if (SHELF_ALIGNMENT_LEFT == 168 } else if (SHELF_ALIGNMENT_LEFT == shelf->GetAlignment()) {
169 GetShelfLayoutManager()->GetAlignment()) {
170 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.x(), shelf_bounds.x()); 169 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.x(), shelf_bounds.x());
171 EXPECT_EQ(shelf_widget_bounds_.x(), shelf_bounds.x()); 170 EXPECT_EQ(shelf_widget_bounds_.x(), shelf_bounds.x());
172 } 171 }
173 172
174 // Auto hidden shelf has a visible height of 0 in MD (where this inequality 173 // Auto hidden shelf has a visible height of 0 in MD (where this inequality
175 // does not apply); whereas auto hidden shelf has a visible height of 3 in 174 // does not apply); whereas auto hidden shelf has a visible height of 3 in
176 // non-MD. 175 // non-MD.
177 WmShelf* shelf = test::AshTestBase::GetPrimaryShelf();
178 if (!ash::MaterialDesignController::IsImmersiveModeMaterial() || 176 if (!ash::MaterialDesignController::IsImmersiveModeMaterial() ||
179 shelf->GetAutoHideState() != ash::SHELF_AUTO_HIDE_HIDDEN) { 177 shelf->GetAutoHideState() != ash::SHELF_AUTO_HIDE_HIDDEN) {
180 EXPECT_GE(shelf_bounds.height(), 178 EXPECT_GE(shelf_bounds.height(),
181 auto_hidden_shelf_widget_bounds_.height()); 179 auto_hidden_shelf_widget_bounds_.height());
182 } 180 }
183 181
184 float scroll_delta = 182 float scroll_delta =
185 GetShelfLayoutManager()->PrimaryAxisValue(scroll_.y(), scroll_.x()); 183 GetShelfLayoutManager()->PrimaryAxisValue(scroll_.y(), scroll_.x());
186 bool increasing_drag = 184 bool increasing_drag =
187 GetShelfLayoutManager()->SelectValueForShelfAlignment( 185 GetShelfLayoutManager()->SelectValueForShelfAlignment(
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); 389 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
392 390
393 // Swipe up yet again to show it. 391 // Swipe up yet again to show it.
394 end = start + delta; 392 end = start + delta;
395 generator.GestureScrollSequenceWithCallback( 393 generator.GestureScrollSequenceWithCallback(
396 end, start, kTimeDelta, kNumScrollSteps, 394 end, start, kTimeDelta, kNumScrollSteps,
397 base::Bind(&ShelfDragCallback::ProcessScroll, 395 base::Bind(&ShelfDragCallback::ProcessScroll,
398 base::Unretained(&handler))); 396 base::Unretained(&handler)));
399 397
400 // Swipe down very little. It shouldn't change any state. 398 // Swipe down very little. It shouldn't change any state.
401 if (GetShelfLayoutManager()->IsHorizontalAlignment()) 399 if (shelf->IsHorizontalAlignment())
402 end.set_y(start.y() + shelf_shown.height() * 3 / 10); 400 end.set_y(start.y() + shelf_shown.height() * 3 / 10);
403 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) 401 else if (SHELF_ALIGNMENT_LEFT == shelf->GetAlignment())
404 end.set_x(start.x() - shelf_shown.width() * 3 / 10); 402 end.set_x(start.x() - shelf_shown.width() * 3 / 10);
405 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) 403 else if (SHELF_ALIGNMENT_RIGHT == shelf->GetAlignment())
406 end.set_x(start.x() + shelf_shown.width() * 3 / 10); 404 end.set_x(start.x() + shelf_shown.width() * 3 / 10);
407 generator.GestureScrollSequence(start, end, kTimeDelta, 5); 405 generator.GestureScrollSequence(start, end, kTimeDelta, 5);
408 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 406 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
409 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); 407 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
410 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); 408 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
411 EXPECT_EQ(shelf_shown.ToString(), 409 EXPECT_EQ(shelf_shown.ToString(),
412 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); 410 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
413 411
414 // Swipe down again to hide. 412 // Swipe down again to hide.
415 end = start + delta; 413 end = start + delta;
416 generator.GestureScrollSequenceWithCallback( 414 generator.GestureScrollSequenceWithCallback(
417 start, end, kTimeDelta, kNumScrollSteps, 415 start, end, kTimeDelta, kNumScrollSteps,
418 base::Bind(&ShelfDragCallback::ProcessScroll, 416 base::Bind(&ShelfDragCallback::ProcessScroll,
419 base::Unretained(&handler))); 417 base::Unretained(&handler)));
420 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 418 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
421 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 419 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
422 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); 420 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
423 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); 421 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString());
424 EXPECT_EQ(shelf_hidden.ToString(), 422 EXPECT_EQ(shelf_hidden.ToString(),
425 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); 423 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
426 424
427 // Swipe up in extended hit region to show it. 425 // Swipe up in extended hit region to show it.
428 gfx::Point extended_start = start; 426 gfx::Point extended_start = start;
429 if (GetShelfLayoutManager()->IsHorizontalAlignment()) 427 if (shelf->IsHorizontalAlignment())
430 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() - 1); 428 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() - 1);
431 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) 429 else if (SHELF_ALIGNMENT_LEFT == shelf->GetAlignment())
432 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 430 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() +
433 1); 431 1);
434 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) 432 else if (SHELF_ALIGNMENT_RIGHT == shelf->GetAlignment())
435 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); 433 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1);
436 end = extended_start - delta; 434 end = extended_start - delta;
437 generator.GestureScrollSequenceWithCallback( 435 generator.GestureScrollSequenceWithCallback(
438 extended_start, end, kTimeDelta, kNumScrollSteps, 436 extended_start, end, kTimeDelta, kNumScrollSteps,
439 base::Bind(&ShelfDragCallback::ProcessScroll, 437 base::Bind(&ShelfDragCallback::ProcessScroll,
440 base::Unretained(&handler))); 438 base::Unretained(&handler)));
441 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 439 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
442 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); 440 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
443 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); 441 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
444 EXPECT_EQ(shelf_shown.ToString(), 442 EXPECT_EQ(shelf_shown.ToString(),
(...skipping 23 matching lines...) Expand all
468 kNumScrollSteps); 466 kNumScrollSteps);
469 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 467 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
470 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 468 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
471 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); 469 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
472 EXPECT_EQ(shelf_hidden.ToString(), 470 EXPECT_EQ(shelf_hidden.ToString(),
473 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); 471 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
474 472
475 // Swipe up from below the shelf where a bezel would be, this should show the 473 // Swipe up from below the shelf where a bezel would be, this should show the
476 // shelf. 474 // shelf.
477 gfx::Point below_start = start; 475 gfx::Point below_start = start;
478 if (GetShelfLayoutManager()->IsHorizontalAlignment()) 476 if (shelf->IsHorizontalAlignment())
479 below_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().bottom() + 1); 477 below_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().bottom() + 1);
480 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) 478 else if (SHELF_ALIGNMENT_LEFT == shelf->GetAlignment())
481 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); 479 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1);
482 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) 480 else if (SHELF_ALIGNMENT_RIGHT == shelf->GetAlignment())
483 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); 481 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1);
484 end = below_start - delta; 482 end = below_start - delta;
485 generator.GestureScrollSequence(below_start, end, kTimeDelta, 483 generator.GestureScrollSequence(below_start, end, kTimeDelta,
486 kNumScrollSteps); 484 kNumScrollSteps);
487 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 485 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
488 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); 486 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior());
489 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); 487 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString());
490 EXPECT_EQ(shelf_shown.ToString(), 488 EXPECT_EQ(shelf_shown.ToString(),
491 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); 489 GetShelfWidget()->GetWindowBoundsInScreen().ToString());
492 490
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 // Open keyboard in sticky mode. 1834 // Open keyboard in sticky mode.
1837 kb_controller->ShowKeyboard(true); 1835 kb_controller->ShowKeyboard(true);
1838 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); 1836 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
1839 1837
1840 // Work area should be changed. 1838 // Work area should be changed.
1841 EXPECT_NE(orig_work_area, 1839 EXPECT_NE(orig_work_area,
1842 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1840 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1843 } 1841 }
1844 1842
1845 } // namespace ash 1843 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/panels/panel_layout_manager.cc ('k') | chrome/browser/chromeos/accessibility/accessibility_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698