Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ash/shelf/shelf_layout_manager.h" |
| 6 | |
| 7 | #include "ash/accelerators/accelerator_controller.h" |
| 8 | #include "ash/accelerators/accelerator_table.h" |
| 9 | #include "ash/ash_switches.h" |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 10 | #include "ash/display/display_controller.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 11 | #include "ash/display/display_manager.h" |
| 12 | #include "ash/focus_cycler.h" |
| 13 | #include "ash/launcher/launcher.h" |
| 14 | #include "ash/launcher/launcher_view.h" |
| 15 | #include "ash/root_window_controller.h" |
| 16 | #include "ash/screen_ash.h" |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 17 | #include "ash/session_state_delegate.h" |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 18 | #include "ash/shelf/shelf_layout_manager_observer.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 19 | #include "ash/shelf/shelf_widget.h" |
| 20 | #include "ash/shell.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 21 | #include "ash/shell_window_ids.h" |
| 22 | #include "ash/system/status_area_widget.h" |
| 23 | #include "ash/system/tray/system_tray.h" |
| 24 | #include "ash/system/tray/system_tray_item.h" |
| 25 | #include "ash/test/ash_test_base.h" |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 26 | #include "ash/wm/window_properties.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 27 | #include "ash/wm/window_util.h" |
| 28 | #include "base/command_line.h" |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 29 | #include "base/strings/utf_string_conversions.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 30 | #include "ui/aura/client/aura_constants.h" |
| 31 | #include "ui/aura/root_window.h" |
| 32 | #include "ui/aura/test/event_generator.h" |
| 33 | #include "ui/aura/window.h" |
| 34 | #include "ui/base/animation/animation_container_element.h" |
| 35 | #include "ui/compositor/layer.h" |
| 36 | #include "ui/compositor/layer_animator.h" |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 37 | #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 38 | #include "ui/gfx/display.h" |
| 39 | #include "ui/gfx/screen.h" |
| 40 | #include "ui/views/controls/label.h" |
| 41 | #include "ui/views/layout/fill_layout.h" |
| 42 | #include "ui/views/view.h" |
| 43 | #include "ui/views/widget/widget.h" |
| 44 | |
| 45 | #if defined(OS_WIN) |
| 46 | #include "base/win/windows_version.h" |
| 47 | #endif |
| 48 | |
| 49 | namespace ash { |
| 50 | namespace internal { |
| 51 | |
| 52 | namespace { |
| 53 | |
| 54 | void StepWidgetLayerAnimatorToEnd(views::Widget* widget) { |
| 55 | ui::AnimationContainerElement* element = |
| 56 | static_cast<ui::AnimationContainerElement*>( |
| 57 | widget->GetNativeView()->layer()->GetAnimator()); |
| 58 | element->Step(base::TimeTicks::Now() + base::TimeDelta::FromSeconds(1)); |
| 59 | } |
| 60 | |
| 61 | ShelfWidget* GetShelfWidget() { |
| 62 | return Shell::GetPrimaryRootWindowController()->shelf(); |
| 63 | } |
| 64 | |
| 65 | ShelfLayoutManager* GetShelfLayoutManager() { |
| 66 | return Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 67 | } |
| 68 | |
| 69 | SystemTray* GetSystemTray() { |
| 70 | return Shell::GetPrimaryRootWindowController()->GetSystemTray(); |
| 71 | } |
| 72 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 73 | class ShelfDragCallback { |
| 74 | public: |
| 75 | ShelfDragCallback(const gfx::Rect& not_visible, const gfx::Rect& visible) |
| 76 | : not_visible_bounds_(not_visible), |
| 77 | visible_bounds_(visible), |
| 78 | was_visible_on_drag_start_(false) { |
| 79 | EXPECT_EQ(not_visible_bounds_.bottom(), visible_bounds_.bottom()); |
| 80 | } |
| 81 | |
| 82 | virtual ~ShelfDragCallback() { |
| 83 | } |
| 84 | |
| 85 | void ProcessScroll(ui::EventType type, const gfx::Vector2dF& delta) { |
| 86 | if (GetShelfLayoutManager()->visibility_state() == ash::SHELF_HIDDEN) |
| 87 | return; |
| 88 | |
| 89 | if (type == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 90 | scroll_ = gfx::Vector2dF(); |
| 91 | was_visible_on_drag_start_ = GetShelfLayoutManager()->IsVisible(); |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | // The state of the shelf at the end of the gesture is tested separately. |
| 96 | if (type == ui::ET_GESTURE_SCROLL_END) |
| 97 | return; |
| 98 | |
| 99 | if (type == ui::ET_GESTURE_SCROLL_UPDATE) |
| 100 | scroll_.Add(delta); |
| 101 | |
| 102 | gfx::Rect shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 103 | if (GetShelfLayoutManager()->IsHorizontalAlignment()) { |
| 104 | EXPECT_EQ(not_visible_bounds_.bottom(), shelf_bounds.bottom()); |
| 105 | EXPECT_EQ(visible_bounds_.bottom(), shelf_bounds.bottom()); |
| 106 | } else if (SHELF_ALIGNMENT_RIGHT == |
| 107 | GetShelfLayoutManager()->GetAlignment()){ |
| 108 | EXPECT_EQ(not_visible_bounds_.right(), shelf_bounds.right()); |
| 109 | EXPECT_EQ(visible_bounds_.right(), shelf_bounds.right()); |
| 110 | } else if (SHELF_ALIGNMENT_LEFT == |
| 111 | GetShelfLayoutManager()->GetAlignment()) { |
| 112 | EXPECT_EQ(not_visible_bounds_.x(), shelf_bounds.x()); |
| 113 | EXPECT_EQ(visible_bounds_.x(), shelf_bounds.x()); |
| 114 | } |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 115 | |
| 116 | // if the shelf is being dimmed test dimmer bounds as well. |
| 117 | if (GetShelfWidget()->GetDimsShelf()) |
| 118 | EXPECT_EQ(GetShelfWidget()->GetWindowBoundsInScreen(), |
| 119 | GetShelfWidget()->GetDimmerBoundsForTest()); |
| 120 | |
| 121 | // The shelf should never be smaller than the hidden state. |
| 122 | EXPECT_GE(shelf_bounds.height(), not_visible_bounds_.height()); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 123 | float scroll_delta = GetShelfLayoutManager()->PrimaryAxisValue( |
| 124 | scroll_.y(), |
| 125 | scroll_.x()); |
| 126 | bool increasing_drag = |
| 127 | GetShelfLayoutManager()->SelectValueForShelfAlignment( |
| 128 | scroll_delta < 0, |
| 129 | scroll_delta > 0, |
| 130 | scroll_delta < 0, |
| 131 | scroll_delta > 0); |
| 132 | int shelf_size = GetShelfLayoutManager()->PrimaryAxisValue( |
| 133 | shelf_bounds.height(), |
| 134 | shelf_bounds.width()); |
| 135 | int visible_bounds_size = GetShelfLayoutManager()->PrimaryAxisValue( |
| 136 | visible_bounds_.height(), |
| 137 | visible_bounds_.width()); |
| 138 | int not_visible_bounds_size = GetShelfLayoutManager()->PrimaryAxisValue( |
| 139 | not_visible_bounds_.height(), |
| 140 | not_visible_bounds_.width()); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 141 | if (was_visible_on_drag_start_) { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 142 | if (increasing_drag) { |
| 143 | // If dragging inwards from the visible state, then the shelf should |
| 144 | // increase in size, but not more than the scroll delta. |
| 145 | EXPECT_LE(visible_bounds_size, shelf_size); |
| 146 | EXPECT_LE(abs(shelf_size - visible_bounds_size), |
| 147 | abs(scroll_delta)); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 148 | } else { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 149 | if (shelf_size > not_visible_bounds_size) { |
| 150 | // If dragging outwards from the visible state, then the shelf |
| 151 | // should decrease in size, until it reaches the minimum size. |
| 152 | EXPECT_EQ(shelf_size, visible_bounds_size - abs(scroll_delta)); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 153 | } |
| 154 | } |
| 155 | } else { |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 156 | if (fabs(scroll_delta) < |
| 157 | visible_bounds_size - not_visible_bounds_size) { |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 158 | // Tests that the shelf sticks with the touch point during the drag |
| 159 | // until the shelf is completely visible. |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 160 | EXPECT_EQ(shelf_size, not_visible_bounds_size + abs(scroll_delta)); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 161 | } else { |
| 162 | // Tests that after the shelf is completely visible, the shelf starts |
| 163 | // resisting the drag. |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 164 | EXPECT_LT(shelf_size, not_visible_bounds_size + abs(scroll_delta)); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 165 | } |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | private: |
| 170 | const gfx::Rect not_visible_bounds_; |
| 171 | const gfx::Rect visible_bounds_; |
| 172 | gfx::Vector2dF scroll_; |
| 173 | bool was_visible_on_drag_start_; |
| 174 | |
| 175 | DISALLOW_COPY_AND_ASSIGN(ShelfDragCallback); |
| 176 | }; |
| 177 | |
Torne (Richard Coles) | b2df76e | 2013-05-13 16:52:09 +0100 | [diff] [blame] | 178 | class ShelfLayoutObserverTest : public ShelfLayoutManagerObserver { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 179 | public: |
| 180 | ShelfLayoutObserverTest() |
| 181 | : changed_auto_hide_state_(false) { |
| 182 | } |
| 183 | |
| 184 | virtual ~ShelfLayoutObserverTest() {} |
| 185 | |
| 186 | bool changed_auto_hide_state() const { return changed_auto_hide_state_; } |
| 187 | |
| 188 | private: |
| 189 | virtual void OnAutoHideStateChanged( |
| 190 | ShelfAutoHideState new_state) OVERRIDE { |
| 191 | changed_auto_hide_state_ = true; |
| 192 | } |
| 193 | |
| 194 | bool changed_auto_hide_state_; |
| 195 | |
| 196 | DISALLOW_COPY_AND_ASSIGN(ShelfLayoutObserverTest); |
| 197 | }; |
| 198 | |
| 199 | // Trivial item implementation that tracks its views for testing. |
| 200 | class TestItem : public SystemTrayItem { |
| 201 | public: |
| 202 | TestItem() |
| 203 | : SystemTrayItem(GetSystemTray()), |
| 204 | tray_view_(NULL), |
| 205 | default_view_(NULL), |
| 206 | detailed_view_(NULL), |
| 207 | notification_view_(NULL) {} |
| 208 | |
| 209 | virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE { |
| 210 | tray_view_ = new views::View; |
| 211 | // Add a label so it has non-zero width. |
| 212 | tray_view_->SetLayoutManager(new views::FillLayout); |
| 213 | tray_view_->AddChildView(new views::Label(UTF8ToUTF16("Tray"))); |
| 214 | return tray_view_; |
| 215 | } |
| 216 | |
| 217 | virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE { |
| 218 | default_view_ = new views::View; |
| 219 | default_view_->SetLayoutManager(new views::FillLayout); |
| 220 | default_view_->AddChildView(new views::Label(UTF8ToUTF16("Default"))); |
| 221 | return default_view_; |
| 222 | } |
| 223 | |
| 224 | virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE { |
| 225 | detailed_view_ = new views::View; |
| 226 | detailed_view_->SetLayoutManager(new views::FillLayout); |
| 227 | detailed_view_->AddChildView(new views::Label(UTF8ToUTF16("Detailed"))); |
| 228 | return detailed_view_; |
| 229 | } |
| 230 | |
| 231 | virtual views::View* CreateNotificationView( |
| 232 | user::LoginStatus status) OVERRIDE { |
| 233 | notification_view_ = new views::View; |
| 234 | return notification_view_; |
| 235 | } |
| 236 | |
| 237 | virtual void DestroyTrayView() OVERRIDE { |
| 238 | tray_view_ = NULL; |
| 239 | } |
| 240 | |
| 241 | virtual void DestroyDefaultView() OVERRIDE { |
| 242 | default_view_ = NULL; |
| 243 | } |
| 244 | |
| 245 | virtual void DestroyDetailedView() OVERRIDE { |
| 246 | detailed_view_ = NULL; |
| 247 | } |
| 248 | |
| 249 | virtual void DestroyNotificationView() OVERRIDE { |
| 250 | notification_view_ = NULL; |
| 251 | } |
| 252 | |
| 253 | virtual void UpdateAfterLoginStatusChange( |
| 254 | user::LoginStatus status) OVERRIDE {} |
| 255 | |
| 256 | views::View* tray_view() const { return tray_view_; } |
| 257 | views::View* default_view() const { return default_view_; } |
| 258 | views::View* detailed_view() const { return detailed_view_; } |
| 259 | views::View* notification_view() const { return notification_view_; } |
| 260 | |
| 261 | private: |
| 262 | views::View* tray_view_; |
| 263 | views::View* default_view_; |
| 264 | views::View* detailed_view_; |
| 265 | views::View* notification_view_; |
| 266 | |
| 267 | DISALLOW_COPY_AND_ASSIGN(TestItem); |
| 268 | }; |
| 269 | |
| 270 | } // namespace |
| 271 | |
| 272 | class ShelfLayoutManagerTest : public ash::test::AshTestBase { |
| 273 | public: |
| 274 | ShelfLayoutManagerTest() {} |
| 275 | |
| 276 | void SetState(ShelfLayoutManager* shelf, |
| 277 | ShelfVisibilityState state) { |
| 278 | shelf->SetState(state); |
| 279 | } |
| 280 | |
| 281 | void UpdateAutoHideStateNow() { |
| 282 | GetShelfLayoutManager()->UpdateAutoHideStateNow(); |
| 283 | } |
| 284 | |
| 285 | aura::Window* CreateTestWindow() { |
| 286 | aura::Window* window = new aura::Window(NULL); |
| 287 | window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 288 | window->SetType(aura::client::WINDOW_TYPE_NORMAL); |
| 289 | window->Init(ui::LAYER_TEXTURED); |
| 290 | SetDefaultParentByPrimaryRootWindow(window); |
| 291 | return window; |
| 292 | } |
| 293 | |
| 294 | views::Widget* CreateTestWidgetWithParams( |
| 295 | const views::Widget::InitParams& params) { |
| 296 | views::Widget* out = new views::Widget; |
| 297 | out->Init(params); |
| 298 | out->Show(); |
| 299 | return out; |
| 300 | } |
| 301 | |
| 302 | // Create a simple widget attached to the current context (will |
| 303 | // delete on TearDown). |
| 304 | views::Widget* CreateTestWidget() { |
| 305 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 306 | params.bounds = gfx::Rect(0, 0, 200, 200); |
| 307 | params.context = CurrentContext(); |
| 308 | return CreateTestWidgetWithParams(params); |
| 309 | } |
| 310 | |
| 311 | // Overridden from AshTestBase: |
| 312 | virtual void SetUp() OVERRIDE { |
| 313 | CommandLine::ForCurrentProcess()->AppendSwitch( |
| 314 | ash::switches::kAshEnableTrayDragging); |
| 315 | test::AshTestBase::SetUp(); |
| 316 | } |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 317 | |
| 318 | void RunGestureDragTests(gfx::Vector2d); |
| 319 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 320 | private: |
| 321 | DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); |
| 322 | }; |
| 323 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 324 | void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { |
| 325 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 326 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 327 | views::Widget* widget = new views::Widget; |
| 328 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 329 | params.bounds = gfx::Rect(0, 0, 200, 200); |
| 330 | params.context = CurrentContext(); |
| 331 | widget->Init(params); |
| 332 | widget->Show(); |
| 333 | widget->Maximize(); |
| 334 | |
| 335 | aura::Window* window = widget->GetNativeWindow(); |
| 336 | shelf->LayoutShelf(); |
| 337 | |
| 338 | gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 339 | gfx::Rect bounds_shelf = window->bounds(); |
| 340 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 341 | |
| 342 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 343 | shelf->LayoutShelf(); |
| 344 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 345 | |
| 346 | gfx::Rect bounds_noshelf = window->bounds(); |
| 347 | gfx::Rect shelf_hidden = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 348 | |
| 349 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 350 | shelf->LayoutShelf(); |
| 351 | |
| 352 | aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 353 | const int kNumScrollSteps = 10; |
| 354 | ShelfDragCallback handler(shelf_hidden, shelf_shown); |
| 355 | |
| 356 | // Swipe up on the shelf. This should not change any state. |
| 357 | gfx::Point start = GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
| 358 | gfx::Point end = start + delta; |
| 359 | |
| 360 | // Swipe down on the shelf to hide it. |
| 361 | generator.GestureScrollSequenceWithCallback(start, end, |
| 362 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 363 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 364 | base::Unretained(&handler))); |
| 365 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 366 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 367 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 368 | EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString()); |
| 369 | EXPECT_NE(shelf_shown.ToString(), |
| 370 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 371 | |
| 372 | // Swipe up to show the shelf. |
| 373 | generator.GestureScrollSequenceWithCallback(end, start, |
| 374 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 375 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 376 | base::Unretained(&handler))); |
| 377 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 378 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 379 | EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 380 | EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), |
| 381 | GetShelfWidget()->GetWindowBoundsInScreen()); |
| 382 | EXPECT_EQ(shelf_shown.ToString(), |
| 383 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 384 | |
| 385 | // Swipe up again. The shelf should hide. |
| 386 | end = start - delta; |
| 387 | generator.GestureScrollSequenceWithCallback(start, end, |
| 388 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 389 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 390 | base::Unretained(&handler))); |
| 391 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 392 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 393 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 394 | EXPECT_EQ(shelf_hidden.ToString(), |
| 395 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 396 | |
| 397 | // Swipe up yet again to show it. |
| 398 | end = start + delta; |
| 399 | generator.GestureScrollSequenceWithCallback(end, start, |
| 400 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 401 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 402 | base::Unretained(&handler))); |
| 403 | |
| 404 | // Swipe down very little. It shouldn't change any state. |
| 405 | if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
| 406 | end.set_y(start.y() + shelf_shown.height() * 3 / 10); |
| 407 | else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
| 408 | end.set_x(start.x() - shelf_shown.width() * 3 / 10); |
| 409 | else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
| 410 | end.set_x(start.x() + shelf_shown.width() * 3 / 10); |
| 411 | generator.GestureScrollSequenceWithCallback(start, end, |
| 412 | base::TimeDelta::FromMilliseconds(100), 1, |
| 413 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 414 | base::Unretained(&handler))); |
| 415 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 416 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 417 | EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 418 | EXPECT_EQ(shelf_shown.ToString(), |
| 419 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 420 | |
| 421 | // Swipe down again to hide. |
| 422 | end = start + delta; |
| 423 | generator.GestureScrollSequenceWithCallback(start, end, |
| 424 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 425 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 426 | base::Unretained(&handler))); |
| 427 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 428 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 429 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 430 | EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); |
| 431 | EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
| 432 | EXPECT_EQ(shelf_hidden.ToString(), |
| 433 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 434 | |
| 435 | // Swipe up in extended hit region to show it. |
| 436 | gfx::Point extended_start = start; |
| 437 | if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
| 438 | extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() -1); |
| 439 | else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
| 440 | extended_start.set_x( |
| 441 | GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); |
| 442 | else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
| 443 | extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
| 444 | end = extended_start - delta; |
| 445 | generator.GestureScrollSequenceWithCallback(extended_start, end, |
| 446 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 447 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 448 | base::Unretained(&handler))); |
| 449 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 450 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 451 | EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 452 | EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), |
| 453 | GetShelfWidget()->GetWindowBoundsInScreen()); |
| 454 | EXPECT_EQ(shelf_shown.ToString(), |
| 455 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 456 | |
| 457 | // Swipe down again to hide. |
| 458 | end = start + delta; |
| 459 | generator.GestureScrollSequenceWithCallback(start, end, |
| 460 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 461 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 462 | base::Unretained(&handler))); |
| 463 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 464 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 465 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 466 | EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); |
| 467 | EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
| 468 | EXPECT_EQ(shelf_hidden.ToString(), |
| 469 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 470 | |
| 471 | // Swipe up outside the hit area. This should not change anything. |
| 472 | gfx::Point outside_start = gfx::Point( |
| 473 | (GetShelfWidget()->GetWindowBoundsInScreen().x() + |
| 474 | GetShelfWidget()->GetWindowBoundsInScreen().right())/2, |
| 475 | GetShelfWidget()->GetWindowBoundsInScreen().y() - 50); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 476 | end = outside_start + delta; |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 477 | generator.GestureScrollSequence(outside_start, |
| 478 | end, |
| 479 | base::TimeDelta::FromMilliseconds(10), |
| 480 | kNumScrollSteps); |
| 481 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 482 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 483 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 484 | EXPECT_EQ(shelf_hidden.ToString(), |
| 485 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 486 | |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 487 | // Swipe up from below the shelf where a bezel would be, this should show the |
| 488 | // shelf. |
| 489 | gfx::Point below_start = start; |
| 490 | if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
| 491 | below_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().bottom() + 1); |
| 492 | else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
| 493 | below_start.set_x( |
| 494 | GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
| 495 | else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
| 496 | below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); |
| 497 | end = below_start - delta; |
| 498 | generator.GestureScrollSequence(below_start, |
| 499 | end, |
| 500 | base::TimeDelta::FromMilliseconds(10), |
| 501 | kNumScrollSteps); |
| 502 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 503 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 504 | EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 505 | EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), |
| 506 | GetShelfWidget()->GetWindowBoundsInScreen()); |
| 507 | EXPECT_EQ(shelf_shown.ToString(), |
| 508 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 509 | |
| 510 | // Swipe down again to hide. |
| 511 | end = start + delta; |
| 512 | generator.GestureScrollSequenceWithCallback(start, end, |
| 513 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 514 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 515 | base::Unretained(&handler))); |
| 516 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 517 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 518 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 519 | EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); |
| 520 | EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
| 521 | EXPECT_EQ(shelf_hidden.ToString(), |
| 522 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 523 | |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 524 | // Enter into fullscreen with minimal chrome (immersive fullscreen). |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 525 | widget->SetFullscreen(true); |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 526 | window->SetProperty(ash::internal::kFullscreenUsesMinimalChromeKey, true); |
| 527 | shelf->UpdateVisibilityState(); |
| 528 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 529 | gfx::Rect bounds_fullscreen = window->bounds(); |
| 530 | EXPECT_TRUE(widget->IsFullscreen()); |
| 531 | EXPECT_NE(bounds_noshelf.ToString(), bounds_fullscreen.ToString()); |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 532 | |
| 533 | // Swipe up. This should show the shelf. |
| 534 | end = below_start - delta; |
| 535 | generator.GestureScrollSequenceWithCallback(below_start, end, |
| 536 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 537 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 538 | base::Unretained(&handler))); |
| 539 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 540 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 541 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 542 | EXPECT_EQ(shelf_shown.ToString(), |
| 543 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 544 | EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
| 545 | |
| 546 | // Swipe up again. This should hide the shelf. |
| 547 | generator.GestureScrollSequenceWithCallback(below_start, end, |
| 548 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 549 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 550 | base::Unretained(&handler))); |
| 551 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 552 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 553 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 554 | EXPECT_EQ(shelf_hidden.ToString(), |
| 555 | GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 556 | EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
| 557 | |
| 558 | // Put the window into fullscreen without any chrome at all (eg tab |
| 559 | // fullscreen). |
| 560 | window->SetProperty(ash::internal::kFullscreenUsesMinimalChromeKey, false); |
| 561 | shelf->UpdateVisibilityState(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 562 | EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 563 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 564 | |
| 565 | // Swipe-up. This should not change anything. |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 566 | end = start - delta; |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 567 | generator.GestureScrollSequenceWithCallback(below_start, end, |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 568 | base::TimeDelta::FromMilliseconds(10), kNumScrollSteps, |
| 569 | base::Bind(&ShelfDragCallback::ProcessScroll, |
| 570 | base::Unretained(&handler))); |
| 571 | EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 572 | EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 573 | EXPECT_EQ(bounds_fullscreen.ToString(), window->bounds().ToString()); |
| 574 | |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 575 | // Close actually, otherwise further event may be affected since widget |
| 576 | // is fullscreen status. |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 577 | widget->Close(); |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 578 | RunAllPendingInMessageLoop(); |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 579 | } |
| 580 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 581 | // Fails on Mac only. Need to be implemented. http://crbug.com/111279. |
| 582 | #if defined(OS_MACOSX) || defined(OS_WIN) |
| 583 | #define MAYBE_SetVisible DISABLED_SetVisible |
| 584 | #else |
| 585 | #define MAYBE_SetVisible SetVisible |
| 586 | #endif |
| 587 | // Makes sure SetVisible updates work area and widget appropriately. |
| 588 | TEST_F(ShelfLayoutManagerTest, MAYBE_SetVisible) { |
| 589 | ShelfWidget* shelf = GetShelfWidget(); |
| 590 | ShelfLayoutManager* manager = shelf->shelf_layout_manager(); |
| 591 | // Force an initial layout. |
| 592 | manager->LayoutShelf(); |
| 593 | EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
| 594 | |
| 595 | gfx::Rect status_bounds( |
| 596 | shelf->status_area_widget()->GetWindowBoundsInScreen()); |
| 597 | gfx::Rect launcher_bounds( |
| 598 | shelf->GetWindowBoundsInScreen()); |
| 599 | int shelf_height = manager->GetIdealBounds().height(); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 600 | gfx::Screen* screen = Shell::GetScreen(); |
| 601 | gfx::Display display = screen->GetDisplayNearestWindow( |
| 602 | Shell::GetPrimaryRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 603 | ASSERT_NE(-1, display.id()); |
| 604 | // Bottom inset should be the max of widget heights. |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 605 | EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 606 | |
| 607 | // Hide the shelf. |
| 608 | SetState(manager, SHELF_HIDDEN); |
| 609 | // Run the animation to completion. |
| 610 | StepWidgetLayerAnimatorToEnd(shelf); |
| 611 | StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); |
| 612 | EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state()); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 613 | display = screen->GetDisplayNearestWindow( |
| 614 | Shell::GetPrimaryRootWindow()); |
| 615 | |
| 616 | EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 617 | |
| 618 | // Make sure the bounds of the two widgets changed. |
| 619 | EXPECT_GE(shelf->GetNativeView()->bounds().y(), |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 620 | screen->GetPrimaryDisplay().bounds().bottom()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 621 | EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(), |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 622 | screen->GetPrimaryDisplay().bounds().bottom()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 623 | |
| 624 | // And show it again. |
| 625 | SetState(manager, SHELF_VISIBLE); |
| 626 | // Run the animation to completion. |
| 627 | StepWidgetLayerAnimatorToEnd(shelf); |
| 628 | StepWidgetLayerAnimatorToEnd(shelf->status_area_widget()); |
| 629 | EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 630 | display = screen->GetDisplayNearestWindow( |
| 631 | Shell::GetPrimaryRootWindow()); |
| 632 | EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 633 | |
| 634 | // Make sure the bounds of the two widgets changed. |
| 635 | launcher_bounds = shelf->GetNativeView()->bounds(); |
| 636 | int bottom = |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 637 | screen->GetPrimaryDisplay().bounds().bottom() - shelf_height; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 638 | EXPECT_EQ(launcher_bounds.y(), |
| 639 | bottom + (manager->GetIdealBounds().height() - |
| 640 | launcher_bounds.height()) / 2); |
| 641 | status_bounds = shelf->status_area_widget()->GetNativeView()->bounds(); |
| 642 | EXPECT_EQ(status_bounds.y(), |
| 643 | bottom + shelf_height - status_bounds.height()); |
| 644 | } |
| 645 | |
| 646 | // Makes sure LayoutShelf invoked while animating cleans things up. |
| 647 | TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
| 648 | ShelfWidget* shelf = GetShelfWidget(); |
| 649 | // Force an initial layout. |
| 650 | shelf->shelf_layout_manager()->LayoutShelf(); |
| 651 | EXPECT_EQ(SHELF_VISIBLE, shelf->shelf_layout_manager()->visibility_state()); |
| 652 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 653 | // Hide the shelf. |
| 654 | SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); |
| 655 | shelf->shelf_layout_manager()->LayoutShelf(); |
| 656 | EXPECT_EQ(SHELF_HIDDEN, shelf->shelf_layout_manager()->visibility_state()); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 657 | gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( |
| 658 | Shell::GetPrimaryRootWindow()); |
| 659 | EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 660 | |
| 661 | // Make sure the bounds of the two widgets changed. |
| 662 | EXPECT_GE(shelf->GetNativeView()->bounds().y(), |
| 663 | Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
| 664 | EXPECT_GE(shelf->status_area_widget()->GetNativeView()->bounds().y(), |
| 665 | Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom()); |
| 666 | } |
| 667 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 668 | // Test that switching to a different visibility state does not restart the |
| 669 | // shelf show / hide animation if it is already running. (crbug.com/250918) |
| 670 | TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) { |
| 671 | ShelfWidget* shelf = GetShelfWidget(); |
| 672 | SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE); |
| 673 | gfx::Rect initial_shelf_bounds = shelf->GetWindowBoundsInScreen(); |
| 674 | gfx::Rect initial_status_bounds = |
| 675 | shelf->status_area_widget()->GetWindowBoundsInScreen(); |
| 676 | |
| 677 | ui::ScopedAnimationDurationScaleMode normal_animation_duration( |
| 678 | ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); |
| 679 | SetState(shelf->shelf_layout_manager(), SHELF_HIDDEN); |
| 680 | SetState(shelf->shelf_layout_manager(), SHELF_VISIBLE); |
| 681 | |
| 682 | gfx::Rect current_shelf_bounds = shelf->GetWindowBoundsInScreen(); |
| 683 | gfx::Rect current_status_bounds = |
| 684 | shelf->status_area_widget()->GetWindowBoundsInScreen(); |
| 685 | |
| 686 | const int small_change = initial_shelf_bounds.height() / 2; |
| 687 | EXPECT_LE( |
| 688 | std::abs(initial_shelf_bounds.height() - current_shelf_bounds.height()), |
| 689 | small_change); |
| 690 | EXPECT_LE( |
| 691 | std::abs(initial_status_bounds.height() - current_status_bounds.height()), |
| 692 | small_change); |
| 693 | } |
| 694 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 695 | // Makes sure the launcher is sized when the status area changes size. |
| 696 | TEST_F(ShelfLayoutManagerTest, LauncherUpdatedWhenStatusAreaChangesSize) { |
| 697 | Launcher* launcher = Launcher::ForPrimaryDisplay(); |
| 698 | ASSERT_TRUE(launcher); |
| 699 | ShelfWidget* shelf_widget = GetShelfWidget(); |
| 700 | ASSERT_TRUE(shelf_widget); |
| 701 | ASSERT_TRUE(shelf_widget->status_area_widget()); |
| 702 | shelf_widget->status_area_widget()->SetBounds( |
| 703 | gfx::Rect(0, 0, 200, 200)); |
| 704 | EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - |
| 705 | launcher->GetLauncherViewForTest()->width()); |
| 706 | } |
| 707 | |
| 708 | |
| 709 | #if defined(OS_WIN) |
| 710 | // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 711 | #define MAYBE_AutoHide DISABLED_AutoHide |
| 712 | #else |
| 713 | #define MAYBE_AutoHide AutoHide |
| 714 | #endif |
| 715 | |
| 716 | // Various assertions around auto-hide. |
| 717 | TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { |
| 718 | aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
| 719 | aura::test::EventGenerator generator(root, root); |
| 720 | generator.MoveMouseTo(0, 0); |
| 721 | |
| 722 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 723 | shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 724 | views::Widget* widget = new views::Widget; |
| 725 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 726 | params.bounds = gfx::Rect(0, 0, 200, 200); |
| 727 | params.context = CurrentContext(); |
| 728 | // Widget is now owned by the parent window. |
| 729 | widget->Init(params); |
| 730 | widget->Maximize(); |
| 731 | widget->Show(); |
| 732 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 733 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 734 | |
| 735 | // LayoutShelf() forces the animation to completion, at which point the |
| 736 | // launcher should go off the screen. |
| 737 | shelf->LayoutShelf(); |
| 738 | EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 739 | GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 740 | EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 741 | Shell::GetScreen()->GetDisplayNearestWindow( |
| 742 | root).work_area().bottom()); |
| 743 | |
| 744 | // Move the mouse to the bottom of the screen. |
| 745 | generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
| 746 | |
| 747 | // Shelf should be shown again (but it shouldn't have changed the work area). |
| 748 | SetState(shelf, SHELF_AUTO_HIDE); |
| 749 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 750 | shelf->LayoutShelf(); |
| 751 | EXPECT_EQ(root->bounds().bottom() - shelf->GetIdealBounds().height(), |
| 752 | GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 753 | EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 754 | Shell::GetScreen()->GetDisplayNearestWindow( |
| 755 | root).work_area().bottom()); |
| 756 | |
| 757 | // Move mouse back up. |
| 758 | generator.MoveMouseTo(0, 0); |
| 759 | SetState(shelf, SHELF_AUTO_HIDE); |
| 760 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 761 | shelf->LayoutShelf(); |
| 762 | EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 763 | GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 764 | |
| 765 | // Drag mouse to bottom of screen. |
| 766 | generator.PressLeftButton(); |
| 767 | generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
| 768 | UpdateAutoHideStateNow(); |
| 769 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 770 | |
| 771 | generator.ReleaseLeftButton(); |
| 772 | generator.MoveMouseTo(1, root->bounds().bottom() - 1); |
| 773 | UpdateAutoHideStateNow(); |
| 774 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 775 | generator.PressLeftButton(); |
| 776 | generator.MoveMouseTo(1, root->bounds().bottom() - 1); |
| 777 | UpdateAutoHideStateNow(); |
| 778 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 779 | } |
| 780 | |
Ben Murdoch | bb1529c | 2013-08-08 10:24:53 +0100 | [diff] [blame^] | 781 | // Test the behavior of the shelf when it is auto hidden and it is on the |
| 782 | // boundary between the primary and the secondary display. |
| 783 | TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { |
| 784 | if (!SupportsMultipleDisplays()) |
| 785 | return; |
| 786 | |
| 787 | UpdateDisplay("800x600,800x600"); |
| 788 | DisplayLayout display_layout(DisplayLayout::RIGHT, 0); |
| 789 | Shell::GetInstance()->display_controller()->SetLayoutForCurrentDisplays( |
| 790 | display_layout); |
| 791 | // Put the primary monitor's shelf on the display boundary. |
| 792 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 793 | shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 794 | |
| 795 | // Create a window because the shelf is always shown when no windows are |
| 796 | // visible. |
| 797 | CreateTestWidget(); |
| 798 | |
| 799 | Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 800 | ASSERT_EQ(root_windows[0], |
| 801 | GetShelfWidget()->GetNativeWindow()->GetRootWindow()); |
| 802 | |
| 803 | shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 804 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 805 | |
| 806 | int right_edge = root_windows[0]->GetBoundsInScreen().right() - 1; |
| 807 | int y = root_windows[0]->GetBoundsInScreen().y(); |
| 808 | |
| 809 | // Start off the mouse nowhere near the shelf; the shelf should be hidden. |
| 810 | aura::test::EventGenerator& generator(GetEventGenerator()); |
| 811 | generator.MoveMouseTo(right_edge - 50, y); |
| 812 | UpdateAutoHideStateNow(); |
| 813 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 814 | |
| 815 | // Moving the mouse over the light bar (but not to the edge of the screen) |
| 816 | // should show the shelf. |
| 817 | generator.MoveMouseTo(right_edge - 1, y); |
| 818 | UpdateAutoHideStateNow(); |
| 819 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 820 | EXPECT_EQ(right_edge - 1, Shell::GetScreen()->GetCursorScreenPoint().x()); |
| 821 | |
| 822 | // Moving the mouse off the light bar should hide the shelf. |
| 823 | generator.MoveMouseTo(right_edge - 50, y); |
| 824 | UpdateAutoHideStateNow(); |
| 825 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 826 | |
| 827 | // Moving the mouse to the right edge of the screen crossing the light bar |
| 828 | // should show the shelf despite the mouse cursor getting warped to the |
| 829 | // secondary display. |
| 830 | generator.MoveMouseTo(right_edge - 1, y); |
| 831 | generator.MoveMouseTo(right_edge, y); |
| 832 | UpdateAutoHideStateNow(); |
| 833 | EXPECT_NE(right_edge - 1, Shell::GetScreen()->GetCursorScreenPoint().x()); |
| 834 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 835 | |
| 836 | // Hide the shelf. |
| 837 | generator.MoveMouseTo(right_edge - 50, y); |
| 838 | UpdateAutoHideStateNow(); |
| 839 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 840 | |
| 841 | // Moving the mouse to the right edge of the screen crossing the light bar and |
| 842 | // overshooting by a lot should keep the shelf hidden. |
| 843 | generator.MoveMouseTo(right_edge - 1, y); |
| 844 | generator.MoveMouseTo(right_edge + 50, y); |
| 845 | UpdateAutoHideStateNow(); |
| 846 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 847 | |
| 848 | // Moving the mouse to the right edge of the screen crossing the light bar and |
| 849 | // overshooting a bit should show the shelf. |
| 850 | generator.MoveMouseTo(right_edge - 1, y); |
| 851 | generator.MoveMouseTo(right_edge + 2, y); |
| 852 | UpdateAutoHideStateNow(); |
| 853 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 854 | |
| 855 | // Keeping the mouse close to the left edge of the secondary display after the |
| 856 | // shelf is shown should keep the shelf shown. |
| 857 | generator.MoveMouseTo(right_edge + 2, y + 1); |
| 858 | UpdateAutoHideStateNow(); |
| 859 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 860 | |
| 861 | // Moving the mouse far from the left edge of the secondary display should |
| 862 | // hide the shelf. |
| 863 | generator.MoveMouseTo(right_edge + 50, y); |
| 864 | UpdateAutoHideStateNow(); |
| 865 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 866 | |
| 867 | // Moving to the left edge of the secondary display without first crossing |
| 868 | // the primary display's right aligned shelf first should not show the shelf. |
| 869 | generator.MoveMouseTo(right_edge + 2, y); |
| 870 | UpdateAutoHideStateNow(); |
| 871 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 872 | } |
| 873 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 874 | // Assertions around the lock screen showing. |
| 875 | TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { |
| 876 | // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 877 | // it isn't over the shelf. |
| 878 | aura::test::EventGenerator generator( |
| 879 | Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 880 | generator.MoveMouseTo(0, 0); |
| 881 | |
| 882 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 883 | shelf->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 884 | views::Widget* widget = new views::Widget; |
| 885 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 886 | params.bounds = gfx::Rect(0, 0, 200, 200); |
| 887 | params.context = CurrentContext(); |
| 888 | // Widget is now owned by the parent window. |
| 889 | widget->Init(params); |
| 890 | widget->Maximize(); |
| 891 | widget->Show(); |
| 892 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 893 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 894 | |
| 895 | aura::RootWindow* root = Shell::GetPrimaryRootWindow(); |
| 896 | // LayoutShelf() forces the animation to completion, at which point the |
| 897 | // launcher should go off the screen. |
| 898 | shelf->LayoutShelf(); |
| 899 | EXPECT_EQ(root->bounds().bottom() - ShelfLayoutManager::kAutoHideSize, |
| 900 | GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 901 | |
| 902 | aura::Window* lock_container = Shell::GetContainer( |
| 903 | Shell::GetPrimaryRootWindow(), |
| 904 | internal::kShellWindowId_LockScreenContainer); |
| 905 | |
| 906 | views::Widget* lock_widget = new views::Widget; |
| 907 | views::Widget::InitParams lock_params( |
| 908 | views::Widget::InitParams::TYPE_WINDOW); |
| 909 | lock_params.bounds = gfx::Rect(0, 0, 200, 200); |
| 910 | params.context = CurrentContext(); |
| 911 | lock_params.parent = lock_container; |
| 912 | // Widget is now owned by the parent window. |
| 913 | lock_widget->Init(lock_params); |
| 914 | lock_widget->Maximize(); |
| 915 | lock_widget->Show(); |
| 916 | |
| 917 | // Lock the screen. |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 918 | Shell::GetInstance()->session_state_delegate()->LockScreen(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 919 | shelf->UpdateVisibilityState(); |
| 920 | // Showing a widget in the lock screen should force the shelf to be visibile. |
| 921 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 922 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 923 | Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 924 | shelf->UpdateVisibilityState(); |
| 925 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 926 | } |
| 927 | |
| 928 | // Assertions around SetAutoHideBehavior. |
| 929 | TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { |
| 930 | // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 931 | // it isn't over the shelf. |
| 932 | aura::test::EventGenerator generator( |
| 933 | Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 934 | generator.MoveMouseTo(0, 0); |
| 935 | |
| 936 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 937 | views::Widget* widget = new views::Widget; |
| 938 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 939 | params.bounds = gfx::Rect(0, 0, 200, 200); |
| 940 | params.context = CurrentContext(); |
| 941 | // Widget is now owned by the parent window. |
| 942 | widget->Init(params); |
| 943 | widget->Show(); |
| 944 | aura::Window* window = widget->GetNativeWindow(); |
| 945 | gfx::Rect display_bounds( |
| 946 | Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| 947 | |
| 948 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 949 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 950 | |
| 951 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 952 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 953 | |
| 954 | widget->Maximize(); |
| 955 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 956 | EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( |
| 957 | window).work_area().bottom(), |
| 958 | widget->GetWorkAreaBoundsInScreen().bottom()); |
| 959 | |
| 960 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 961 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 962 | EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( |
| 963 | window).work_area().bottom(), |
| 964 | widget->GetWorkAreaBoundsInScreen().bottom()); |
| 965 | |
| 966 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 967 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 968 | EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( |
| 969 | window).work_area().bottom(), |
| 970 | widget->GetWorkAreaBoundsInScreen().bottom()); |
| 971 | } |
| 972 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 973 | // Basic assertions around the dimming of the shelf. |
| 974 | TEST_F(ShelfLayoutManagerTest, TestDimmingBehavior) { |
| 975 | // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 976 | // it isn't over the shelf. |
| 977 | aura::test::EventGenerator generator( |
| 978 | Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 979 | generator.MoveMouseTo(0, 0); |
| 980 | |
| 981 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 982 | shelf->shelf_widget()->DisableDimmingAnimationsForTest(); |
| 983 | |
| 984 | views::Widget* widget = new views::Widget; |
| 985 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 986 | params.bounds = gfx::Rect(0, 0, 200, 200); |
| 987 | params.context = CurrentContext(); |
| 988 | // Widget is now owned by the parent window. |
| 989 | widget->Init(params); |
| 990 | widget->Show(); |
| 991 | aura::Window* window = widget->GetNativeWindow(); |
| 992 | gfx::Rect display_bounds( |
| 993 | Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| 994 | |
| 995 | gfx::Point off_shelf = display_bounds.CenterPoint(); |
| 996 | gfx::Point on_shelf = |
| 997 | shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); |
| 998 | |
| 999 | // Test there is no dimming object active at this point. |
| 1000 | generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| 1001 | EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1002 | generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); |
| 1003 | EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1004 | |
| 1005 | // After maximization, the shelf should be visible and the dimmer created. |
| 1006 | widget->Maximize(); |
| 1007 | |
| 1008 | on_shelf = shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); |
| 1009 | EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1010 | |
| 1011 | // Moving the mouse off the shelf should dim the bar. |
| 1012 | generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); |
| 1013 | EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1014 | |
| 1015 | // Adding touch events outside the shelf should still keep the shelf in |
| 1016 | // dimmed state. |
| 1017 | generator.PressTouch(); |
| 1018 | generator.MoveTouch(off_shelf); |
| 1019 | EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1020 | // Move the touch into the shelf area should undim. |
| 1021 | generator.MoveTouch(on_shelf); |
| 1022 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1023 | generator.ReleaseTouch(); |
| 1024 | // And a release dims again. |
| 1025 | EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1026 | |
| 1027 | // Moving the mouse on the shelf should undim the bar. |
| 1028 | generator.MoveMouseTo(on_shelf); |
| 1029 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1030 | |
| 1031 | // No matter what the touch events do, the shelf should stay undimmed. |
| 1032 | generator.PressTouch(); |
| 1033 | generator.MoveTouch(off_shelf); |
| 1034 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1035 | generator.MoveTouch(on_shelf); |
| 1036 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1037 | generator.MoveTouch(off_shelf); |
| 1038 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1039 | generator.MoveTouch(on_shelf); |
| 1040 | generator.ReleaseTouch(); |
| 1041 | |
| 1042 | // After restore, the dimming object should be deleted again. |
| 1043 | widget->Restore(); |
| 1044 | EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1045 | } |
| 1046 | |
| 1047 | // Assertions around the dimming of the shelf in conjunction with menus. |
| 1048 | TEST_F(ShelfLayoutManagerTest, TestDimmingBehaviorWithMenus) { |
| 1049 | // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 1050 | // it isn't over the shelf. |
| 1051 | aura::test::EventGenerator generator( |
| 1052 | Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 1053 | generator.MoveMouseTo(0, 0); |
| 1054 | |
| 1055 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1056 | shelf->shelf_widget()->DisableDimmingAnimationsForTest(); |
| 1057 | |
| 1058 | views::Widget* widget = new views::Widget; |
| 1059 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1060 | params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1061 | params.context = CurrentContext(); |
| 1062 | // Widget is now owned by the parent window. |
| 1063 | widget->Init(params); |
| 1064 | widget->Show(); |
| 1065 | aura::Window* window = widget->GetNativeWindow(); |
| 1066 | gfx::Rect display_bounds( |
| 1067 | Shell::GetScreen()->GetDisplayNearestWindow(window).bounds()); |
| 1068 | |
| 1069 | // After maximization, the shelf should be visible and the dimmer created. |
| 1070 | widget->Maximize(); |
| 1071 | |
| 1072 | gfx::Point off_shelf = display_bounds.CenterPoint(); |
| 1073 | gfx::Point on_shelf = |
| 1074 | shelf->shelf_widget()->GetWindowBoundsInScreen().CenterPoint(); |
| 1075 | |
| 1076 | // Moving the mouse on the shelf should undim the bar. |
| 1077 | generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| 1078 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1079 | |
| 1080 | // Simulate a menu opening. |
| 1081 | shelf->shelf_widget()->ForceUndimming(true); |
| 1082 | |
| 1083 | // Moving the mouse off the shelf should not dim the bar. |
| 1084 | generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); |
| 1085 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1086 | |
| 1087 | // No matter what the touch events do, the shelf should stay undimmed. |
| 1088 | generator.PressTouch(); |
| 1089 | generator.MoveTouch(off_shelf); |
| 1090 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1091 | generator.MoveTouch(on_shelf); |
| 1092 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1093 | generator.MoveTouch(off_shelf); |
| 1094 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1095 | generator.ReleaseTouch(); |
| 1096 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1097 | |
| 1098 | // "Closing the menu" should now turn off the menu since no event is inside |
| 1099 | // the shelf any longer. |
| 1100 | shelf->shelf_widget()->ForceUndimming(false); |
| 1101 | EXPECT_LT(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1102 | |
| 1103 | // Moving the mouse again on the shelf which should undim the bar again. |
| 1104 | // This time we check that the bar stays undimmed when the mouse remains on |
| 1105 | // the bar and the "menu gets closed". |
| 1106 | generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| 1107 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1108 | shelf->shelf_widget()->ForceUndimming(true); |
| 1109 | generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); |
| 1110 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1111 | generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); |
| 1112 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1113 | shelf->shelf_widget()->ForceUndimming(true); |
| 1114 | EXPECT_EQ(0, shelf->shelf_widget()->GetDimmingAlphaForTest()); |
| 1115 | } |
| 1116 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1117 | // Verifies the shelf is visible when status/launcher is focused. |
| 1118 | TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) { |
| 1119 | // Since ShelfLayoutManager queries for mouse location, move the mouse so |
| 1120 | // it isn't over the shelf. |
| 1121 | aura::test::EventGenerator generator( |
| 1122 | Shell::GetPrimaryRootWindow(), gfx::Point()); |
| 1123 | generator.MoveMouseTo(0, 0); |
| 1124 | |
| 1125 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1126 | views::Widget* widget = new views::Widget; |
| 1127 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1128 | params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1129 | params.context = CurrentContext(); |
| 1130 | // Widget is now owned by the parent window. |
| 1131 | widget->Init(params); |
| 1132 | widget->Show(); |
| 1133 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1134 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1135 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1136 | |
| 1137 | // Focus the launcher. Have to go through the focus cycler as normal focus |
| 1138 | // requests to it do nothing. |
| 1139 | GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); |
| 1140 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 1141 | |
| 1142 | widget->Activate(); |
| 1143 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1144 | |
| 1145 | // Trying to activate the status should fail, since we only allow activating |
| 1146 | // it when the user is using the keyboard (i.e. through FocusCycler). |
| 1147 | GetShelfWidget()->status_area_widget()->Activate(); |
| 1148 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1149 | |
| 1150 | GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); |
| 1151 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 1152 | } |
| 1153 | |
| 1154 | // Makes sure shelf will be visible when app list opens as shelf is in |
| 1155 | // SHELF_VISIBLE state,and toggling app list won't change shelf |
| 1156 | // visibility state. |
| 1157 | TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { |
| 1158 | Shell* shell = Shell::GetInstance(); |
| 1159 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1160 | shelf->LayoutShelf(); |
| 1161 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1162 | |
| 1163 | // Create a normal unmaximized windowm shelf should be visible. |
| 1164 | aura::Window* window = CreateTestWindow(); |
| 1165 | window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1166 | window->Show(); |
| 1167 | EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1168 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 1169 | |
| 1170 | // Toggle app list to show, and the shelf stays visible. |
| 1171 | shell->ToggleAppList(NULL); |
| 1172 | EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
| 1173 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 1174 | |
| 1175 | // Toggle app list to hide, and the shelf stays visible. |
| 1176 | shell->ToggleAppList(NULL); |
| 1177 | EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1178 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 1179 | } |
| 1180 | |
| 1181 | // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state |
| 1182 | // when app list opens as shelf is in SHELF_AUTO_HIDE state, and |
| 1183 | // toggling app list won't change shelf visibility state. |
| 1184 | TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { |
| 1185 | Shell* shell = Shell::GetInstance(); |
| 1186 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1187 | shelf->LayoutShelf(); |
| 1188 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1189 | |
| 1190 | // Create a window and show it in maximized state. |
| 1191 | aura::Window* window = CreateTestWindow(); |
| 1192 | window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1193 | window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1194 | window->Show(); |
| 1195 | wm::ActivateWindow(window); |
| 1196 | |
| 1197 | EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1198 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1199 | |
| 1200 | // Toggle app list to show. |
| 1201 | shell->ToggleAppList(NULL); |
| 1202 | // The shelf's auto hide state won't be changed until the timer fires, so |
| 1203 | // calling shell->UpdateShelfVisibility() is kind of manually helping it to |
| 1204 | // update the state. |
| 1205 | shell->UpdateShelfVisibility(); |
| 1206 | EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
| 1207 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1208 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 1209 | |
| 1210 | // Toggle app list to hide. |
| 1211 | shell->ToggleAppList(NULL); |
| 1212 | EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1213 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1214 | } |
| 1215 | |
| 1216 | // Makes sure shelf will be hidden when app list opens as shelf is in HIDDEN |
| 1217 | // state, and toggling app list won't change shelf visibility state. |
| 1218 | TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { |
| 1219 | Shell* shell = Shell::GetInstance(); |
| 1220 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1221 | // For shelf to be visible, app list is not open in initial state. |
| 1222 | shelf->LayoutShelf(); |
| 1223 | |
| 1224 | // Create a window and make it full screen. |
| 1225 | aura::Window* window = CreateTestWindow(); |
| 1226 | window->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1227 | window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| 1228 | window->Show(); |
| 1229 | wm::ActivateWindow(window); |
| 1230 | |
| 1231 | // App list and shelf is not shown. |
| 1232 | EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1233 | EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 1234 | |
| 1235 | // Toggle app list to show. |
| 1236 | shell->ToggleAppList(NULL); |
| 1237 | EXPECT_TRUE(shell->GetAppListTargetVisibility()); |
| 1238 | EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 1239 | |
| 1240 | // Toggle app list to hide. |
| 1241 | shell->ToggleAppList(NULL); |
| 1242 | EXPECT_FALSE(shell->GetAppListTargetVisibility()); |
| 1243 | EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 1244 | } |
| 1245 | |
| 1246 | #if defined(OS_WIN) |
| 1247 | // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 1248 | #define MAYBE_SetAlignment DISABLED_SetAlignment |
| 1249 | #else |
| 1250 | #define MAYBE_SetAlignment SetAlignment |
| 1251 | #endif |
| 1252 | |
| 1253 | // Tests SHELF_ALIGNMENT_(LEFT, RIGHT, TOP). |
| 1254 | TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { |
| 1255 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1256 | // Force an initial layout. |
| 1257 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1258 | shelf->LayoutShelf(); |
| 1259 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 1260 | |
| 1261 | shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 1262 | gfx::Rect launcher_bounds( |
| 1263 | GetShelfWidget()->GetWindowBoundsInScreen()); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1264 | const gfx::Screen* screen = Shell::GetScreen(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1265 | gfx::Display display = |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1266 | screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1267 | ASSERT_NE(-1, display.id()); |
| 1268 | EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 1269 | display.GetWorkAreaInsets().left()); |
| 1270 | EXPECT_GE( |
| 1271 | launcher_bounds.width(), |
| 1272 | GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| 1273 | EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); |
| 1274 | StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| 1275 | gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 1276 | EXPECT_GE(status_bounds.width(), |
| 1277 | status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 1278 | EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 1279 | display.GetWorkAreaInsets().left()); |
| 1280 | EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 1281 | EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1282 | EXPECT_EQ(0, display.GetWorkAreaInsets().right()); |
| 1283 | EXPECT_EQ(display.bounds().x(), launcher_bounds.x()); |
| 1284 | EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); |
| 1285 | EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); |
| 1286 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1287 | display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1288 | EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1289 | display.GetWorkAreaInsets().left()); |
| 1290 | EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, display.work_area().x()); |
| 1291 | |
| 1292 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1293 | shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1294 | display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1295 | launcher_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1296 | display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1297 | ASSERT_NE(-1, display.id()); |
| 1298 | EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 1299 | display.GetWorkAreaInsets().right()); |
| 1300 | EXPECT_GE(launcher_bounds.width(), |
| 1301 | GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| 1302 | EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); |
| 1303 | status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); |
| 1304 | EXPECT_GE(status_bounds.width(), |
| 1305 | status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 1306 | EXPECT_EQ(shelf->GetIdealBounds().width(), |
| 1307 | display.GetWorkAreaInsets().right()); |
| 1308 | EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 1309 | EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1310 | EXPECT_EQ(0, display.GetWorkAreaInsets().left()); |
| 1311 | EXPECT_EQ(display.work_area().right(), launcher_bounds.x()); |
| 1312 | EXPECT_EQ(display.bounds().y(), launcher_bounds.y()); |
| 1313 | EXPECT_EQ(display.bounds().height(), launcher_bounds.height()); |
| 1314 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1315 | display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1316 | EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1317 | display.GetWorkAreaInsets().right()); |
| 1318 | EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1319 | display.bounds().right() - display.work_area().right()); |
| 1320 | |
| 1321 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1322 | shelf->SetAlignment(SHELF_ALIGNMENT_TOP); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1323 | display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1324 | launcher_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1325 | display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1326 | ASSERT_NE(-1, display.id()); |
| 1327 | EXPECT_EQ(shelf->GetIdealBounds().height(), |
| 1328 | display.GetWorkAreaInsets().top()); |
| 1329 | EXPECT_GE(launcher_bounds.height(), |
| 1330 | GetShelfWidget()->GetContentsView()->GetPreferredSize().height()); |
| 1331 | EXPECT_EQ(SHELF_ALIGNMENT_TOP, GetSystemTray()->shelf_alignment()); |
| 1332 | status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); |
| 1333 | EXPECT_GE(status_bounds.height(), |
| 1334 | status_area_widget->GetContentsView()->GetPreferredSize().height()); |
| 1335 | EXPECT_EQ(shelf->GetIdealBounds().height(), |
| 1336 | display.GetWorkAreaInsets().top()); |
| 1337 | EXPECT_EQ(0, display.GetWorkAreaInsets().right()); |
| 1338 | EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1339 | EXPECT_EQ(0, display.GetWorkAreaInsets().left()); |
| 1340 | EXPECT_EQ(display.work_area().y(), launcher_bounds.bottom()); |
| 1341 | EXPECT_EQ(display.bounds().x(), launcher_bounds.x()); |
| 1342 | EXPECT_EQ(display.bounds().width(), launcher_bounds.width()); |
| 1343 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1344 | display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1345 | EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1346 | display.GetWorkAreaInsets().top()); |
| 1347 | EXPECT_EQ(ShelfLayoutManager::kAutoHideSize, |
| 1348 | display.work_area().y() - display.bounds().y()); |
| 1349 | } |
| 1350 | |
| 1351 | #if defined(OS_WIN) |
| 1352 | // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 1353 | #define MAYBE_GestureDrag DISABLED_GestureDrag |
| 1354 | #else |
| 1355 | #define MAYBE_GestureDrag GestureDrag |
| 1356 | #endif |
| 1357 | |
| 1358 | TEST_F(ShelfLayoutManagerTest, MAYBE_GestureDrag) { |
| 1359 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 1360 | { |
| 1361 | SCOPED_TRACE("BOTTOM"); |
| 1362 | RunGestureDragTests(gfx::Vector2d(0, 100)); |
| 1363 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1364 | |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 1365 | { |
| 1366 | SCOPED_TRACE("LEFT"); |
| 1367 | shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 1368 | RunGestureDragTests(gfx::Vector2d(-100, 0)); |
| 1369 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1370 | |
Ben Murdoch | a3f7b4e | 2013-07-24 10:36:34 +0100 | [diff] [blame] | 1371 | { |
| 1372 | SCOPED_TRACE("RIGHT"); |
| 1373 | shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 1374 | RunGestureDragTests(gfx::Vector2d(100, 0)); |
| 1375 | } |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1376 | } |
| 1377 | |
| 1378 | TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { |
Torne (Richard Coles) | 7d4cd47 | 2013-06-19 11:58:07 +0100 | [diff] [blame] | 1379 | if (!SupportsMultipleDisplays()) |
| 1380 | return; |
| 1381 | |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 1382 | UpdateDisplay("800x600,800x600"); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1383 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1384 | shelf->LayoutShelf(); |
| 1385 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1386 | |
| 1387 | // Create a visible window so auto-hide behavior is enforced |
| 1388 | views::Widget* dummy = CreateTestWidget(); |
| 1389 | |
| 1390 | // Window visible => auto hide behaves normally. |
| 1391 | shelf->UpdateVisibilityState(); |
| 1392 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1393 | |
| 1394 | // Window minimized => auto hide disabled. |
| 1395 | dummy->Minimize(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1396 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 1397 | |
| 1398 | // Window closed => auto hide disabled. |
| 1399 | dummy->CloseNow(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1400 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 1401 | |
| 1402 | // Multiple window test |
| 1403 | views::Widget* window1 = CreateTestWidget(); |
| 1404 | views::Widget* window2 = CreateTestWidget(); |
| 1405 | |
| 1406 | // both visible => normal autohide |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1407 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1408 | |
| 1409 | // either minimzed => normal autohide |
| 1410 | window2->Minimize(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1411 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1412 | window2->Restore(); |
| 1413 | window1->Minimize(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1414 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1415 | |
| 1416 | // both minimzed => disable auto hide |
| 1417 | window2->Minimize(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1418 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
Torne (Richard Coles) | c2e0dbd | 2013-05-09 18:35:53 +0100 | [diff] [blame] | 1419 | |
| 1420 | // Test moving windows to/from other display. |
| 1421 | window2->Restore(); |
| 1422 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1423 | // Move to second display. |
| 1424 | window2->SetBounds(gfx::Rect(850, 50, 50, 50)); |
| 1425 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 1426 | // Move back to primary display. |
| 1427 | window2->SetBounds(gfx::Rect(50, 50, 50, 50)); |
| 1428 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1429 | } |
| 1430 | |
| 1431 | #if defined(OS_WIN) |
| 1432 | // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 |
| 1433 | #define MAYBE_GestureRevealsTrayBubble DISABLED_GestureRevealsTrayBubble |
| 1434 | #else |
| 1435 | #define MAYBE_GestureRevealsTrayBubble GestureRevealsTrayBubble |
| 1436 | #endif |
| 1437 | |
| 1438 | TEST_F(ShelfLayoutManagerTest, MAYBE_GestureRevealsTrayBubble) { |
| 1439 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1440 | shelf->LayoutShelf(); |
| 1441 | |
| 1442 | // Create a visible window so auto-hide behavior is enforced. |
| 1443 | CreateTestWidget(); |
| 1444 | |
| 1445 | aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1446 | SystemTray* tray = GetSystemTray(); |
| 1447 | |
| 1448 | // First, make sure the shelf is visible. |
| 1449 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1450 | EXPECT_FALSE(tray->HasSystemBubble()); |
| 1451 | |
| 1452 | // Now, drag up on the tray to show the bubble. |
| 1453 | gfx::Point start = GetShelfWidget()->status_area_widget()-> |
| 1454 | GetWindowBoundsInScreen().CenterPoint(); |
| 1455 | gfx::Point end(start.x(), start.y() - 100); |
| 1456 | generator.GestureScrollSequence(start, end, |
| 1457 | base::TimeDelta::FromMilliseconds(10), 1); |
| 1458 | EXPECT_TRUE(tray->HasSystemBubble()); |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 1459 | tray->CloseSystemBubble(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1460 | RunAllPendingInMessageLoop(); |
| 1461 | EXPECT_FALSE(tray->HasSystemBubble()); |
| 1462 | |
| 1463 | // Drag again, but only a small amount, and slowly. The bubble should not be |
| 1464 | // visible. |
| 1465 | end.set_y(start.y() - 30); |
| 1466 | generator.GestureScrollSequence(start, end, |
| 1467 | base::TimeDelta::FromMilliseconds(500), 100); |
| 1468 | EXPECT_FALSE(tray->HasSystemBubble()); |
| 1469 | |
| 1470 | // Now, hide the shelf. |
| 1471 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1472 | |
| 1473 | // Start a drag from the bezel, and drag up to show both the shelf and the |
| 1474 | // tray bubble. |
| 1475 | start.set_y(start.y() + 100); |
| 1476 | end.set_y(start.y() - 400); |
| 1477 | generator.GestureScrollSequence(start, end, |
| 1478 | base::TimeDelta::FromMilliseconds(10), 1); |
| 1479 | EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 1480 | EXPECT_TRUE(tray->HasSystemBubble()); |
| 1481 | } |
| 1482 | |
| 1483 | TEST_F(ShelfLayoutManagerTest, ShelfFlickerOnTrayActivation) { |
| 1484 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1485 | |
| 1486 | // Create a visible window so auto-hide behavior is enforced. |
| 1487 | CreateTestWidget(); |
| 1488 | |
| 1489 | // Turn on auto-hide for the shelf. |
| 1490 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1491 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1492 | EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state()); |
| 1493 | |
| 1494 | // Show the status menu. That should make the shelf visible again. |
| 1495 | Shell::GetInstance()->accelerator_controller()->PerformAction( |
| 1496 | SHOW_SYSTEM_TRAY_BUBBLE, ui::Accelerator()); |
| 1497 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1498 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 1499 | EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); |
| 1500 | |
| 1501 | // Now activate the tray (using the keyboard, instead of using the mouse to |
| 1502 | // make sure the mouse does not alter the auto-hide state in the shelf). |
| 1503 | // This should not trigger any auto-hide state change in the shelf. |
| 1504 | ShelfLayoutObserverTest observer; |
| 1505 | shelf->AddObserver(&observer); |
| 1506 | |
| 1507 | aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1508 | generator.PressKey(ui::VKEY_SPACE, 0); |
| 1509 | generator.ReleaseKey(ui::VKEY_SPACE, 0); |
| 1510 | EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); |
| 1511 | EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 1512 | EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); |
| 1513 | EXPECT_FALSE(observer.changed_auto_hide_state()); |
| 1514 | |
| 1515 | shelf->RemoveObserver(&observer); |
| 1516 | } |
| 1517 | |
| 1518 | TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { |
| 1519 | // Make sure the shelf is always visible. |
| 1520 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1521 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1522 | shelf->LayoutShelf(); |
| 1523 | |
| 1524 | views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 1525 | params.bounds = gfx::Rect(0, 0, 200, 200); |
| 1526 | params.context = CurrentContext(); |
| 1527 | views::Widget* widget_one = CreateTestWidgetWithParams(params); |
| 1528 | widget_one->Maximize(); |
| 1529 | |
| 1530 | views::Widget* widget_two = CreateTestWidgetWithParams(params); |
| 1531 | widget_two->Maximize(); |
| 1532 | widget_two->Activate(); |
| 1533 | |
| 1534 | // Both windows are maximized. They should be of the same size. |
| 1535 | EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
| 1536 | widget_two->GetNativeWindow()->bounds().ToString()); |
Torne (Richard Coles) | 5e3f23d | 2013-06-11 16:24:11 +0100 | [diff] [blame] | 1537 | int area_when_shelf_shown = |
| 1538 | widget_one->GetNativeWindow()->bounds().size().GetArea(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1539 | |
| 1540 | // Now hide the shelf. |
| 1541 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1542 | |
Torne (Richard Coles) | 5e3f23d | 2013-06-11 16:24:11 +0100 | [diff] [blame] | 1543 | // Both windows should be resized according to the shelf status. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1544 | EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
| 1545 | widget_two->GetNativeWindow()->bounds().ToString()); |
Torne (Richard Coles) | 5e3f23d | 2013-06-11 16:24:11 +0100 | [diff] [blame] | 1546 | // Resized to small. |
| 1547 | EXPECT_LT(area_when_shelf_shown, |
| 1548 | widget_one->GetNativeWindow()->bounds().size().GetArea()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1549 | |
| 1550 | // Now show the shelf. |
| 1551 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1552 | |
Torne (Richard Coles) | 5e3f23d | 2013-06-11 16:24:11 +0100 | [diff] [blame] | 1553 | // Again both windows should be of the same size. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1554 | EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
| 1555 | widget_two->GetNativeWindow()->bounds().ToString()); |
Torne (Richard Coles) | 5e3f23d | 2013-06-11 16:24:11 +0100 | [diff] [blame] | 1556 | EXPECT_EQ(area_when_shelf_shown, |
| 1557 | widget_one->GetNativeWindow()->bounds().size().GetArea()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1558 | } |
| 1559 | |
| 1560 | // Confirm that the shelf is dimmed only when content is maximized and |
| 1561 | // shelf is not autohidden. |
| 1562 | TEST_F(ShelfLayoutManagerTest, Dimming) { |
| 1563 | GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1564 | scoped_ptr<aura::Window> w1(CreateTestWindow()); |
| 1565 | w1->Show(); |
| 1566 | wm::ActivateWindow(w1.get()); |
| 1567 | |
| 1568 | // Normal window doesn't dim shelf. |
| 1569 | w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 1570 | ShelfWidget* shelf = GetShelfWidget(); |
| 1571 | EXPECT_FALSE(shelf->GetDimsShelf()); |
| 1572 | |
| 1573 | // Maximized window does. |
| 1574 | w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1575 | EXPECT_TRUE(shelf->GetDimsShelf()); |
| 1576 | |
| 1577 | // Change back to normal stops dimming. |
| 1578 | w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| 1579 | EXPECT_FALSE(shelf->GetDimsShelf()); |
| 1580 | |
| 1581 | // Changing back to maximized dims again. |
| 1582 | w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1583 | EXPECT_TRUE(shelf->GetDimsShelf()); |
| 1584 | |
| 1585 | // Changing shelf to autohide stops dimming. |
| 1586 | GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1587 | EXPECT_FALSE(shelf->GetDimsShelf()); |
| 1588 | } |
| 1589 | |
| 1590 | // Make sure that the shelf will not hide if the mouse is between a bubble and |
| 1591 | // the shelf. |
| 1592 | TEST_F(ShelfLayoutManagerTest, BubbleEnlargesShelfMouseHitArea) { |
| 1593 | ShelfLayoutManager* shelf = GetShelfLayoutManager(); |
| 1594 | StatusAreaWidget* status_area_widget = |
| 1595 | Shell::GetPrimaryRootWindowController()->shelf()->status_area_widget(); |
| 1596 | SystemTray* tray = GetSystemTray(); |
| 1597 | |
| 1598 | // Create a visible window so auto-hide behavior is enforced. |
| 1599 | CreateTestWidget(); |
| 1600 | |
| 1601 | shelf->LayoutShelf(); |
| 1602 | aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
| 1603 | |
| 1604 | // Make two iterations - first without a message bubble which should make |
| 1605 | // the shelf disappear and then with a message bubble which should keep it |
| 1606 | // visible. |
| 1607 | for (int i = 0; i < 2; i++) { |
| 1608 | // Make sure the shelf is visible and position the mouse over it. Then |
| 1609 | // allow auto hide. |
| 1610 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1611 | EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 1612 | gfx::Point center = |
| 1613 | status_area_widget->GetWindowBoundsInScreen().CenterPoint(); |
| 1614 | generator.MoveMouseTo(center.x(), center.y()); |
| 1615 | shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1616 | EXPECT_TRUE(shelf->IsVisible()); |
| 1617 | if (!i) { |
| 1618 | // In our first iteration we make sure there is no bubble. |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 1619 | tray->CloseSystemBubble(); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1620 | EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 1621 | } else { |
| 1622 | // In our second iteration we show a bubble. |
| 1623 | TestItem *item = new TestItem; |
| 1624 | tray->AddTrayItem(item); |
| 1625 | tray->ShowNotificationView(item); |
| 1626 | EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 1627 | } |
| 1628 | // Move the pointer over the edge of the shelf. |
| 1629 | generator.MoveMouseTo( |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 1630 | center.x(), status_area_widget->GetWindowBoundsInScreen().y() - 8); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1631 | shelf->UpdateVisibilityState(); |
| 1632 | if (i) { |
| 1633 | EXPECT_TRUE(shelf->IsVisible()); |
| 1634 | EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 1635 | } else { |
| 1636 | EXPECT_FALSE(shelf->IsVisible()); |
| 1637 | EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 1638 | } |
| 1639 | } |
| 1640 | } |
| 1641 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 1642 | TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColor) { |
| 1643 | EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); |
| 1644 | |
| 1645 | scoped_ptr<aura::Window> w1(CreateTestWindow()); |
| 1646 | w1->Show(); |
| 1647 | wm::ActivateWindow(w1.get()); |
| 1648 | EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); |
| 1649 | w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1650 | EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); |
| 1651 | |
| 1652 | scoped_ptr<aura::Window> w2(CreateTestWindow()); |
| 1653 | w2->Show(); |
| 1654 | wm::ActivateWindow(w2.get()); |
| 1655 | // Overlaps with shelf. |
| 1656 | w2->SetBounds(GetShelfLayoutManager()->GetIdealBounds()); |
| 1657 | |
| 1658 | // Still background is 'maximized'. |
| 1659 | EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); |
| 1660 | |
| 1661 | w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 1662 | EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); |
| 1663 | w2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| 1664 | EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); |
| 1665 | |
| 1666 | w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1667 | EXPECT_EQ(SHELF_BACKGROUND_MAXIMIZED, GetShelfWidget()->GetBackgroundType()); |
| 1668 | w1.reset(); |
| 1669 | EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget()->GetBackgroundType()); |
| 1670 | } |
| 1671 | |
| 1672 | // Verify that the shelf doesn't have the opaque background if it's auto-hide |
| 1673 | // status. |
| 1674 | TEST_F(ShelfLayoutManagerTest, ShelfBackgroundColorAutoHide) { |
| 1675 | EXPECT_EQ(SHELF_BACKGROUND_DEFAULT, GetShelfWidget ()->GetBackgroundType()); |
| 1676 | |
| 1677 | GetShelfLayoutManager()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1678 | scoped_ptr<aura::Window> w1(CreateTestWindow()); |
| 1679 | w1->Show(); |
| 1680 | wm::ActivateWindow(w1.get()); |
| 1681 | EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); |
| 1682 | w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1683 | EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); |
| 1684 | } |
| 1685 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 1686 | } // namespace internal |
| 1687 | } // namespace ash |