OLD | NEW |
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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 bool WasValidAnimation() const { | 103 bool WasValidAnimation() const { |
104 return done_waiting_ && animation_steps_ > 0; | 104 return done_waiting_ && animation_steps_ > 0; |
105 } | 105 } |
106 | 106 |
107 private: | 107 private: |
108 // Returns true if shelf has finished animating to the target size. | 108 // Returns true if shelf has finished animating to the target size. |
109 bool IsDoneAnimating() const { | 109 bool IsDoneAnimating() const { |
110 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 110 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
111 gfx::Rect current_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 111 gfx::Rect current_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
112 int size = layout_manager->PrimaryAxisValue(current_bounds.height(), | 112 int size = layout_manager->PrimaryAxisValue(current_bounds.height(), |
113 current_bounds.width()); | 113 current_bounds.width()); |
114 int desired_size = layout_manager->PrimaryAxisValue(target_bounds_.height(), | 114 int desired_size = layout_manager->PrimaryAxisValue(target_bounds_.height(), |
115 target_bounds_.width()); | 115 target_bounds_.width()); |
116 return (size == desired_size); | 116 return (size == desired_size); |
117 } | 117 } |
118 | 118 |
119 // views::WidgetObserver override. | 119 // views::WidgetObserver override. |
120 void OnWidgetBoundsChanged(views::Widget* widget, | 120 void OnWidgetBoundsChanged(views::Widget* widget, |
121 const gfx::Rect& new_bounds) override { | 121 const gfx::Rect& new_bounds) override { |
122 if (done_waiting_) | 122 if (done_waiting_) |
123 return; | 123 return; |
124 | 124 |
125 ++animation_steps_; | 125 ++animation_steps_; |
(...skipping 12 matching lines...) Expand all Loading... |
138 | 138 |
139 class ShelfDragCallback { | 139 class ShelfDragCallback { |
140 public: | 140 public: |
141 ShelfDragCallback(const gfx::Rect& not_visible, const gfx::Rect& visible) | 141 ShelfDragCallback(const gfx::Rect& not_visible, const gfx::Rect& visible) |
142 : not_visible_bounds_(not_visible), | 142 : not_visible_bounds_(not_visible), |
143 visible_bounds_(visible), | 143 visible_bounds_(visible), |
144 was_visible_on_drag_start_(false) { | 144 was_visible_on_drag_start_(false) { |
145 EXPECT_EQ(not_visible_bounds_.bottom(), visible_bounds_.bottom()); | 145 EXPECT_EQ(not_visible_bounds_.bottom(), visible_bounds_.bottom()); |
146 } | 146 } |
147 | 147 |
148 virtual ~ShelfDragCallback() { | 148 virtual ~ShelfDragCallback() {} |
149 } | |
150 | 149 |
151 void ProcessScroll(ui::EventType type, const gfx::Vector2dF& delta) { | 150 void ProcessScroll(ui::EventType type, const gfx::Vector2dF& delta) { |
152 if (GetShelfLayoutManager()->visibility_state() == ash::SHELF_HIDDEN) | 151 if (GetShelfLayoutManager()->visibility_state() == ash::SHELF_HIDDEN) |
153 return; | 152 return; |
154 | 153 |
155 if (type == ui::ET_GESTURE_SCROLL_BEGIN) { | 154 if (type == ui::ET_GESTURE_SCROLL_BEGIN) { |
156 scroll_ = gfx::Vector2dF(); | 155 scroll_ = gfx::Vector2dF(); |
157 was_visible_on_drag_start_ = GetShelfLayoutManager()->IsVisible(); | 156 was_visible_on_drag_start_ = GetShelfLayoutManager()->IsVisible(); |
158 return; | 157 return; |
159 } | 158 } |
(...skipping 21 matching lines...) Expand all Loading... |
181 | 180 |
182 // if the shelf is being dimmed test dimmer bounds as well. | 181 // if the shelf is being dimmed test dimmer bounds as well. |
183 if (GetShelfWidget()->GetDimsShelf()) | 182 if (GetShelfWidget()->GetDimsShelf()) |
184 EXPECT_EQ(GetShelfWidget()->GetWindowBoundsInScreen(), | 183 EXPECT_EQ(GetShelfWidget()->GetWindowBoundsInScreen(), |
185 GetShelfWidget()->GetDimmerBoundsForTest()); | 184 GetShelfWidget()->GetDimmerBoundsForTest()); |
186 | 185 |
187 // The shelf should never be smaller than the hidden state when shelf is | 186 // The shelf should never be smaller than the hidden state when shelf is |
188 // visible; the shelf has a height of 0 when it is hidden. | 187 // visible; the shelf has a height of 0 when it is hidden. |
189 if (was_visible_on_drag_start_) | 188 if (was_visible_on_drag_start_) |
190 EXPECT_GE(shelf_bounds.height(), not_visible_bounds_.height()); | 189 EXPECT_GE(shelf_bounds.height(), not_visible_bounds_.height()); |
191 float scroll_delta = GetShelfLayoutManager()->PrimaryAxisValue( | 190 float scroll_delta = |
192 scroll_.y(), | 191 GetShelfLayoutManager()->PrimaryAxisValue(scroll_.y(), scroll_.x()); |
193 scroll_.x()); | |
194 bool increasing_drag = | 192 bool increasing_drag = |
195 GetShelfWidget()->shelf()->SelectValueForShelfAlignment( | 193 GetShelfWidget()->shelf()->SelectValueForShelfAlignment( |
196 scroll_delta < 0, scroll_delta > 0, scroll_delta < 0); | 194 scroll_delta<0, scroll_delta> 0, scroll_delta < 0); |
197 int shelf_size = GetShelfLayoutManager()->PrimaryAxisValue( | 195 int shelf_size = GetShelfLayoutManager()->PrimaryAxisValue( |
198 shelf_bounds.height(), | 196 shelf_bounds.height(), shelf_bounds.width()); |
199 shelf_bounds.width()); | |
200 int visible_bounds_size = GetShelfLayoutManager()->PrimaryAxisValue( | 197 int visible_bounds_size = GetShelfLayoutManager()->PrimaryAxisValue( |
201 visible_bounds_.height(), | 198 visible_bounds_.height(), visible_bounds_.width()); |
202 visible_bounds_.width()); | |
203 int not_visible_bounds_size = GetShelfLayoutManager()->PrimaryAxisValue( | 199 int not_visible_bounds_size = GetShelfLayoutManager()->PrimaryAxisValue( |
204 not_visible_bounds_.height(), | 200 not_visible_bounds_.height(), not_visible_bounds_.width()); |
205 not_visible_bounds_.width()); | |
206 if (was_visible_on_drag_start_) { | 201 if (was_visible_on_drag_start_) { |
207 if (increasing_drag) { | 202 if (increasing_drag) { |
208 // If dragging inwards from the visible state, then the shelf should | 203 // If dragging inwards from the visible state, then the shelf should |
209 // increase in size, but not more than the scroll delta. | 204 // increase in size, but not more than the scroll delta. |
210 EXPECT_LE(visible_bounds_size, shelf_size); | 205 EXPECT_LE(visible_bounds_size, shelf_size); |
211 EXPECT_LE(std::abs(shelf_size - visible_bounds_size), | 206 EXPECT_LE(std::abs(shelf_size - visible_bounds_size), |
212 std::abs(scroll_delta)); | 207 std::abs(scroll_delta)); |
213 } else { | 208 } else { |
214 if (shelf_size > not_visible_bounds_size) { | 209 if (shelf_size > not_visible_bounds_size) { |
215 // If dragging outwards from the visible state, then the shelf | 210 // If dragging outwards from the visible state, then the shelf |
(...skipping 19 matching lines...) Expand all Loading... |
235 const gfx::Rect not_visible_bounds_; | 230 const gfx::Rect not_visible_bounds_; |
236 const gfx::Rect visible_bounds_; | 231 const gfx::Rect visible_bounds_; |
237 gfx::Vector2dF scroll_; | 232 gfx::Vector2dF scroll_; |
238 bool was_visible_on_drag_start_; | 233 bool was_visible_on_drag_start_; |
239 | 234 |
240 DISALLOW_COPY_AND_ASSIGN(ShelfDragCallback); | 235 DISALLOW_COPY_AND_ASSIGN(ShelfDragCallback); |
241 }; | 236 }; |
242 | 237 |
243 class ShelfLayoutObserverTest : public ShelfLayoutManagerObserver { | 238 class ShelfLayoutObserverTest : public ShelfLayoutManagerObserver { |
244 public: | 239 public: |
245 ShelfLayoutObserverTest() | 240 ShelfLayoutObserverTest() : changed_auto_hide_state_(false) {} |
246 : changed_auto_hide_state_(false) { | |
247 } | |
248 | 241 |
249 ~ShelfLayoutObserverTest() override {} | 242 ~ShelfLayoutObserverTest() override {} |
250 | 243 |
251 bool changed_auto_hide_state() const { return changed_auto_hide_state_; } | 244 bool changed_auto_hide_state() const { return changed_auto_hide_state_; } |
252 | 245 |
253 private: | 246 private: |
254 // ShelfLayoutManagerObserver: | 247 // ShelfLayoutManagerObserver: |
255 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override { | 248 void OnAutoHideStateChanged(ShelfAutoHideState new_state) override { |
256 changed_auto_hide_state_ = true; | 249 changed_auto_hide_state_ = true; |
257 } | 250 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 422 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
430 const int kNumScrollSteps = 4; | 423 const int kNumScrollSteps = 4; |
431 ShelfDragCallback handler(shelf_hidden, shelf_shown); | 424 ShelfDragCallback handler(shelf_hidden, shelf_shown); |
432 | 425 |
433 // Swipe up on the shelf. This should not change any state. | 426 // Swipe up on the shelf. This should not change any state. |
434 gfx::Point start = GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); | 427 gfx::Point start = GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
435 gfx::Point end = start + delta; | 428 gfx::Point end = start + delta; |
436 | 429 |
437 // Swipe down on the shelf to hide it. | 430 // Swipe down on the shelf to hide it. |
438 generator.GestureScrollSequenceWithCallback( | 431 generator.GestureScrollSequenceWithCallback( |
439 start, | 432 start, end, kTimeDelta, kNumScrollSteps, |
440 end, | |
441 kTimeDelta, | |
442 kNumScrollSteps, | |
443 base::Bind(&ShelfDragCallback::ProcessScroll, | 433 base::Bind(&ShelfDragCallback::ProcessScroll, |
444 base::Unretained(&handler))); | 434 base::Unretained(&handler))); |
445 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 435 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
446 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 436 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
447 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 437 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
448 EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString()); | 438 EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString()); |
449 EXPECT_NE(shelf_shown.ToString(), | 439 EXPECT_NE(shelf_shown.ToString(), |
450 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 440 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
451 | 441 |
452 // Swipe up to show the shelf. | 442 // Swipe up to show the shelf. |
453 generator.GestureScrollSequenceWithCallback( | 443 generator.GestureScrollSequenceWithCallback( |
454 end, | 444 end, start, kTimeDelta, kNumScrollSteps, |
455 start, | |
456 kTimeDelta, | |
457 kNumScrollSteps, | |
458 base::Bind(&ShelfDragCallback::ProcessScroll, | 445 base::Bind(&ShelfDragCallback::ProcessScroll, |
459 base::Unretained(&handler))); | 446 base::Unretained(&handler))); |
460 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 447 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
461 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 448 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
462 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 449 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
463 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | 450 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), |
464 GetShelfWidget()->GetWindowBoundsInScreen()); | 451 GetShelfWidget()->GetWindowBoundsInScreen()); |
465 EXPECT_EQ(shelf_shown.ToString(), | 452 EXPECT_EQ(shelf_shown.ToString(), |
466 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 453 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
467 | 454 |
468 // Swipe up again. The shelf should hide. | 455 // Swipe up again. The shelf should hide. |
469 end = start - delta; | 456 end = start - delta; |
470 generator.GestureScrollSequenceWithCallback( | 457 generator.GestureScrollSequenceWithCallback( |
471 start, | 458 start, end, kTimeDelta, kNumScrollSteps, |
472 end, | |
473 kTimeDelta, | |
474 kNumScrollSteps, | |
475 base::Bind(&ShelfDragCallback::ProcessScroll, | 459 base::Bind(&ShelfDragCallback::ProcessScroll, |
476 base::Unretained(&handler))); | 460 base::Unretained(&handler))); |
477 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 461 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
478 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 462 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
479 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 463 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
480 EXPECT_EQ(shelf_hidden.ToString(), | 464 EXPECT_EQ(shelf_hidden.ToString(), |
481 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 465 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
482 | 466 |
483 // Swipe up yet again to show it. | 467 // Swipe up yet again to show it. |
484 end = start + delta; | 468 end = start + delta; |
485 generator.GestureScrollSequenceWithCallback( | 469 generator.GestureScrollSequenceWithCallback( |
486 end, | 470 end, start, kTimeDelta, kNumScrollSteps, |
487 start, | |
488 kTimeDelta, | |
489 kNumScrollSteps, | |
490 base::Bind(&ShelfDragCallback::ProcessScroll, | 471 base::Bind(&ShelfDragCallback::ProcessScroll, |
491 base::Unretained(&handler))); | 472 base::Unretained(&handler))); |
492 | 473 |
493 // Swipe down very little. It shouldn't change any state. | 474 // Swipe down very little. It shouldn't change any state. |
494 if (GetShelfLayoutManager()->IsHorizontalAlignment()) | 475 if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
495 end.set_y(start.y() + shelf_shown.height() * 3 / 10); | 476 end.set_y(start.y() + shelf_shown.height() * 3 / 10); |
496 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 477 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
497 end.set_x(start.x() - shelf_shown.width() * 3 / 10); | 478 end.set_x(start.x() - shelf_shown.width() * 3 / 10); |
498 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 479 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
499 end.set_x(start.x() + shelf_shown.width() * 3 / 10); | 480 end.set_x(start.x() + shelf_shown.width() * 3 / 10); |
500 generator.GestureScrollSequence(start, end, kTimeDelta, 5); | 481 generator.GestureScrollSequence(start, end, kTimeDelta, 5); |
501 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 482 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
502 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 483 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
503 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 484 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
504 EXPECT_EQ(shelf_shown.ToString(), | 485 EXPECT_EQ(shelf_shown.ToString(), |
505 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 486 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
506 | 487 |
507 // Swipe down again to hide. | 488 // Swipe down again to hide. |
508 end = start + delta; | 489 end = start + delta; |
509 generator.GestureScrollSequenceWithCallback( | 490 generator.GestureScrollSequenceWithCallback( |
510 start, | 491 start, end, kTimeDelta, kNumScrollSteps, |
511 end, | |
512 kTimeDelta, | |
513 kNumScrollSteps, | |
514 base::Bind(&ShelfDragCallback::ProcessScroll, | 492 base::Bind(&ShelfDragCallback::ProcessScroll, |
515 base::Unretained(&handler))); | 493 base::Unretained(&handler))); |
516 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 494 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
517 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 495 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
518 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 496 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
519 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | 497 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); |
520 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 498 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
521 EXPECT_EQ(shelf_hidden.ToString(), | 499 EXPECT_EQ(shelf_hidden.ToString(), |
522 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 500 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
523 | 501 |
524 // Swipe up in extended hit region to show it. | 502 // Swipe up in extended hit region to show it. |
525 gfx::Point extended_start = start; | 503 gfx::Point extended_start = start; |
526 if (GetShelfLayoutManager()->IsHorizontalAlignment()) | 504 if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
527 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() -1); | 505 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() - 1); |
528 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 506 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
529 extended_start.set_x( | 507 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + |
530 GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); | 508 1); |
531 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 509 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
532 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); | 510 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
533 end = extended_start - delta; | 511 end = extended_start - delta; |
534 generator.GestureScrollSequenceWithCallback( | 512 generator.GestureScrollSequenceWithCallback( |
535 extended_start, | 513 extended_start, end, kTimeDelta, kNumScrollSteps, |
536 end, | |
537 kTimeDelta, | |
538 kNumScrollSteps, | |
539 base::Bind(&ShelfDragCallback::ProcessScroll, | 514 base::Bind(&ShelfDragCallback::ProcessScroll, |
540 base::Unretained(&handler))); | 515 base::Unretained(&handler))); |
541 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 516 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
542 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 517 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
543 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 518 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
544 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | 519 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), |
545 GetShelfWidget()->GetWindowBoundsInScreen()); | 520 GetShelfWidget()->GetWindowBoundsInScreen()); |
546 EXPECT_EQ(shelf_shown.ToString(), | 521 EXPECT_EQ(shelf_shown.ToString(), |
547 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 522 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
548 | 523 |
549 // Swipe down again to hide. | 524 // Swipe down again to hide. |
550 end = start + delta; | 525 end = start + delta; |
551 generator.GestureScrollSequenceWithCallback( | 526 generator.GestureScrollSequenceWithCallback( |
552 start, | 527 start, end, kTimeDelta, kNumScrollSteps, |
553 end, | |
554 kTimeDelta, | |
555 kNumScrollSteps, | |
556 base::Bind(&ShelfDragCallback::ProcessScroll, | 528 base::Bind(&ShelfDragCallback::ProcessScroll, |
557 base::Unretained(&handler))); | 529 base::Unretained(&handler))); |
558 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 530 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
559 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 531 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
560 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 532 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
561 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | 533 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); |
562 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 534 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
563 EXPECT_EQ(shelf_hidden.ToString(), | 535 EXPECT_EQ(shelf_hidden.ToString(), |
564 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 536 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
565 | 537 |
566 // Swipe up outside the hit area. This should not change anything. | 538 // Swipe up outside the hit area. This should not change anything. |
567 gfx::Point outside_start = gfx::Point( | 539 gfx::Point outside_start = |
568 (GetShelfWidget()->GetWindowBoundsInScreen().x() + | 540 gfx::Point((GetShelfWidget()->GetWindowBoundsInScreen().x() + |
569 GetShelfWidget()->GetWindowBoundsInScreen().right())/2, | 541 GetShelfWidget()->GetWindowBoundsInScreen().right()) / |
570 GetShelfWidget()->GetWindowBoundsInScreen().y() - 50); | 542 2, |
| 543 GetShelfWidget()->GetWindowBoundsInScreen().y() - 50); |
571 end = outside_start + delta; | 544 end = outside_start + delta; |
572 generator.GestureScrollSequence( | 545 generator.GestureScrollSequence(outside_start, end, kTimeDelta, |
573 outside_start, end, kTimeDelta, kNumScrollSteps); | 546 kNumScrollSteps); |
574 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 547 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
575 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 548 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
576 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 549 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
577 EXPECT_EQ(shelf_hidden.ToString(), | 550 EXPECT_EQ(shelf_hidden.ToString(), |
578 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 551 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
579 | 552 |
580 // Swipe up from below the shelf where a bezel would be, this should show the | 553 // Swipe up from below the shelf where a bezel would be, this should show the |
581 // shelf. | 554 // shelf. |
582 gfx::Point below_start = start; | 555 gfx::Point below_start = start; |
583 if (GetShelfLayoutManager()->IsHorizontalAlignment()) | 556 if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
584 below_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().bottom() + 1); | 557 below_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().bottom() + 1); |
585 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 558 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
586 below_start.set_x( | 559 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
587 GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); | |
588 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 560 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
589 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); | 561 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); |
590 end = below_start - delta; | 562 end = below_start - delta; |
591 generator.GestureScrollSequence( | 563 generator.GestureScrollSequence(below_start, end, kTimeDelta, |
592 below_start, end, kTimeDelta, kNumScrollSteps); | 564 kNumScrollSteps); |
593 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 565 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
594 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 566 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
595 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 567 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
596 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | 568 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), |
597 GetShelfWidget()->GetWindowBoundsInScreen()); | 569 GetShelfWidget()->GetWindowBoundsInScreen()); |
598 EXPECT_EQ(shelf_shown.ToString(), | 570 EXPECT_EQ(shelf_shown.ToString(), |
599 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 571 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
600 | 572 |
601 // Swipe down again to hide. | 573 // Swipe down again to hide. |
602 end = start + delta; | 574 end = start + delta; |
603 generator.GestureScrollSequenceWithCallback( | 575 generator.GestureScrollSequenceWithCallback( |
604 start, | 576 start, end, kTimeDelta, kNumScrollSteps, |
605 end, | |
606 kTimeDelta, | |
607 kNumScrollSteps, | |
608 base::Bind(&ShelfDragCallback::ProcessScroll, | 577 base::Bind(&ShelfDragCallback::ProcessScroll, |
609 base::Unretained(&handler))); | 578 base::Unretained(&handler))); |
610 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 579 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
611 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 580 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
612 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 581 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
613 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | 582 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); |
614 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 583 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
615 EXPECT_EQ(shelf_hidden.ToString(), | 584 EXPECT_EQ(shelf_hidden.ToString(), |
616 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 585 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
617 | 586 |
618 // Put |widget| into fullscreen. Set the shelf to be auto hidden when |widget| | 587 // Put |widget| into fullscreen. Set the shelf to be auto hidden when |widget| |
619 // is fullscreen. (eg browser immersive fullscreen). | 588 // is fullscreen. (eg browser immersive fullscreen). |
620 widget->SetFullscreen(true); | 589 widget->SetFullscreen(true); |
621 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); | 590 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); |
622 layout_manager->UpdateVisibilityState(); | 591 layout_manager->UpdateVisibilityState(); |
623 | 592 |
624 gfx::Rect bounds_fullscreen = window->bounds(); | 593 gfx::Rect bounds_fullscreen = window->bounds(); |
625 EXPECT_TRUE(widget->IsFullscreen()); | 594 EXPECT_TRUE(widget->IsFullscreen()); |
626 EXPECT_NE(bounds_noshelf.ToString(), bounds_fullscreen.ToString()); | 595 EXPECT_NE(bounds_noshelf.ToString(), bounds_fullscreen.ToString()); |
627 | 596 |
628 // Swipe up. This should show the shelf. | 597 // Swipe up. This should show the shelf. |
629 end = below_start - delta; | 598 end = below_start - delta; |
630 generator.GestureScrollSequenceWithCallback( | 599 generator.GestureScrollSequenceWithCallback( |
631 below_start, | 600 below_start, end, kTimeDelta, kNumScrollSteps, |
632 end, | |
633 kTimeDelta, | |
634 kNumScrollSteps, | |
635 base::Bind(&ShelfDragCallback::ProcessScroll, | 601 base::Bind(&ShelfDragCallback::ProcessScroll, |
636 base::Unretained(&handler))); | 602 base::Unretained(&handler))); |
637 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 603 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
638 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 604 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
639 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 605 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
640 EXPECT_EQ(shelf_shown.ToString(), | 606 EXPECT_EQ(shelf_shown.ToString(), |
641 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 607 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
642 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); | 608 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
643 | 609 |
644 // Swipe up again. This should hide the shelf. | 610 // Swipe up again. This should hide the shelf. |
645 generator.GestureScrollSequenceWithCallback( | 611 generator.GestureScrollSequenceWithCallback( |
646 below_start, | 612 below_start, end, kTimeDelta, kNumScrollSteps, |
647 end, | |
648 kTimeDelta, | |
649 kNumScrollSteps, | |
650 base::Bind(&ShelfDragCallback::ProcessScroll, | 613 base::Bind(&ShelfDragCallback::ProcessScroll, |
651 base::Unretained(&handler))); | 614 base::Unretained(&handler))); |
652 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 615 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
653 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 616 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
654 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 617 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
655 EXPECT_EQ(shelf_hidden.ToString(), | 618 EXPECT_EQ(shelf_hidden.ToString(), |
656 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 619 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
657 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); | 620 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
658 | 621 |
659 // Set the shelf to be hidden when |widget| is fullscreen. (eg tab fullscreen | 622 // Set the shelf to be hidden when |widget| is fullscreen. (eg tab fullscreen |
660 // with or without immersive browser fullscreen). | 623 // with or without immersive browser fullscreen). |
661 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(true); | 624 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(true); |
662 layout_manager->UpdateVisibilityState(); | 625 layout_manager->UpdateVisibilityState(); |
663 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 626 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
664 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 627 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
665 | 628 |
666 // Swipe-up. This should not change anything. | 629 // Swipe-up. This should not change anything. |
667 end = start - delta; | 630 end = start - delta; |
668 generator.GestureScrollSequenceWithCallback( | 631 generator.GestureScrollSequenceWithCallback( |
669 below_start, | 632 below_start, end, kTimeDelta, kNumScrollSteps, |
670 end, | |
671 kTimeDelta, | |
672 kNumScrollSteps, | |
673 base::Bind(&ShelfDragCallback::ProcessScroll, | 633 base::Bind(&ShelfDragCallback::ProcessScroll, |
674 base::Unretained(&handler))); | 634 base::Unretained(&handler))); |
675 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 635 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
676 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 636 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
677 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); | 637 EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
678 | 638 |
679 // Close actually, otherwise further event may be affected since widget | 639 // Close actually, otherwise further event may be affected since widget |
680 // is fullscreen status. | 640 // is fullscreen status. |
681 widget->Close(); | 641 widget->Close(); |
682 RunAllPendingInMessageLoop(); | 642 RunAllPendingInMessageLoop(); |
683 | 643 |
684 // The shelf should be shown because there are no more visible windows. | 644 // The shelf should be shown because there are no more visible windows. |
685 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 645 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
686 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 646 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
687 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 647 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
688 | 648 |
689 // Swipe-up to hide. This should have no effect because there are no visible | 649 // Swipe-up to hide. This should have no effect because there are no visible |
690 // windows. | 650 // windows. |
691 end = below_start - delta; | 651 end = below_start - delta; |
692 generator.GestureScrollSequenceWithCallback( | 652 generator.GestureScrollSequenceWithCallback( |
693 below_start, | 653 below_start, end, kTimeDelta, kNumScrollSteps, |
694 end, | |
695 kTimeDelta, | |
696 kNumScrollSteps, | |
697 base::Bind(&ShelfDragCallback::ProcessScroll, | 654 base::Bind(&ShelfDragCallback::ProcessScroll, |
698 base::Unretained(&handler))); | 655 base::Unretained(&handler))); |
699 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 656 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
700 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 657 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
701 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 658 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
702 } | 659 } |
703 | 660 |
704 // Need to be implemented. http://crbug.com/111279. | 661 // Need to be implemented. http://crbug.com/111279. |
705 #if defined(OS_WIN) | 662 #if defined(OS_WIN) |
706 #define MAYBE_SetVisible DISABLED_SetVisible | 663 #define MAYBE_SetVisible DISABLED_SetVisible |
(...skipping 18 matching lines...) Expand all Loading... |
725 ASSERT_NE(-1, display.id()); | 682 ASSERT_NE(-1, display.id()); |
726 // Bottom inset should be the max of widget heights. | 683 // Bottom inset should be the max of widget heights. |
727 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); | 684 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
728 | 685 |
729 // Hide the shelf. | 686 // Hide the shelf. |
730 SetState(manager, SHELF_HIDDEN); | 687 SetState(manager, SHELF_HIDDEN); |
731 // Run the animation to completion. | 688 // Run the animation to completion. |
732 StepWidgetLayerAnimatorToEnd(shelf_widget); | 689 StepWidgetLayerAnimatorToEnd(shelf_widget); |
733 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); | 690 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
734 EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state()); | 691 EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state()); |
735 display = screen->GetDisplayNearestWindow( | 692 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
736 Shell::GetPrimaryRootWindow()); | |
737 | 693 |
738 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 694 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
739 | 695 |
740 // Make sure the bounds of the two widgets changed. | 696 // Make sure the bounds of the two widgets changed. |
741 EXPECT_GE(shelf_widget->GetNativeView()->bounds().y(), | 697 EXPECT_GE(shelf_widget->GetNativeView()->bounds().y(), |
742 screen->GetPrimaryDisplay().bounds().bottom()); | 698 screen->GetPrimaryDisplay().bounds().bottom()); |
743 EXPECT_GE(shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), | 699 EXPECT_GE(shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), |
744 screen->GetPrimaryDisplay().bounds().bottom()); | 700 screen->GetPrimaryDisplay().bounds().bottom()); |
745 | 701 |
746 // And show it again. | 702 // And show it again. |
747 SetState(manager, SHELF_VISIBLE); | 703 SetState(manager, SHELF_VISIBLE); |
748 // Run the animation to completion. | 704 // Run the animation to completion. |
749 StepWidgetLayerAnimatorToEnd(shelf_widget); | 705 StepWidgetLayerAnimatorToEnd(shelf_widget); |
750 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); | 706 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
751 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); | 707 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
752 display = screen->GetDisplayNearestWindow( | 708 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
753 Shell::GetPrimaryRootWindow()); | |
754 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); | 709 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
755 | 710 |
756 // Make sure the bounds of the two widgets changed. | 711 // Make sure the bounds of the two widgets changed. |
757 shelf_bounds = shelf_widget->GetNativeView()->bounds(); | 712 shelf_bounds = shelf_widget->GetNativeView()->bounds(); |
758 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); | 713 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); |
759 status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds(); | 714 status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds(); |
760 EXPECT_LT(status_bounds.y(), | 715 EXPECT_LT(status_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); |
761 screen->GetPrimaryDisplay().bounds().bottom()); | |
762 } | 716 } |
763 | 717 |
764 // Makes sure LayoutShelf invoked while animating cleans things up. | 718 // Makes sure LayoutShelf invoked while animating cleans things up. |
765 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { | 719 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
766 Shelf* shelf = GetShelf(); | 720 Shelf* shelf = GetShelf(); |
767 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 721 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
768 // Force an initial layout. | 722 // Force an initial layout. |
769 layout_manager->LayoutShelf(); | 723 layout_manager->LayoutShelf(); |
770 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 724 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
771 | 725 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 small_change); | 770 small_change); |
817 } | 771 } |
818 | 772 |
819 // Makes sure the shelf is sized when the status area changes size. | 773 // Makes sure the shelf is sized when the status area changes size. |
820 TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) { | 774 TEST_F(ShelfLayoutManagerTest, ShelfUpdatedWhenStatusAreaChangesSize) { |
821 Shelf* shelf = GetShelf(); | 775 Shelf* shelf = GetShelf(); |
822 ASSERT_TRUE(shelf); | 776 ASSERT_TRUE(shelf); |
823 ShelfWidget* shelf_widget = GetShelfWidget(); | 777 ShelfWidget* shelf_widget = GetShelfWidget(); |
824 ASSERT_TRUE(shelf_widget); | 778 ASSERT_TRUE(shelf_widget); |
825 ASSERT_TRUE(shelf_widget->status_area_widget()); | 779 ASSERT_TRUE(shelf_widget->status_area_widget()); |
826 shelf_widget->status_area_widget()->SetBounds( | 780 shelf_widget->status_area_widget()->SetBounds(gfx::Rect(0, 0, 200, 200)); |
827 gfx::Rect(0, 0, 200, 200)); | |
828 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - | 781 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - |
829 test::ShelfTestAPI(shelf).shelf_view()->width()); | 782 test::ShelfTestAPI(shelf).shelf_view()->width()); |
830 } | 783 } |
831 | 784 |
832 | |
833 #if defined(OS_WIN) | 785 #if defined(OS_WIN) |
834 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | 786 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
835 #define MAYBE_AutoHide DISABLED_AutoHide | 787 #define MAYBE_AutoHide DISABLED_AutoHide |
836 #else | 788 #else |
837 #define MAYBE_AutoHide AutoHide | 789 #define MAYBE_AutoHide AutoHide |
838 #endif | 790 #endif |
839 | 791 |
840 // Various assertions around auto-hide. | 792 // Various assertions around auto-hide. |
841 TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { | 793 TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { |
842 aura::Window* root = Shell::GetPrimaryRootWindow(); | 794 aura::Window* root = Shell::GetPrimaryRootWindow(); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 // LayoutShelf() forces the animation to completion, at which point the | 983 // LayoutShelf() forces the animation to completion, at which point the |
1032 // shelf should go off the screen. | 984 // shelf should go off the screen. |
1033 layout_manager->LayoutShelf(); | 985 layout_manager->LayoutShelf(); |
1034 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, | 986 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, |
1035 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 987 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
1036 | 988 |
1037 aura::Window* lock_container = Shell::GetContainer( | 989 aura::Window* lock_container = Shell::GetContainer( |
1038 Shell::GetPrimaryRootWindow(), kShellWindowId_LockScreenContainer); | 990 Shell::GetPrimaryRootWindow(), kShellWindowId_LockScreenContainer); |
1039 | 991 |
1040 views::Widget* lock_widget = new views::Widget; | 992 views::Widget* lock_widget = new views::Widget; |
1041 views::Widget::InitParams lock_params( | 993 views::Widget::InitParams lock_params(views::Widget::InitParams::TYPE_WINDOW); |
1042 views::Widget::InitParams::TYPE_WINDOW); | |
1043 lock_params.bounds = gfx::Rect(0, 0, 200, 200); | 994 lock_params.bounds = gfx::Rect(0, 0, 200, 200); |
1044 params.context = CurrentContext(); | 995 params.context = CurrentContext(); |
1045 lock_params.parent = lock_container; | 996 lock_params.parent = lock_container; |
1046 // Widget is now owned by the parent window. | 997 // Widget is now owned by the parent window. |
1047 lock_widget->Init(lock_params); | 998 lock_widget->Init(lock_params); |
1048 lock_widget->Maximize(); | 999 lock_widget->Maximize(); |
1049 lock_widget->Show(); | 1000 lock_widget->Show(); |
1050 | 1001 |
1051 // Lock the screen. | 1002 // Lock the screen. |
1052 LockScreen(); | 1003 LockScreen(); |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 return; | 1588 return; |
1638 | 1589 |
1639 UpdateDisplay("800x600,800x600"); | 1590 UpdateDisplay("800x600,800x600"); |
1640 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 1591 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
1641 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1592 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
1642 Shell::RootWindowControllerList root_window_controllers = | 1593 Shell::RootWindowControllerList root_window_controllers = |
1643 Shell::GetAllRootWindowControllers(); | 1594 Shell::GetAllRootWindowControllers(); |
1644 | 1595 |
1645 // Create windows on either display. | 1596 // Create windows on either display. |
1646 aura::Window* window1 = CreateTestWindow(); | 1597 aura::Window* window1 = CreateTestWindow(); |
1647 window1->SetBoundsInScreen( | 1598 window1->SetBoundsInScreen(gfx::Rect(0, 0, 100, 100), |
1648 gfx::Rect(0, 0, 100, 100), | 1599 display_manager->GetDisplayAt(0)); |
1649 display_manager->GetDisplayAt(0)); | |
1650 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 1600 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
1651 window1->Show(); | 1601 window1->Show(); |
1652 | 1602 |
1653 aura::Window* window2 = CreateTestWindow(); | 1603 aura::Window* window2 = CreateTestWindow(); |
1654 window2->SetBoundsInScreen( | 1604 window2->SetBoundsInScreen(gfx::Rect(800, 0, 100, 100), |
1655 gfx::Rect(800, 0, 100, 100), | 1605 display_manager->GetDisplayAt(1)); |
1656 display_manager->GetDisplayAt(1)); | |
1657 window2->Show(); | 1606 window2->Show(); |
1658 | 1607 |
1659 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 1608 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
1660 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | 1609 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); |
1661 | 1610 |
1662 wm::GetWindowState(window2)->Activate(); | 1611 wm::GetWindowState(window2)->Activate(); |
1663 EXPECT_EQ(SHELF_HIDDEN, | 1612 EXPECT_EQ( |
| 1613 SHELF_HIDDEN, |
1664 root_window_controllers[0]->GetShelfLayoutManager()->visibility_state()); | 1614 root_window_controllers[0]->GetShelfLayoutManager()->visibility_state()); |
1665 EXPECT_EQ(SHELF_VISIBLE, | 1615 EXPECT_EQ( |
| 1616 SHELF_VISIBLE, |
1666 root_window_controllers[1]->GetShelfLayoutManager()->visibility_state()); | 1617 root_window_controllers[1]->GetShelfLayoutManager()->visibility_state()); |
1667 } | 1618 } |
1668 | 1619 |
1669 // Test for Pinned mode. | 1620 // Test for Pinned mode. |
1670 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) { | 1621 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) { |
1671 Shelf* shelf = GetShelf(); | 1622 Shelf* shelf = GetShelf(); |
1672 | 1623 |
1673 aura::Window* window1 = CreateTestWindow(); | 1624 aura::Window* window1 = CreateTestWindow(); |
1674 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1625 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
1675 window1->Show(); | 1626 window1->Show(); |
(...skipping 17 matching lines...) Expand all Loading... |
1693 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). | 1644 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). |
1694 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { | 1645 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { |
1695 Shelf* shelf = GetShelf(); | 1646 Shelf* shelf = GetShelf(); |
1696 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1647 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
1697 // Force an initial layout. | 1648 // Force an initial layout. |
1698 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1649 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1699 layout_manager->LayoutShelf(); | 1650 layout_manager->LayoutShelf(); |
1700 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1651 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
1701 | 1652 |
1702 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1653 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
1703 gfx::Rect shelf_bounds( | 1654 gfx::Rect shelf_bounds(GetShelfWidget()->GetWindowBoundsInScreen()); |
1704 GetShelfWidget()->GetWindowBoundsInScreen()); | |
1705 const display::Screen* screen = display::Screen::GetScreen(); | 1655 const display::Screen* screen = display::Screen::GetScreen(); |
1706 display::Display display = | 1656 display::Display display = |
1707 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | 1657 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
1708 ASSERT_NE(-1, display.id()); | 1658 ASSERT_NE(-1, display.id()); |
1709 EXPECT_EQ(layout_manager->GetIdealBounds().width(), | 1659 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
1710 display.GetWorkAreaInsets().left()); | 1660 display.GetWorkAreaInsets().left()); |
1711 EXPECT_GE( | 1661 EXPECT_GE(shelf_bounds.width(), |
1712 shelf_bounds.width(), | 1662 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
1713 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); | |
1714 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); | 1663 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); |
1715 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); | 1664 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
1716 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); | 1665 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); |
1717 EXPECT_GE(status_bounds.width(), | 1666 EXPECT_GE(status_bounds.width(), |
1718 status_area_widget->GetContentsView()->GetPreferredSize().width()); | 1667 status_area_widget->GetContentsView()->GetPreferredSize().width()); |
1719 EXPECT_EQ(layout_manager->GetIdealBounds().width(), | 1668 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
1720 display.GetWorkAreaInsets().left()); | 1669 display.GetWorkAreaInsets().left()); |
1721 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 1670 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
1722 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 1671 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
1723 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); | 1672 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 // Enable animations so that we can make sure that they occur. | 1923 // Enable animations so that we can make sure that they occur. |
1975 ui::ScopedAnimationDurationScaleMode regular_animations( | 1924 ui::ScopedAnimationDurationScaleMode regular_animations( |
1976 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 1925 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
1977 | 1926 |
1978 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1927 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
1979 gfx::Rect shelf_bounds_in_screen = | 1928 gfx::Rect shelf_bounds_in_screen = |
1980 GetShelfWidget()->GetWindowBoundsInScreen(); | 1929 GetShelfWidget()->GetWindowBoundsInScreen(); |
1981 gfx::Point start(shelf_bounds_in_screen.CenterPoint()); | 1930 gfx::Point start(shelf_bounds_in_screen.CenterPoint()); |
1982 gfx::Point end(start.x(), shelf_bounds_in_screen.bottom()); | 1931 gfx::Point end(start.x(), shelf_bounds_in_screen.bottom()); |
1983 generator.GestureScrollSequence(start, end, | 1932 generator.GestureScrollSequence(start, end, |
1984 base::TimeDelta::FromMilliseconds(10), 5); | 1933 base::TimeDelta::FromMilliseconds(10), 5); |
1985 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1934 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
1986 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 1935 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
1987 | 1936 |
1988 ShelfAnimationWaiter waiter(visible_bounds); | 1937 ShelfAnimationWaiter waiter(visible_bounds); |
1989 // Wait till the animation completes and check that it occurred. | 1938 // Wait till the animation completes and check that it occurred. |
1990 waiter.WaitTillDoneAnimating(); | 1939 waiter.WaitTillDoneAnimating(); |
1991 EXPECT_TRUE(waiter.WasValidAnimation()); | 1940 EXPECT_TRUE(waiter.WasValidAnimation()); |
1992 } | 1941 } |
1993 | 1942 |
1994 // Create a visible window so auto-hide behavior is enforced. | 1943 // Create a visible window so auto-hide behavior is enforced. |
(...skipping 10 matching lines...) Expand all Loading... |
2005 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 1954 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
2006 | 1955 |
2007 gfx::Point start = | 1956 gfx::Point start = |
2008 GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); | 1957 GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
2009 gfx::Point end(start.x(), start.y() - 100); | 1958 gfx::Point end(start.x(), start.y() - 100); |
2010 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1959 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
2011 | 1960 |
2012 // Test that the shelf animates to the visible bounds after a swipe up on | 1961 // Test that the shelf animates to the visible bounds after a swipe up on |
2013 // the auto hidden shelf. | 1962 // the auto hidden shelf. |
2014 generator.GestureScrollSequence(start, end, | 1963 generator.GestureScrollSequence(start, end, |
2015 base::TimeDelta::FromMilliseconds(10), 1); | 1964 base::TimeDelta::FromMilliseconds(10), 1); |
2016 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1965 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
2017 ShelfAnimationWaiter waiter1(visible_bounds); | 1966 ShelfAnimationWaiter waiter1(visible_bounds); |
2018 waiter1.WaitTillDoneAnimating(); | 1967 waiter1.WaitTillDoneAnimating(); |
2019 EXPECT_TRUE(waiter1.WasValidAnimation()); | 1968 EXPECT_TRUE(waiter1.WasValidAnimation()); |
2020 | 1969 |
2021 // Test that the shelf animates to the auto hidden bounds after a swipe up | 1970 // Test that the shelf animates to the auto hidden bounds after a swipe up |
2022 // on the visible shelf. | 1971 // on the visible shelf. |
2023 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1972 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
2024 generator.GestureScrollSequence(start, end, | 1973 generator.GestureScrollSequence(start, end, |
2025 base::TimeDelta::FromMilliseconds(10), 1); | 1974 base::TimeDelta::FromMilliseconds(10), 1); |
2026 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1975 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
2027 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 1976 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
2028 ShelfAnimationWaiter waiter2(auto_hidden_bounds); | 1977 ShelfAnimationWaiter waiter2(auto_hidden_bounds); |
2029 waiter2.WaitTillDoneAnimating(); | 1978 waiter2.WaitTillDoneAnimating(); |
2030 EXPECT_TRUE(waiter2.WasValidAnimation()); | 1979 EXPECT_TRUE(waiter2.WasValidAnimation()); |
2031 } | 1980 } |
2032 } | 1981 } |
2033 | 1982 |
2034 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { | 1983 TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { |
2035 Shelf* shelf = GetShelf(); | 1984 Shelf* shelf = GetShelf(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2151 status_area_widget->GetWindowBoundsInScreen().CenterPoint(); | 2100 status_area_widget->GetWindowBoundsInScreen().CenterPoint(); |
2152 generator.MoveMouseTo(center.x(), center.y()); | 2101 generator.MoveMouseTo(center.x(), center.y()); |
2153 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 2102 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
2154 EXPECT_TRUE(layout_manager->IsVisible()); | 2103 EXPECT_TRUE(layout_manager->IsVisible()); |
2155 if (!i) { | 2104 if (!i) { |
2156 // In our first iteration we make sure there is no bubble. | 2105 // In our first iteration we make sure there is no bubble. |
2157 tray->CloseSystemBubble(); | 2106 tray->CloseSystemBubble(); |
2158 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2107 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
2159 } else { | 2108 } else { |
2160 // In our second iteration we show a bubble. | 2109 // In our second iteration we show a bubble. |
2161 TestItem *item = new TestItem; | 2110 TestItem* item = new TestItem; |
2162 tray->AddTrayItem(item); | 2111 tray->AddTrayItem(item); |
2163 tray->ShowNotificationView(item); | 2112 tray->ShowNotificationView(item); |
2164 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2113 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
2165 } | 2114 } |
2166 // Move the pointer over the edge of the shelf. | 2115 // Move the pointer over the edge of the shelf. |
2167 generator.MoveMouseTo( | 2116 generator.MoveMouseTo( |
2168 center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8); | 2117 center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8); |
2169 layout_manager->UpdateVisibilityState(); | 2118 layout_manager->UpdateVisibilityState(); |
2170 if (i) { | 2119 if (i) { |
2171 EXPECT_TRUE(layout_manager->IsVisible()); | 2120 EXPECT_TRUE(layout_manager->IsVisible()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2228 #endif | 2177 #endif |
2229 | 2178 |
2230 // Verify the hit bounds of the status area extend to the edge of the shelf. | 2179 // Verify the hit bounds of the status area extend to the edge of the shelf. |
2231 TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { | 2180 TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { |
2232 UpdateDisplay("400x400"); | 2181 UpdateDisplay("400x400"); |
2233 Shelf* shelf = GetShelf(); | 2182 Shelf* shelf = GetShelf(); |
2234 StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() | 2183 StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() |
2235 ->shelf_widget() | 2184 ->shelf_widget() |
2236 ->status_area_widget(); | 2185 ->status_area_widget(); |
2237 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 2186 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
2238 generator.MoveMouseTo(399,399); | 2187 generator.MoveMouseTo(399, 399); |
2239 | 2188 |
2240 // Test bottom right pixel for bottom alignment. | 2189 // Test bottom right pixel for bottom alignment. |
2241 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2190 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
2242 generator.ClickLeftButton(); | 2191 generator.ClickLeftButton(); |
2243 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2192 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
2244 generator.ClickLeftButton(); | 2193 generator.ClickLeftButton(); |
2245 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2194 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
2246 | 2195 |
2247 // Test bottom right pixel for right alignment. | 2196 // Test bottom right pixel for right alignment. |
2248 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 2197 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
(...skipping 11 matching lines...) Expand all Loading... |
2260 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 2209 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
2261 generator.ClickLeftButton(); | 2210 generator.ClickLeftButton(); |
2262 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 2211 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
2263 } | 2212 } |
2264 | 2213 |
2265 // Tests that when the auto-hide behaviour is changed during an animation the | 2214 // Tests that when the auto-hide behaviour is changed during an animation the |
2266 // target bounds are updated to reflect the new state. | 2215 // target bounds are updated to reflect the new state. |
2267 TEST_F(ShelfLayoutManagerTest, | 2216 TEST_F(ShelfLayoutManagerTest, |
2268 ShelfAutoHideToggleDuringAnimationUpdatesBounds) { | 2217 ShelfAutoHideToggleDuringAnimationUpdatesBounds) { |
2269 Shelf* shelf = GetShelf(); | 2218 Shelf* shelf = GetShelf(); |
2270 aura::Window* status_window = GetShelfWidget()->status_area_widget()-> | 2219 aura::Window* status_window = |
2271 GetNativeView(); | 2220 GetShelfWidget()->status_area_widget()->GetNativeView(); |
2272 gfx::Rect initial_bounds = status_window->bounds(); | 2221 gfx::Rect initial_bounds = status_window->bounds(); |
2273 | 2222 |
2274 ui::ScopedAnimationDurationScaleMode regular_animations( | 2223 ui::ScopedAnimationDurationScaleMode regular_animations( |
2275 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); | 2224 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); |
2276 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); | 2225 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); |
2277 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); | 2226 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); |
2278 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); | 2227 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); |
2279 | 2228 |
2280 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 2229 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
2281 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); | 2230 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); |
2282 EXPECT_EQ(initial_bounds, reshow_target_bounds); | 2231 EXPECT_EQ(initial_bounds, reshow_target_bounds); |
2283 } | 2232 } |
2284 | 2233 |
2285 // Tests that during shutdown, that window activation changes are properly | 2234 // Tests that during shutdown, that window activation changes are properly |
2286 // handled, and do not crash (crbug.com/458768) | 2235 // handled, and do not crash (crbug.com/458768) |
2287 TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) { | 2236 TEST_F(ShelfLayoutManagerTest, ShutdownHandlesWindowActivation) { |
(...skipping 28 matching lines...) Expand all Loading... |
2316 ->shelf_widget() | 2265 ->shelf_widget() |
2317 ->status_area_widget(); | 2266 ->status_area_widget(); |
2318 EXPECT_TRUE(status_area_widget->IsVisible()); | 2267 EXPECT_TRUE(status_area_widget->IsVisible()); |
2319 // Shelf should be in the first display's area. | 2268 // Shelf should be in the first display's area. |
2320 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 2269 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
2321 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 2270 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
2322 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 2271 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
2323 } | 2272 } |
2324 | 2273 |
2325 } // namespace ash | 2274 } // namespace ash |
OLD | NEW |