| 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/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
| 8 #include "ash/common/accelerators/accelerator_controller.h" | 8 #include "ash/common/accelerators/accelerator_controller.h" |
| 9 #include "ash/common/accelerators/accelerator_table.h" | 9 #include "ash/common/accelerators/accelerator_table.h" |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| 11 #include "ash/common/focus_cycler.h" | 11 #include "ash/common/focus_cycler.h" |
| 12 #include "ash/common/material_design/material_design_controller.h" | 12 #include "ash/common/material_design/material_design_controller.h" |
| 13 #include "ash/common/session/session_state_delegate.h" | 13 #include "ash/common/session/session_state_delegate.h" |
| 14 #include "ash/common/shelf/shelf_constants.h" | 14 #include "ash/common/shelf/shelf_constants.h" |
| 15 #include "ash/common/shell_window_ids.h" | 15 #include "ash/common/shell_window_ids.h" |
| 16 #include "ash/common/system/status_area_widget.h" | 16 #include "ash/common/system/status_area_widget.h" |
| 17 #include "ash/common/system/tray/system_tray.h" | 17 #include "ash/common/system/tray/system_tray.h" |
| 18 #include "ash/common/system/tray/system_tray_item.h" | 18 #include "ash/common/system/tray/system_tray_item.h" |
| 19 #include "ash/common/wm/window_state.h" | 19 #include "ash/common/wm/window_state.h" |
| 20 #include "ash/common/wm_shell.h" | 20 #include "ash/common/wm_shell.h" |
| 21 #include "ash/display/display_manager.h" | 21 #include "ash/display/display_manager.h" |
| 22 #include "ash/display/window_tree_host_manager.h" | |
| 23 #include "ash/root_window_controller.h" | 22 #include "ash/root_window_controller.h" |
| 24 #include "ash/shelf/shelf.h" | 23 #include "ash/shelf/shelf.h" |
| 25 #include "ash/shelf/shelf_layout_manager_observer.h" | 24 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 26 #include "ash/shelf/shelf_view.h" | 25 #include "ash/shelf/shelf_view.h" |
| 27 #include "ash/shelf/shelf_widget.h" | 26 #include "ash/shelf/shelf_widget.h" |
| 28 #include "ash/shell.h" | 27 #include "ash/shell.h" |
| 29 #include "ash/test/ash_test_base.h" | 28 #include "ash/test/ash_test_base.h" |
| 30 #include "ash/test/display_manager_test_api.h" | 29 #include "ash/test/display_manager_test_api.h" |
| 31 #include "ash/test/shelf_test_api.h" | 30 #include "ash/test/shelf_test_api.h" |
| 31 #include "ash/test/status_area_widget_test_helper.h" |
| 32 #include "ash/test/test_system_tray_item.h" | 32 #include "ash/test/test_system_tray_item.h" |
| 33 #include "ash/wm/window_state_aura.h" | 33 #include "ash/wm/window_state_aura.h" |
| 34 #include "ash/wm/window_util.h" | 34 #include "ash/wm/window_util.h" |
| 35 #include "base/command_line.h" | 35 #include "base/command_line.h" |
| 36 #include "ui/aura/client/aura_constants.h" | 36 #include "ui/aura/client/aura_constants.h" |
| 37 #include "ui/aura/client/window_tree_client.h" | 37 #include "ui/aura/client/window_tree_client.h" |
| 38 #include "ui/aura/window.h" | 38 #include "ui/aura/window.h" |
| 39 #include "ui/aura/window_event_dispatcher.h" | 39 #include "ui/aura/window_event_dispatcher.h" |
| 40 #include "ui/compositor/layer.h" | 40 #include "ui/compositor/layer.h" |
| 41 #include "ui/compositor/layer_animator.h" | 41 #include "ui/compositor/layer_animator.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } else if (SHELF_ALIGNMENT_RIGHT == | 171 } else if (SHELF_ALIGNMENT_RIGHT == |
| 172 GetShelfLayoutManager()->GetAlignment()) { | 172 GetShelfLayoutManager()->GetAlignment()) { |
| 173 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.right(), shelf_bounds.right()); | 173 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.right(), shelf_bounds.right()); |
| 174 EXPECT_EQ(shelf_widget_bounds_.right(), shelf_bounds.right()); | 174 EXPECT_EQ(shelf_widget_bounds_.right(), shelf_bounds.right()); |
| 175 } else if (SHELF_ALIGNMENT_LEFT == | 175 } else if (SHELF_ALIGNMENT_LEFT == |
| 176 GetShelfLayoutManager()->GetAlignment()) { | 176 GetShelfLayoutManager()->GetAlignment()) { |
| 177 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.x(), shelf_bounds.x()); | 177 EXPECT_EQ(auto_hidden_shelf_widget_bounds_.x(), shelf_bounds.x()); |
| 178 EXPECT_EQ(shelf_widget_bounds_.x(), shelf_bounds.x()); | 178 EXPECT_EQ(shelf_widget_bounds_.x(), shelf_bounds.x()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 // if the shelf is being dimmed test dimmer bounds as well. | |
| 182 if (GetShelfWidget()->GetDimsShelf()) | |
| 183 EXPECT_EQ(GetShelfWidget()->GetWindowBoundsInScreen(), | |
| 184 GetShelfWidget()->GetDimmerBoundsForTest()); | |
| 185 | |
| 186 // Auto hidden shelf has a visible height of 0 in MD (where this inequality | 181 // Auto hidden shelf has a visible height of 0 in MD (where this inequality |
| 187 // does not apply); whereas auto hidden shelf has a visible height of 3 in | 182 // does not apply); whereas auto hidden shelf has a visible height of 3 in |
| 188 // non-MD. | 183 // non-MD. |
| 189 if (!ash::MaterialDesignController::IsShelfMaterial() || | 184 if (!ash::MaterialDesignController::IsShelfMaterial() || |
| 190 GetShelf()->GetAutoHideState() != ash::SHELF_AUTO_HIDE_HIDDEN) { | 185 GetShelf()->GetAutoHideState() != ash::SHELF_AUTO_HIDE_HIDDEN) { |
| 191 EXPECT_GE(shelf_bounds.height(), | 186 EXPECT_GE(shelf_bounds.height(), |
| 192 auto_hidden_shelf_widget_bounds_.height()); | 187 auto_hidden_shelf_widget_bounds_.height()); |
| 193 } | 188 } |
| 194 | 189 |
| 195 float scroll_delta = | 190 float scroll_delta = |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 290 } |
| 296 | 291 |
| 297 views::Widget* CreateTestWidgetWithParams( | 292 views::Widget* CreateTestWidgetWithParams( |
| 298 const views::Widget::InitParams& params) { | 293 const views::Widget::InitParams& params) { |
| 299 views::Widget* out = new views::Widget; | 294 views::Widget* out = new views::Widget; |
| 300 out->Init(params); | 295 out->Init(params); |
| 301 out->Show(); | 296 out->Show(); |
| 302 return out; | 297 return out; |
| 303 } | 298 } |
| 304 | 299 |
| 305 // Create a simple widget attached to the current context (will | 300 // Create a simple widget in the current context (will delete on TearDown). |
| 306 // delete on TearDown). | |
| 307 views::Widget* CreateTestWidget() { | 301 views::Widget* CreateTestWidget() { |
| 308 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 302 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
| 309 params.bounds = gfx::Rect(0, 0, 200, 200); | 303 params.bounds = gfx::Rect(0, 0, 200, 200); |
| 310 params.context = CurrentContext(); | 304 params.context = CurrentContext(); |
| 311 return CreateTestWidgetWithParams(params); | 305 return CreateTestWidgetWithParams(params); |
| 312 } | 306 } |
| 313 | 307 |
| 314 void RunGestureDragTests(gfx::Vector2d); | 308 void RunGestureDragTests(gfx::Vector2d); |
| 315 | 309 |
| 316 // Turn on the lock screen. | 310 // Turn on the lock screen. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 327 Shell::GetInstance()->OnLockStateChanged(false); | 321 Shell::GetInstance()->OnLockStateChanged(false); |
| 328 } | 322 } |
| 329 | 323 |
| 330 private: | 324 private: |
| 331 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); | 325 DISALLOW_COPY_AND_ASSIGN(ShelfLayoutManagerTest); |
| 332 }; | 326 }; |
| 333 | 327 |
| 334 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { | 328 void ShelfLayoutManagerTest::RunGestureDragTests(gfx::Vector2d delta) { |
| 335 Shelf* shelf = GetShelf(); | 329 Shelf* shelf = GetShelf(); |
| 336 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 330 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 337 views::Widget* widget = new views::Widget; | 331 |
| 338 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 332 views::Widget* widget = CreateTestWidget(); |
| 339 params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 340 params.context = CurrentContext(); | |
| 341 widget->Init(params); | |
| 342 widget->Show(); | |
| 343 widget->Maximize(); | 333 widget->Maximize(); |
| 344 | 334 |
| 345 // The time delta should be large enough to prevent accidental fling creation. | 335 // The time delta should be large enough to prevent accidental fling creation. |
| 346 const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100); | 336 const base::TimeDelta kTimeDelta = base::TimeDelta::FromMilliseconds(100); |
| 347 | 337 |
| 348 aura::Window* window = widget->GetNativeWindow(); | 338 aura::Window* window = widget->GetNativeWindow(); |
| 349 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 339 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 350 layout_manager->LayoutShelf(); | 340 layout_manager->LayoutShelf(); |
| 351 | 341 |
| 352 gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen(); | 342 gfx::Rect shelf_shown = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 353 gfx::Rect bounds_shelf = window->bounds(); | 343 gfx::Rect bounds_shelf = window->bounds(); |
| 354 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 344 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 355 | 345 |
| 356 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 346 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 357 layout_manager->LayoutShelf(); | 347 layout_manager->LayoutShelf(); |
| 358 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 348 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 359 | 349 |
| 360 gfx::Rect bounds_noshelf = window->bounds(); | 350 gfx::Rect bounds_noshelf = window->bounds(); |
| 361 gfx::Rect shelf_hidden = GetShelfWidget()->GetWindowBoundsInScreen(); | 351 gfx::Rect shelf_hidden = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 362 | 352 |
| 363 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 353 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 364 layout_manager->LayoutShelf(); | 354 layout_manager->LayoutShelf(); |
| 365 | 355 |
| 366 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 356 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 367 const int kNumScrollSteps = 4; | 357 const int kNumScrollSteps = 4; |
| 368 ShelfDragCallback handler(shelf_hidden, shelf_shown); | 358 ShelfDragCallback handler(shelf_hidden, shelf_shown); |
| 369 | 359 |
| 370 // Swipe up on the shelf. This should not change any state. | 360 // Swipe up on the shelf. This should not change any state. |
| 371 gfx::Point start = GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); | 361 gfx::Point start = GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
| 372 gfx::Point end = start + delta; | 362 gfx::Point end = start + delta; |
| 373 | 363 |
| 374 // Swipe down on the shelf to hide it. | 364 // Swipe down on the shelf to hide it. |
| 375 generator.GestureScrollSequenceWithCallback( | 365 generator.GestureScrollSequenceWithCallback( |
| 376 start, end, kTimeDelta, kNumScrollSteps, | 366 start, end, kTimeDelta, kNumScrollSteps, |
| 377 base::Bind(&ShelfDragCallback::ProcessScroll, | 367 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 378 base::Unretained(&handler))); | 368 base::Unretained(&handler))); |
| 379 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 369 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 380 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 370 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 381 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 371 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 382 EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString()); | 372 EXPECT_NE(bounds_shelf.ToString(), window->bounds().ToString()); |
| 383 EXPECT_NE(shelf_shown.ToString(), | 373 EXPECT_NE(shelf_shown.ToString(), |
| 384 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 374 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 385 | 375 |
| 386 // Swipe up to show the shelf. | 376 // Swipe up to show the shelf. |
| 387 generator.GestureScrollSequenceWithCallback( | 377 generator.GestureScrollSequenceWithCallback( |
| 388 end, start, kTimeDelta, kNumScrollSteps, | 378 end, start, kTimeDelta, kNumScrollSteps, |
| 389 base::Bind(&ShelfDragCallback::ProcessScroll, | 379 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 390 base::Unretained(&handler))); | 380 base::Unretained(&handler))); |
| 391 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 381 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 392 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 382 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 393 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 383 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 394 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | |
| 395 GetShelfWidget()->GetWindowBoundsInScreen()); | |
| 396 EXPECT_EQ(shelf_shown.ToString(), | 384 EXPECT_EQ(shelf_shown.ToString(), |
| 397 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 385 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 398 | 386 |
| 399 // Swipe up again. The shelf should hide. | 387 // Swipe up again. The shelf should hide. |
| 400 end = start - delta; | 388 end = start - delta; |
| 401 generator.GestureScrollSequenceWithCallback( | 389 generator.GestureScrollSequenceWithCallback( |
| 402 start, end, kTimeDelta, kNumScrollSteps, | 390 start, end, kTimeDelta, kNumScrollSteps, |
| 403 base::Bind(&ShelfDragCallback::ProcessScroll, | 391 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 404 base::Unretained(&handler))); | 392 base::Unretained(&handler))); |
| 405 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 393 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 431 | 419 |
| 432 // Swipe down again to hide. | 420 // Swipe down again to hide. |
| 433 end = start + delta; | 421 end = start + delta; |
| 434 generator.GestureScrollSequenceWithCallback( | 422 generator.GestureScrollSequenceWithCallback( |
| 435 start, end, kTimeDelta, kNumScrollSteps, | 423 start, end, kTimeDelta, kNumScrollSteps, |
| 436 base::Bind(&ShelfDragCallback::ProcessScroll, | 424 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 437 base::Unretained(&handler))); | 425 base::Unretained(&handler))); |
| 438 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 426 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 439 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 427 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 440 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 428 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 441 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | |
| 442 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 429 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
| 443 EXPECT_EQ(shelf_hidden.ToString(), | 430 EXPECT_EQ(shelf_hidden.ToString(), |
| 444 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 431 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 445 | 432 |
| 446 // Swipe up in extended hit region to show it. | 433 // Swipe up in extended hit region to show it. |
| 447 gfx::Point extended_start = start; | 434 gfx::Point extended_start = start; |
| 448 if (GetShelfLayoutManager()->IsHorizontalAlignment()) | 435 if (GetShelfLayoutManager()->IsHorizontalAlignment()) |
| 449 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() - 1); | 436 extended_start.set_y(GetShelfWidget()->GetWindowBoundsInScreen().y() - 1); |
| 450 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 437 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
| 451 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + | 438 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + |
| 452 1); | 439 1); |
| 453 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 440 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
| 454 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); | 441 extended_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
| 455 end = extended_start - delta; | 442 end = extended_start - delta; |
| 456 generator.GestureScrollSequenceWithCallback( | 443 generator.GestureScrollSequenceWithCallback( |
| 457 extended_start, end, kTimeDelta, kNumScrollSteps, | 444 extended_start, end, kTimeDelta, 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(), | |
| 464 GetShelfWidget()->GetWindowBoundsInScreen()); | |
| 465 EXPECT_EQ(shelf_shown.ToString(), | 450 EXPECT_EQ(shelf_shown.ToString(), |
| 466 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 451 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 467 | 452 |
| 468 // Swipe down again to hide. | 453 // Swipe down again to hide. |
| 469 end = start + delta; | 454 end = start + delta; |
| 470 generator.GestureScrollSequenceWithCallback( | 455 generator.GestureScrollSequenceWithCallback( |
| 471 start, end, kTimeDelta, kNumScrollSteps, | 456 start, end, kTimeDelta, kNumScrollSteps, |
| 472 base::Bind(&ShelfDragCallback::ProcessScroll, | 457 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 473 base::Unretained(&handler))); | 458 base::Unretained(&handler))); |
| 474 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 459 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 475 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 460 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 476 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 461 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 477 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | |
| 478 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 462 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
| 479 EXPECT_EQ(shelf_hidden.ToString(), | 463 EXPECT_EQ(shelf_hidden.ToString(), |
| 480 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 464 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 481 | 465 |
| 482 // Swipe up outside the hit area. This should not change anything. | 466 // Swipe up outside the hit area. This should not change anything. |
| 483 gfx::Point outside_start = | 467 gfx::Point outside_start = |
| 484 gfx::Point((GetShelfWidget()->GetWindowBoundsInScreen().x() + | 468 gfx::Point((GetShelfWidget()->GetWindowBoundsInScreen().x() + |
| 485 GetShelfWidget()->GetWindowBoundsInScreen().right()) / | 469 GetShelfWidget()->GetWindowBoundsInScreen().right()) / |
| 486 2, | 470 2, |
| 487 GetShelfWidget()->GetWindowBoundsInScreen().y() - 50); | 471 GetShelfWidget()->GetWindowBoundsInScreen().y() - 50); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 502 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) | 486 else if (SHELF_ALIGNMENT_LEFT == GetShelfLayoutManager()->GetAlignment()) |
| 503 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); | 487 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().x() - 1); |
| 504 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) | 488 else if (SHELF_ALIGNMENT_RIGHT == GetShelfLayoutManager()->GetAlignment()) |
| 505 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); | 489 below_start.set_x(GetShelfWidget()->GetWindowBoundsInScreen().right() + 1); |
| 506 end = below_start - delta; | 490 end = below_start - delta; |
| 507 generator.GestureScrollSequence(below_start, end, kTimeDelta, | 491 generator.GestureScrollSequence(below_start, end, kTimeDelta, |
| 508 kNumScrollSteps); | 492 kNumScrollSteps); |
| 509 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 493 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 510 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 494 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
| 511 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); | 495 EXPECT_EQ(bounds_shelf.ToString(), window->bounds().ToString()); |
| 512 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), | |
| 513 GetShelfWidget()->GetWindowBoundsInScreen()); | |
| 514 EXPECT_EQ(shelf_shown.ToString(), | 496 EXPECT_EQ(shelf_shown.ToString(), |
| 515 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 497 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 516 | 498 |
| 517 // Swipe down again to hide. | 499 // Swipe down again to hide. |
| 518 end = start + delta; | 500 end = start + delta; |
| 519 generator.GestureScrollSequenceWithCallback( | 501 generator.GestureScrollSequenceWithCallback( |
| 520 start, end, kTimeDelta, kNumScrollSteps, | 502 start, end, kTimeDelta, kNumScrollSteps, |
| 521 base::Bind(&ShelfDragCallback::ProcessScroll, | 503 base::Bind(&ShelfDragCallback::ProcessScroll, |
| 522 base::Unretained(&handler))); | 504 base::Unretained(&handler))); |
| 523 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 505 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 524 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 506 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 525 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 507 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
| 526 EXPECT_EQ(GetShelfWidget()->GetDimmerBoundsForTest(), gfx::Rect()); | |
| 527 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); | 508 EXPECT_EQ(bounds_noshelf.ToString(), window->bounds().ToString()); |
| 528 EXPECT_EQ(shelf_hidden.ToString(), | 509 EXPECT_EQ(shelf_hidden.ToString(), |
| 529 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); | 510 GetShelfWidget()->GetWindowBoundsInScreen().ToString()); |
| 530 | 511 |
| 531 // Put |widget| into fullscreen. Set the shelf to be auto hidden when |widget| | 512 // Put |widget| into fullscreen. Set the shelf to be auto hidden when |widget| |
| 532 // is fullscreen. (eg browser immersive fullscreen). | 513 // is fullscreen. (eg browser immersive fullscreen). |
| 533 widget->SetFullscreen(true); | 514 widget->SetFullscreen(true); |
| 534 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); | 515 wm::GetWindowState(window)->set_hide_shelf_when_fullscreen(false); |
| 535 layout_manager->UpdateVisibilityState(); | 516 layout_manager->UpdateVisibilityState(); |
| 536 | 517 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 ShelfWidget* shelf_widget = GetShelfWidget(); | 600 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 620 ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager(); | 601 ShelfLayoutManager* manager = shelf_widget->shelf_layout_manager(); |
| 621 // Force an initial layout. | 602 // Force an initial layout. |
| 622 manager->LayoutShelf(); | 603 manager->LayoutShelf(); |
| 623 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); | 604 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
| 624 | 605 |
| 625 gfx::Rect status_bounds( | 606 gfx::Rect status_bounds( |
| 626 shelf_widget->status_area_widget()->GetWindowBoundsInScreen()); | 607 shelf_widget->status_area_widget()->GetWindowBoundsInScreen()); |
| 627 gfx::Rect shelf_bounds(shelf_widget->GetWindowBoundsInScreen()); | 608 gfx::Rect shelf_bounds(shelf_widget->GetWindowBoundsInScreen()); |
| 628 int shelf_height = manager->GetIdealBounds().height(); | 609 int shelf_height = manager->GetIdealBounds().height(); |
| 629 display::Screen* screen = display::Screen::GetScreen(); | 610 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 630 display::Display display = | |
| 631 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 632 ASSERT_NE(-1, display.id()); | 611 ASSERT_NE(-1, display.id()); |
| 633 // Bottom inset should be the max of widget heights. | 612 // Bottom inset should be the max of widget heights. |
| 634 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); | 613 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
| 635 | 614 |
| 636 // Hide the shelf. | 615 // Hide the shelf. |
| 637 SetState(manager, SHELF_HIDDEN); | 616 SetState(manager, SHELF_HIDDEN); |
| 638 // Run the animation to completion. | 617 // Run the animation to completion. |
| 639 StepWidgetLayerAnimatorToEnd(shelf_widget); | 618 StepWidgetLayerAnimatorToEnd(shelf_widget); |
| 640 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); | 619 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
| 641 EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state()); | 620 EXPECT_EQ(SHELF_HIDDEN, manager->visibility_state()); |
| 642 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 643 | 621 |
| 644 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 622 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 645 | 623 |
| 646 // Make sure the bounds of the two widgets changed. | 624 // Make sure the bounds of the two widgets changed. |
| 647 EXPECT_GE(shelf_widget->GetNativeView()->bounds().y(), | 625 EXPECT_GE(shelf_widget->GetNativeView()->bounds().y(), |
| 648 screen->GetPrimaryDisplay().bounds().bottom()); | 626 display.bounds().bottom()); |
| 649 EXPECT_GE(shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), | 627 EXPECT_GE(shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), |
| 650 screen->GetPrimaryDisplay().bounds().bottom()); | 628 display.bounds().bottom()); |
| 651 | 629 |
| 652 // And show it again. | 630 // And show it again. |
| 653 SetState(manager, SHELF_VISIBLE); | 631 SetState(manager, SHELF_VISIBLE); |
| 654 // Run the animation to completion. | 632 // Run the animation to completion. |
| 655 StepWidgetLayerAnimatorToEnd(shelf_widget); | 633 StepWidgetLayerAnimatorToEnd(shelf_widget); |
| 656 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); | 634 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
| 657 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); | 635 EXPECT_EQ(SHELF_VISIBLE, manager->visibility_state()); |
| 658 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 659 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); | 636 EXPECT_EQ(shelf_height, display.GetWorkAreaInsets().bottom()); |
| 660 | 637 |
| 661 // Make sure the bounds of the two widgets changed. | 638 // Make sure the bounds of the two widgets changed. |
| 662 shelf_bounds = shelf_widget->GetNativeView()->bounds(); | 639 shelf_bounds = shelf_widget->GetNativeView()->bounds(); |
| 663 EXPECT_LT(shelf_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); | 640 EXPECT_LT(shelf_bounds.y(), display.bounds().bottom()); |
| 664 status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds(); | 641 status_bounds = shelf_widget->status_area_widget()->GetNativeView()->bounds(); |
| 665 EXPECT_LT(status_bounds.y(), screen->GetPrimaryDisplay().bounds().bottom()); | 642 EXPECT_LT(status_bounds.y(), display.bounds().bottom()); |
| 666 } | 643 } |
| 667 | 644 |
| 668 // Makes sure LayoutShelf invoked while animating cleans things up. | 645 // Makes sure LayoutShelf invoked while animating cleans things up. |
| 669 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { | 646 TEST_F(ShelfLayoutManagerTest, LayoutShelfWhileAnimating) { |
| 670 Shelf* shelf = GetShelf(); | 647 Shelf* shelf = GetShelf(); |
| 671 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 648 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 672 // Force an initial layout. | 649 // Force an initial layout. |
| 673 layout_manager->LayoutShelf(); | 650 layout_manager->LayoutShelf(); |
| 674 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 651 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 675 | 652 |
| 676 // Hide the shelf. | 653 // Hide the shelf. |
| 677 SetState(layout_manager, SHELF_HIDDEN); | 654 SetState(layout_manager, SHELF_HIDDEN); |
| 678 layout_manager->LayoutShelf(); | 655 layout_manager->LayoutShelf(); |
| 679 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 656 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
| 680 display::Display display = | 657 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 681 display::Screen::GetScreen()->GetDisplayNearestWindow( | |
| 682 Shell::GetPrimaryRootWindow()); | |
| 683 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 658 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 684 | 659 |
| 685 // Make sure the bounds of the two widgets changed. | 660 // Make sure the bounds of the two widgets changed. |
| 686 ShelfWidget* shelf_widget = GetShelfWidget(); | 661 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 687 EXPECT_GE( | 662 EXPECT_GE(shelf_widget->GetNativeView()->bounds().y(), |
| 688 shelf_widget->GetNativeView()->bounds().y(), | 663 display.bounds().bottom()); |
| 689 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); | 664 EXPECT_GE(shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), |
| 690 EXPECT_GE( | 665 display.bounds().bottom()); |
| 691 shelf_widget->status_area_widget()->GetNativeView()->bounds().y(), | |
| 692 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().bottom()); | |
| 693 } | 666 } |
| 694 | 667 |
| 695 // Test that switching to a different visibility state does not restart the | 668 // Test that switching to a different visibility state does not restart the |
| 696 // shelf show / hide animation if it is already running. (crbug.com/250918) | 669 // shelf show / hide animation if it is already running. (crbug.com/250918) |
| 697 TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) { | 670 TEST_F(ShelfLayoutManagerTest, SetStateWhileAnimating) { |
| 698 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 671 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 699 SetState(layout_manager, SHELF_VISIBLE); | 672 SetState(layout_manager, SHELF_VISIBLE); |
| 700 ShelfWidget* shelf_widget = GetShelfWidget(); | 673 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 701 gfx::Rect initial_shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); | 674 gfx::Rect initial_shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); |
| 702 gfx::Rect initial_status_bounds = | 675 gfx::Rect initial_status_bounds = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 725 Shelf* shelf = GetShelf(); | 698 Shelf* shelf = GetShelf(); |
| 726 ASSERT_TRUE(shelf); | 699 ASSERT_TRUE(shelf); |
| 727 ShelfWidget* shelf_widget = GetShelfWidget(); | 700 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 728 ASSERT_TRUE(shelf_widget); | 701 ASSERT_TRUE(shelf_widget); |
| 729 ASSERT_TRUE(shelf_widget->status_area_widget()); | 702 ASSERT_TRUE(shelf_widget->status_area_widget()); |
| 730 shelf_widget->status_area_widget()->SetBounds(gfx::Rect(0, 0, 200, 200)); | 703 shelf_widget->status_area_widget()->SetBounds(gfx::Rect(0, 0, 200, 200)); |
| 731 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - | 704 EXPECT_EQ(200, shelf_widget->GetContentsView()->width() - |
| 732 test::ShelfTestAPI(shelf).shelf_view()->width()); | 705 test::ShelfTestAPI(shelf).shelf_view()->width()); |
| 733 } | 706 } |
| 734 | 707 |
| 735 #if defined(OS_WIN) | |
| 736 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | |
| 737 #define MAYBE_AutoHide DISABLED_AutoHide | |
| 738 #else | |
| 739 #define MAYBE_AutoHide AutoHide | |
| 740 #endif | |
| 741 | |
| 742 // Various assertions around auto-hide. | 708 // Various assertions around auto-hide. |
| 743 TEST_F(ShelfLayoutManagerTest, MAYBE_AutoHide) { | 709 TEST_F(ShelfLayoutManagerTest, AutoHide) { |
| 744 aura::Window* root = Shell::GetPrimaryRootWindow(); | 710 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 745 ui::test::EventGenerator generator(root, root); | |
| 746 generator.MoveMouseTo(0, 0); | |
| 747 | 711 |
| 748 Shelf* shelf = GetShelf(); | 712 Shelf* shelf = GetShelf(); |
| 749 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 713 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 750 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 714 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 751 views::Widget* widget = new views::Widget; | 715 views::Widget* widget = CreateTestWidget(); |
| 752 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
| 753 params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 754 params.context = CurrentContext(); | |
| 755 // Widget is now owned by the parent window. | |
| 756 widget->Init(params); | |
| 757 widget->Maximize(); | 716 widget->Maximize(); |
| 758 widget->Show(); | |
| 759 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 717 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 760 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 718 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 761 | 719 |
| 762 // LayoutShelf() forces the animation to completion, at which point the | 720 // LayoutShelf() forces the animation to completion, at which point the |
| 763 // shelf should go off the screen. | 721 // shelf should go off the screen. |
| 764 layout_manager->LayoutShelf(); | 722 layout_manager->LayoutShelf(); |
| 765 int shelf_insets = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); | 723 int shelf_insets = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
| 766 | 724 |
| 725 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 767 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, | 726 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, |
| 768 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 727 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 728 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 769 EXPECT_EQ(root->bounds().bottom() - shelf_insets, | 729 EXPECT_EQ(root->bounds().bottom() - shelf_insets, |
| 770 display::Screen::GetScreen() | 730 display.work_area().bottom()); |
| 771 ->GetDisplayNearestWindow(root) | |
| 772 .work_area() | |
| 773 .bottom()); | |
| 774 | 731 |
| 775 // Move the mouse to the bottom of the screen. | 732 // Move the mouse to the bottom of the screen. |
| 776 generator.MoveMouseTo(0, root->bounds().bottom() - 1); | 733 generator.MoveMouseTo(0, root->bounds().bottom() - 1); |
| 777 | 734 |
| 778 // Shelf should be shown again (but it shouldn't have changed the work area). | 735 // Shelf should be shown again (but it shouldn't have changed the work area). |
| 779 SetState(layout_manager, SHELF_AUTO_HIDE); | 736 SetState(layout_manager, SHELF_AUTO_HIDE); |
| 780 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 737 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 781 layout_manager->LayoutShelf(); | 738 layout_manager->LayoutShelf(); |
| 782 EXPECT_EQ(root->bounds().bottom() - layout_manager->GetIdealBounds().height(), | 739 EXPECT_EQ(root->bounds().bottom() - layout_manager->GetIdealBounds().height(), |
| 783 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 740 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 784 EXPECT_EQ(root->bounds().bottom() - shelf_insets, | 741 EXPECT_EQ(root->bounds().bottom() - shelf_insets, |
| 785 display::Screen::GetScreen() | 742 display.work_area().bottom()); |
| 786 ->GetDisplayNearestWindow(root) | |
| 787 .work_area() | |
| 788 .bottom()); | |
| 789 | 743 |
| 790 // Move mouse back up. | 744 // Move mouse back up. |
| 791 generator.MoveMouseTo(0, 0); | 745 generator.MoveMouseTo(0, 0); |
| 792 SetState(layout_manager, SHELF_AUTO_HIDE); | 746 SetState(layout_manager, SHELF_AUTO_HIDE); |
| 793 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 747 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 794 layout_manager->LayoutShelf(); | 748 layout_manager->LayoutShelf(); |
| 795 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, | 749 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, |
| 796 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 750 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 797 | 751 |
| 798 // Drag mouse to bottom of screen. | 752 // Drag mouse to bottom of screen. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 | 854 |
| 901 // Moving to the left edge of the secondary display without first crossing | 855 // Moving to the left edge of the secondary display without first crossing |
| 902 // the primary display's right aligned shelf first should not show the shelf. | 856 // the primary display's right aligned shelf first should not show the shelf. |
| 903 generator.MoveMouseTo(right_edge + 2, y); | 857 generator.MoveMouseTo(right_edge + 2, y); |
| 904 UpdateAutoHideStateNow(); | 858 UpdateAutoHideStateNow(); |
| 905 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 859 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 906 } | 860 } |
| 907 | 861 |
| 908 // Assertions around the lock screen showing. | 862 // Assertions around the lock screen showing. |
| 909 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { | 863 TEST_F(ShelfLayoutManagerTest, VisibleWhenLockScreenShowing) { |
| 910 if (!SupportsHostWindowResize()) | |
| 911 return; | |
| 912 | |
| 913 // Since ShelfLayoutManager queries for mouse location, move the mouse so | |
| 914 // it isn't over the shelf. | |
| 915 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | |
| 916 gfx::Point()); | |
| 917 generator.MoveMouseTo(0, 0); | |
| 918 | |
| 919 Shelf* shelf = GetShelf(); | 864 Shelf* shelf = GetShelf(); |
| 920 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 865 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 921 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 866 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 922 views::Widget* widget = new views::Widget; | 867 views::Widget* widget = CreateTestWidget(); |
| 923 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
| 924 params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 925 params.context = CurrentContext(); | |
| 926 // Widget is now owned by the parent window. | |
| 927 widget->Init(params); | |
| 928 widget->Maximize(); | 868 widget->Maximize(); |
| 929 widget->Show(); | |
| 930 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 869 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 931 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 870 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 932 | 871 |
| 933 aura::Window* root = Shell::GetPrimaryRootWindow(); | 872 aura::Window* root = Shell::GetPrimaryRootWindow(); |
| 934 // LayoutShelf() forces the animation to completion, at which point the | 873 // LayoutShelf() forces the animation to completion, at which point the |
| 935 // shelf should go off the screen. | 874 // shelf should go off the screen. |
| 936 layout_manager->LayoutShelf(); | 875 layout_manager->LayoutShelf(); |
| 937 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, | 876 EXPECT_EQ(root->bounds().bottom() - kShelfAutoHideSize, |
| 938 GetShelfWidget()->GetWindowBoundsInScreen().y()); | 877 GetShelfWidget()->GetWindowBoundsInScreen().y()); |
| 939 | 878 |
| 940 aura::Window* lock_container = Shell::GetContainer( | 879 std::unique_ptr<views::Widget> lock_widget(AshTestBase::CreateTestWidget( |
| 941 Shell::GetPrimaryRootWindow(), kShellWindowId_LockScreenContainer); | 880 nullptr, kShellWindowId_LockScreenContainer, gfx::Rect(200, 200))); |
| 942 | |
| 943 views::Widget* lock_widget = new views::Widget; | |
| 944 views::Widget::InitParams lock_params(views::Widget::InitParams::TYPE_WINDOW); | |
| 945 lock_params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 946 params.context = CurrentContext(); | |
| 947 lock_params.parent = lock_container; | |
| 948 // Widget is now owned by the parent window. | |
| 949 lock_widget->Init(lock_params); | |
| 950 lock_widget->Maximize(); | 881 lock_widget->Maximize(); |
| 951 lock_widget->Show(); | |
| 952 | 882 |
| 953 // Lock the screen. | 883 // Lock the screen. |
| 954 LockScreen(); | 884 LockScreen(); |
| 955 // Showing a widget in the lock screen should force the shelf to be visibile. | 885 // Showing a widget in the lock screen should force the shelf to be visibile. |
| 956 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 886 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 957 | 887 |
| 958 UnlockScreen(); | 888 UnlockScreen(); |
| 959 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 889 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 960 } | 890 } |
| 961 | 891 |
| 962 // Assertions around SetAutoHideBehavior. | 892 // Assertions around SetAutoHideBehavior. |
| 963 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { | 893 TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { |
| 964 // Since ShelfLayoutManager queries for mouse location, move the mouse so | |
| 965 // it isn't over the shelf. | |
| 966 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | |
| 967 gfx::Point()); | |
| 968 generator.MoveMouseTo(0, 0); | |
| 969 | |
| 970 Shelf* shelf = GetShelf(); | 894 Shelf* shelf = GetShelf(); |
| 971 views::Widget* widget = new views::Widget; | 895 views::Widget* widget = CreateTestWidget(); |
| 972 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
| 973 params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 974 params.context = CurrentContext(); | |
| 975 // Widget is now owned by the parent window. | |
| 976 widget->Init(params); | |
| 977 widget->Show(); | |
| 978 aura::Window* window = widget->GetNativeWindow(); | |
| 979 | 896 |
| 980 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 897 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 981 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 898 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 982 | 899 |
| 983 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 900 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 984 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 901 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 985 | 902 |
| 986 widget->Maximize(); | 903 widget->Maximize(); |
| 987 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 904 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 988 EXPECT_EQ(display::Screen::GetScreen() | 905 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 989 ->GetDisplayNearestWindow(window) | 906 EXPECT_EQ(display.work_area().bottom(), |
| 990 .work_area() | |
| 991 .bottom(), | |
| 992 widget->GetWorkAreaBoundsInScreen().bottom()); | 907 widget->GetWorkAreaBoundsInScreen().bottom()); |
| 993 | 908 |
| 994 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 909 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 995 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 910 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 996 EXPECT_EQ(display::Screen::GetScreen() | 911 EXPECT_EQ(display.work_area().bottom(), |
| 997 ->GetDisplayNearestWindow(window) | |
| 998 .work_area() | |
| 999 .bottom(), | |
| 1000 widget->GetWorkAreaBoundsInScreen().bottom()); | 912 widget->GetWorkAreaBoundsInScreen().bottom()); |
| 1001 | 913 |
| 1002 ui::ScopedAnimationDurationScaleMode animation_duration( | 914 ui::ScopedAnimationDurationScaleMode animation_duration( |
| 1003 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); | 915 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION); |
| 1004 | 916 |
| 1005 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 917 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1006 ShelfWidget* shelf_widget = GetShelfWidget(); | 918 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 1007 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); | 919 EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible()); |
| 1008 StepWidgetLayerAnimatorToEnd(shelf_widget); | 920 StepWidgetLayerAnimatorToEnd(shelf_widget); |
| 1009 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); | 921 StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget()); |
| 1010 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 922 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1011 EXPECT_EQ(display::Screen::GetScreen() | 923 EXPECT_EQ(display.work_area().bottom(), |
| 1012 ->GetDisplayNearestWindow(window) | |
| 1013 .work_area() | |
| 1014 .bottom(), | |
| 1015 widget->GetWorkAreaBoundsInScreen().bottom()); | 924 widget->GetWorkAreaBoundsInScreen().bottom()); |
| 1016 } | 925 } |
| 1017 | 926 |
| 1018 // Basic assertions around the dimming of the shelf. | 927 // Basic assertions around the dimming of the shelf. |
| 1019 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) { | 928 TEST_F(ShelfLayoutManagerTest, DimmingBehavior) { |
| 1020 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 929 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 1021 // it isn't over the shelf. | 930 views::Widget* widget = CreateTestWidget(); |
| 1022 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | |
| 1023 gfx::Point()); | |
| 1024 generator.MoveMouseTo(0, 0); | |
| 1025 | 931 |
| 1026 ShelfWidget* shelf_widget = GetShelfWidget(); | 932 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 1027 shelf_widget->DisableDimmingAnimationsForTest(); | 933 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1028 | 934 gfx::Point off_shelf = display.bounds().CenterPoint(); |
| 1029 views::Widget* widget = new views::Widget; | |
| 1030 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
| 1031 params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 1032 params.context = CurrentContext(); | |
| 1033 // Widget is now owned by the parent window. | |
| 1034 widget->Init(params); | |
| 1035 widget->Show(); | |
| 1036 aura::Window* window = widget->GetNativeWindow(); | |
| 1037 gfx::Rect display_bounds( | |
| 1038 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); | |
| 1039 | |
| 1040 gfx::Point off_shelf = display_bounds.CenterPoint(); | |
| 1041 gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); | 935 gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); |
| 1042 | 936 |
| 1043 // Test there is no dimming object active at this point. | 937 // Test that the shelf is not dimmed at this point. |
| 1044 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 938 generator.MoveMouseTo(on_shelf); |
| 1045 EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest()); | 939 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1046 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | 940 generator.MoveMouseTo(off_shelf); |
| 1047 EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest()); | 941 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1048 | 942 |
| 1049 // After maximization, the shelf should be visible and the dimmer created. | 943 // Maximizing the window should dim the shelf. |
| 1050 widget->Maximize(); | 944 widget->Maximize(); |
| 945 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 1051 | 946 |
| 1052 on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); | 947 // Mouse move events outside the shelf should keep the shelf dimmed. |
| 1053 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | 948 generator.MoveMouseTo(off_shelf.x() + 10, off_shelf.y() + 10); |
| 949 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 1054 | 950 |
| 1055 // Moving the mouse off the shelf should dim the bar. | 951 // Mouse move events inside the shelf should undim the shelf. |
| 1056 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | 952 generator.MoveMouseTo(on_shelf); |
| 1057 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | 953 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1058 | 954 |
| 1059 // Adding touch events outside the shelf should still keep the shelf in | 955 // Mouse drags starting outside the shelf are not captured. |
| 1060 // dimmed state. | 956 generator.MoveMouseTo(off_shelf); |
| 957 generator.PressLeftButton(); |
| 958 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 959 generator.MoveMouseTo(on_shelf); |
| 960 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 961 generator.MoveMouseTo(off_shelf); |
| 962 generator.ReleaseLeftButton(); |
| 963 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 964 |
| 965 // Mouse drags starting inside the shelf are captured. |
| 966 generator.MoveMouseTo(on_shelf); |
| 967 generator.PressLeftButton(); |
| 968 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 969 generator.MoveMouseTo(off_shelf); |
| 970 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 971 generator.MoveMouseTo(on_shelf); |
| 972 generator.ReleaseLeftButton(); |
| 973 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 974 |
| 975 // Touch drags outside the shelf should keep the shelf dimmed. |
| 976 generator.MoveTouch(off_shelf); |
| 1061 generator.PressTouch(); | 977 generator.PressTouch(); |
| 978 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 979 generator.MoveTouch(gfx::Point(off_shelf.x() + 10, off_shelf.y() + 10)); |
| 980 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 1062 generator.MoveTouch(off_shelf); | 981 generator.MoveTouch(off_shelf); |
| 1063 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | 982 generator.ReleaseTouch(); |
| 1064 // Move the touch into the shelf area should undim. | 983 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 984 |
| 985 // Touch drags inside the shelf should undim the shelf until release. |
| 1065 generator.MoveTouch(on_shelf); | 986 generator.MoveTouch(on_shelf); |
| 1066 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
| 1067 generator.ReleaseTouch(); | |
| 1068 // And a release dims again. | |
| 1069 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | |
| 1070 | |
| 1071 // Moving the mouse on the shelf should undim the bar. | |
| 1072 generator.MoveMouseTo(on_shelf); | |
| 1073 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
| 1074 | |
| 1075 // No matter what the touch events do, the shelf should stay undimmed. | |
| 1076 generator.PressTouch(); | 987 generator.PressTouch(); |
| 1077 generator.MoveTouch(off_shelf); | 988 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1078 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 989 generator.MoveTouch(gfx::Point(on_shelf.x() + 1, on_shelf.y() + 1)); |
| 1079 generator.MoveTouch(on_shelf); | 990 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1080 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
| 1081 generator.MoveTouch(off_shelf); | |
| 1082 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | |
| 1083 generator.MoveTouch(on_shelf); | 991 generator.MoveTouch(on_shelf); |
| 1084 generator.ReleaseTouch(); | 992 generator.ReleaseTouch(); |
| 993 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 1085 | 994 |
| 1086 // After restore, the dimming object should be deleted again. | 995 // After restore, the shelf should be undimmed. |
| 996 generator.MoveMouseTo(off_shelf); |
| 997 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 1087 widget->Restore(); | 998 widget->Restore(); |
| 1088 EXPECT_EQ(-1, shelf_widget->GetDimmingAlphaForTest()); | 999 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1089 } | 1000 } |
| 1090 | 1001 |
| 1091 // Test that dimming works correctly with multiple displays. | 1002 // Test that dimming works correctly with multiple displays. |
| 1092 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { | 1003 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) { |
| 1093 if (!SupportsMultipleDisplays()) | 1004 if (!SupportsMultipleDisplays()) |
| 1094 return; | 1005 return; |
| 1095 | 1006 |
| 1096 // Create two displays. | 1007 // Create two displays. |
| 1097 Shell* shell = Shell::GetInstance(); | 1008 UpdateDisplay("0+0-300x300,+600+0-300x300"); |
| 1098 UpdateDisplay("0+0-200x200,+200+0-100x100"); | 1009 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1099 EXPECT_EQ(2U, shell->display_manager()->GetNumDisplays()); | |
| 1100 | |
| 1101 WindowTreeHostManager* window_tree_host_manager = | |
| 1102 shell->window_tree_host_manager(); | |
| 1103 aura::Window::Windows root_windows = | |
| 1104 window_tree_host_manager->GetAllRootWindows(); | |
| 1105 EXPECT_EQ(root_windows.size(), 2U); | 1010 EXPECT_EQ(root_windows.size(), 2U); |
| 1106 | 1011 |
| 1107 std::vector<ShelfWidget*> shelf_widgets; | 1012 std::vector<ShelfWidget*> shelf_widgets; |
| 1108 for (auto* root_window : root_windows) { | 1013 for (auto* root_window : root_windows) { |
| 1109 ShelfLayoutManager* shelf = | 1014 ShelfLayoutManager* shelf = |
| 1110 GetRootWindowController(root_window)->GetShelfLayoutManager(); | 1015 GetRootWindowController(root_window)->GetShelfLayoutManager(); |
| 1111 shelf_widgets.push_back(shelf->shelf_widget()); | 1016 shelf_widgets.push_back(shelf->shelf_widget()); |
| 1112 | 1017 // Force the shelf to enable dimming with a maximized window background. |
| 1113 // For disabling the dimming animation to work, the animation must be | 1018 shelf->shelf_widget()->SetPaintsBackground(SHELF_BACKGROUND_MAXIMIZED, |
| 1114 // disabled prior to creating the dimmer. | 1019 BACKGROUND_CHANGE_IMMEDIATE); |
| 1115 shelf_widgets.back()->DisableDimmingAnimationsForTest(); | |
| 1116 | |
| 1117 // Create a maximized window to create the dimmer. | |
| 1118 views::Widget* widget = new views::Widget; | |
| 1119 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
| 1120 params.context = root_window; | |
| 1121 params.bounds = root_window->GetBoundsInScreen(); | |
| 1122 params.show_state = ui::SHOW_STATE_MAXIMIZED; | |
| 1123 widget->Init(params); | |
| 1124 widget->Show(); | |
| 1125 } | 1020 } |
| 1126 | 1021 |
| 1127 ui::test::EventGenerator& generator(GetEventGenerator()); | 1022 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 1128 | |
| 1129 generator.MoveMouseTo(root_windows[0]->GetBoundsInScreen().CenterPoint()); | 1023 generator.MoveMouseTo(root_windows[0]->GetBoundsInScreen().CenterPoint()); |
| 1130 EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | 1024 EXPECT_TRUE(shelf_widgets[0]->GetDimsShelf()); |
| 1131 EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | 1025 EXPECT_TRUE(shelf_widgets[1]->GetDimsShelf()); |
| 1132 | 1026 |
| 1133 generator.MoveMouseTo( | 1027 generator.MoveMouseTo( |
| 1134 shelf_widgets[0]->GetWindowBoundsInScreen().CenterPoint()); | 1028 shelf_widgets[0]->GetWindowBoundsInScreen().CenterPoint()); |
| 1135 EXPECT_EQ(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | 1029 EXPECT_FALSE(shelf_widgets[0]->GetDimsShelf()); |
| 1136 EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | 1030 EXPECT_TRUE(shelf_widgets[1]->GetDimsShelf()); |
| 1031 |
| 1032 generator.MoveMouseTo(root_windows[0]->GetBoundsInScreen().CenterPoint()); |
| 1033 EXPECT_TRUE(shelf_widgets[0]->GetDimsShelf()); |
| 1034 EXPECT_TRUE(shelf_widgets[1]->GetDimsShelf()); |
| 1035 |
| 1036 generator.MoveMouseTo(root_windows[1]->GetBoundsInScreen().CenterPoint()); |
| 1037 EXPECT_TRUE(shelf_widgets[0]->GetDimsShelf()); |
| 1038 EXPECT_TRUE(shelf_widgets[1]->GetDimsShelf()); |
| 1137 | 1039 |
| 1138 generator.MoveMouseTo( | 1040 generator.MoveMouseTo( |
| 1139 shelf_widgets[1]->GetWindowBoundsInScreen().CenterPoint()); | 1041 shelf_widgets[1]->GetWindowBoundsInScreen().CenterPoint()); |
| 1140 EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | 1042 EXPECT_TRUE(shelf_widgets[0]->GetDimsShelf()); |
| 1141 EXPECT_EQ(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | 1043 EXPECT_FALSE(shelf_widgets[1]->GetDimsShelf()); |
| 1142 | 1044 |
| 1143 generator.MoveMouseTo(root_windows[1]->GetBoundsInScreen().CenterPoint()); | 1045 generator.MoveMouseTo(root_windows[1]->GetBoundsInScreen().CenterPoint()); |
| 1144 EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest()); | 1046 EXPECT_TRUE(shelf_widgets[0]->GetDimsShelf()); |
| 1145 EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest()); | 1047 EXPECT_TRUE(shelf_widgets[1]->GetDimsShelf()); |
| 1146 } | 1048 } |
| 1147 | 1049 |
| 1148 // Assertions around the dimming of the shelf in conjunction with menus. | 1050 // Assertions around the dimming of the shelf in conjunction with menus. |
| 1149 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) { | 1051 TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) { |
| 1150 // Since ShelfLayoutManager queries for mouse location, move the mouse so | 1052 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 1151 // it isn't over the shelf. | 1053 |
| 1152 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 1054 // Maximize a widget to make shelf dimming possible. |
| 1153 gfx::Point()); | 1055 views::Widget* widget = CreateTestWidget(); |
| 1154 generator.MoveMouseTo(0, 0); | 1056 widget->Maximize(); |
| 1155 | 1057 |
| 1156 ShelfWidget* shelf_widget = GetShelfWidget(); | 1058 ShelfWidget* shelf_widget = GetShelfWidget(); |
| 1157 shelf_widget->DisableDimmingAnimationsForTest(); | 1059 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1158 | 1060 gfx::Point off_shelf = display.bounds().CenterPoint(); |
| 1159 views::Widget* widget = new views::Widget; | |
| 1160 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
| 1161 params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 1162 params.context = CurrentContext(); | |
| 1163 // Widget is now owned by the parent window. | |
| 1164 widget->Init(params); | |
| 1165 widget->Show(); | |
| 1166 aura::Window* window = widget->GetNativeWindow(); | |
| 1167 gfx::Rect display_bounds( | |
| 1168 display::Screen::GetScreen()->GetDisplayNearestWindow(window).bounds()); | |
| 1169 | |
| 1170 // After maximization, the shelf should be visible and the dimmer created. | |
| 1171 widget->Maximize(); | |
| 1172 | |
| 1173 gfx::Point off_shelf = display_bounds.CenterPoint(); | |
| 1174 gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); | 1061 gfx::Point on_shelf = shelf_widget->GetWindowBoundsInScreen().CenterPoint(); |
| 1175 | 1062 |
| 1176 // Moving the mouse on the shelf should undim the bar. | 1063 // Moving the mouse on the shelf should undim the bar. |
| 1177 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 1064 generator.MoveMouseTo(on_shelf); |
| 1178 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1065 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1179 | 1066 |
| 1180 // Simulate a menu opening. | 1067 // Simulate a menu opening. |
| 1181 shelf_widget->ForceUndimming(true); | 1068 shelf_widget->ForceUndimming(true); |
| 1182 | 1069 |
| 1183 // Moving the mouse off the shelf should not dim the bar. | 1070 // Moving the mouse off the shelf should not dim the bar. |
| 1184 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | 1071 generator.MoveMouseTo(off_shelf); |
| 1185 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1072 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1186 | 1073 |
| 1187 // No matter what the touch events do, the shelf should stay undimmed. | 1074 // No matter what the touch events do, the shelf should stay undimmed. |
| 1188 generator.PressTouch(); | 1075 generator.PressTouch(); |
| 1189 generator.MoveTouch(off_shelf); | 1076 generator.MoveTouch(off_shelf); |
| 1190 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1077 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1191 generator.MoveTouch(on_shelf); | 1078 generator.MoveTouch(on_shelf); |
| 1192 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1079 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1193 generator.MoveTouch(off_shelf); | 1080 generator.MoveTouch(off_shelf); |
| 1194 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1081 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1195 generator.ReleaseTouch(); | 1082 generator.ReleaseTouch(); |
| 1196 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1083 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1197 | 1084 |
| 1198 // "Closing the menu" should now turn off the menu since no event is inside | 1085 // "Closing the menu" should now turn off the menu since no event is inside |
| 1199 // the shelf any longer. | 1086 // the shelf any longer. |
| 1200 shelf_widget->ForceUndimming(false); | 1087 shelf_widget->ForceUndimming(false); |
| 1201 EXPECT_LT(0, shelf_widget->GetDimmingAlphaForTest()); | 1088 EXPECT_TRUE(shelf_widget->GetDimsShelf()); |
| 1202 | 1089 |
| 1203 // Moving the mouse again on the shelf which should undim the bar again. | 1090 // Moving the mouse again on the shelf which should undim the bar again. |
| 1204 // This time we check that the bar stays undimmed when the mouse remains on | 1091 // This time we check that the bar stays undimmed when the mouse remains on |
| 1205 // the bar and the "menu gets closed". | 1092 // the bar and the "menu gets closed". |
| 1206 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 1093 generator.MoveMouseTo(on_shelf); |
| 1207 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1094 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1208 shelf_widget->ForceUndimming(true); | 1095 shelf_widget->ForceUndimming(true); |
| 1209 generator.MoveMouseTo(off_shelf.x(), off_shelf.y()); | 1096 generator.MoveMouseTo(off_shelf); |
| 1210 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1097 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1211 generator.MoveMouseTo(on_shelf.x(), on_shelf.y()); | 1098 generator.MoveMouseTo(on_shelf); |
| 1212 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1099 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1213 shelf_widget->ForceUndimming(true); | 1100 shelf_widget->ForceUndimming(true); |
| 1214 EXPECT_EQ(0, shelf_widget->GetDimmingAlphaForTest()); | 1101 EXPECT_FALSE(shelf_widget->GetDimsShelf()); |
| 1215 } | 1102 } |
| 1216 | 1103 |
| 1217 // Verifies the shelf is visible when status/shelf is focused. | 1104 // Verifies the shelf is visible when status/shelf is focused. |
| 1218 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { | 1105 TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrShelfFocused) { |
| 1219 // Since ShelfLayoutManager queries for mouse location, move the mouse so | |
| 1220 // it isn't over the shelf. | |
| 1221 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | |
| 1222 gfx::Point()); | |
| 1223 generator.MoveMouseTo(0, 0); | |
| 1224 | |
| 1225 Shelf* shelf = GetShelf(); | 1106 Shelf* shelf = GetShelf(); |
| 1226 views::Widget* widget = new views::Widget; | 1107 views::Widget* widget = CreateTestWidget(); |
| 1227 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
| 1228 params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 1229 params.context = CurrentContext(); | |
| 1230 // Widget is now owned by the parent window. | |
| 1231 widget->Init(params); | |
| 1232 widget->Show(); | |
| 1233 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1108 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1234 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1109 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 1235 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 1110 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 1236 | 1111 |
| 1237 // Focus the shelf. Have to go through the focus cycler as normal focus | 1112 // Focus the shelf. Have to go through the focus cycler as normal focus |
| 1238 // requests to it do nothing. | 1113 // requests to it do nothing. |
| 1239 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); | 1114 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); |
| 1240 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 1115 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 1241 | 1116 |
| 1242 widget->Activate(); | 1117 widget->Activate(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 if (!SupportsMultipleDisplays()) | 1196 if (!SupportsMultipleDisplays()) |
| 1322 return; | 1197 return; |
| 1323 | 1198 |
| 1324 // Create two displays. | 1199 // Create two displays. |
| 1325 Shell* shell = Shell::GetInstance(); | 1200 Shell* shell = Shell::GetInstance(); |
| 1326 DisplayManager* display_manager = shell->display_manager(); | 1201 DisplayManager* display_manager = shell->display_manager(); |
| 1327 EXPECT_EQ(1U, display_manager->GetNumDisplays()); | 1202 EXPECT_EQ(1U, display_manager->GetNumDisplays()); |
| 1328 UpdateDisplay("0+0-200x200,+200+0-100x100"); | 1203 UpdateDisplay("0+0-200x200,+200+0-100x100"); |
| 1329 EXPECT_EQ(2U, display_manager->GetNumDisplays()); | 1204 EXPECT_EQ(2U, display_manager->GetNumDisplays()); |
| 1330 | 1205 |
| 1331 WindowTreeHostManager* window_tree_host_manager = | 1206 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1332 shell->window_tree_host_manager(); | |
| 1333 aura::Window::Windows root_windows = | |
| 1334 window_tree_host_manager->GetAllRootWindows(); | |
| 1335 EXPECT_EQ(root_windows.size(), 2U); | 1207 EXPECT_EQ(root_windows.size(), 2U); |
| 1336 | 1208 |
| 1337 // Get the shelves in both displays and set them to be 'AutoHide'. | 1209 // Get the shelves in both displays and set them to be 'AutoHide'. |
| 1338 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->GetShelf(); | 1210 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->GetShelf(); |
| 1339 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->GetShelf(); | 1211 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->GetShelf(); |
| 1340 EXPECT_NE(shelf_1, shelf_2); | 1212 EXPECT_NE(shelf_1, shelf_2); |
| 1341 EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), | 1213 EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), |
| 1342 shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); | 1214 shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); |
| 1343 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1215 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1344 shelf_1->shelf_layout_manager()->LayoutShelf(); | 1216 shelf_1->shelf_layout_manager()->LayoutShelf(); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { | 1324 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { |
| 1453 if (!SupportsMultipleDisplays()) | 1325 if (!SupportsMultipleDisplays()) |
| 1454 return; | 1326 return; |
| 1455 | 1327 |
| 1456 // Create two displays. | 1328 // Create two displays. |
| 1457 Shell* shell = Shell::GetInstance(); | 1329 Shell* shell = Shell::GetInstance(); |
| 1458 DisplayManager* display_manager = shell->display_manager(); | 1330 DisplayManager* display_manager = shell->display_manager(); |
| 1459 UpdateDisplay("200x200,100x100"); | 1331 UpdateDisplay("200x200,100x100"); |
| 1460 EXPECT_EQ(2U, display_manager->GetNumDisplays()); | 1332 EXPECT_EQ(2U, display_manager->GetNumDisplays()); |
| 1461 | 1333 |
| 1462 WindowTreeHostManager* window_tree_host_manager = | 1334 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1463 shell->window_tree_host_manager(); | |
| 1464 aura::Window::Windows root_windows = | |
| 1465 window_tree_host_manager->GetAllRootWindows(); | |
| 1466 EXPECT_EQ(2U, root_windows.size()); | 1335 EXPECT_EQ(2U, root_windows.size()); |
| 1467 | 1336 |
| 1468 // Get the shelves in both displays and set them to be 'AutoHide'. | 1337 // Get the shelves in both displays and set them to be 'AutoHide'. |
| 1469 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->GetShelf(); | 1338 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->GetShelf(); |
| 1470 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->GetShelf(); | 1339 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->GetShelf(); |
| 1471 EXPECT_NE(shelf_1, shelf_2); | 1340 EXPECT_NE(shelf_1, shelf_2); |
| 1472 EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), | 1341 EXPECT_NE(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), |
| 1473 shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); | 1342 shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow()); |
| 1474 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1343 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1475 shelf_1->shelf_layout_manager()->LayoutShelf(); | 1344 shelf_1->shelf_layout_manager()->LayoutShelf(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 | 1446 |
| 1578 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1447 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1579 | 1448 |
| 1580 wm::PinWindow(window1); | 1449 wm::PinWindow(window1); |
| 1581 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 1450 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
| 1582 | 1451 |
| 1583 WmWindowAura::Get(window1)->GetWindowState()->Restore(); | 1452 WmWindowAura::Get(window1)->GetWindowState()->Restore(); |
| 1584 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1453 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1585 } | 1454 } |
| 1586 | 1455 |
| 1587 #if defined(OS_WIN) | |
| 1588 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | |
| 1589 #define MAYBE_SetAlignment DISABLED_SetAlignment | |
| 1590 #else | |
| 1591 #define MAYBE_SetAlignment SetAlignment | |
| 1592 #endif | |
| 1593 | |
| 1594 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). | 1456 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). |
| 1595 TEST_F(ShelfLayoutManagerTest, MAYBE_SetAlignment) { | 1457 TEST_F(ShelfLayoutManagerTest, SetAlignment) { |
| 1596 Shelf* shelf = GetShelf(); | 1458 Shelf* shelf = GetShelf(); |
| 1597 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1459 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1598 // Force an initial layout. | 1460 // Force an initial layout. |
| 1599 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1461 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1600 layout_manager->LayoutShelf(); | 1462 layout_manager->LayoutShelf(); |
| 1601 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1463 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1602 | 1464 |
| 1603 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1465 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 1604 gfx::Rect shelf_bounds(GetShelfWidget()->GetWindowBoundsInScreen()); | 1466 gfx::Rect shelf_bounds(GetShelfWidget()->GetWindowBoundsInScreen()); |
| 1605 const display::Screen* screen = display::Screen::GetScreen(); | 1467 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 1606 display::Display display = | |
| 1607 screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 1608 ASSERT_NE(-1, display.id()); | 1468 ASSERT_NE(-1, display.id()); |
| 1609 EXPECT_EQ(layout_manager->GetIdealBounds().width(), | 1469 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| 1610 display.GetWorkAreaInsets().left()); | 1470 display.GetWorkAreaInsets().left()); |
| 1611 EXPECT_GE(shelf_bounds.width(), | 1471 EXPECT_GE(shelf_bounds.width(), |
| 1612 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); | 1472 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| 1613 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); | 1473 EXPECT_EQ(SHELF_ALIGNMENT_LEFT, GetSystemTray()->shelf_alignment()); |
| 1614 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); | 1474 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| 1615 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); | 1475 gfx::Rect status_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 1616 EXPECT_GE(status_bounds.width(), | 1476 EXPECT_GE(status_bounds.width(), |
| 1617 status_area_widget->GetContentsView()->GetPreferredSize().width()); | 1477 status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 1618 EXPECT_EQ(layout_manager->GetIdealBounds().width(), | 1478 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| 1619 display.GetWorkAreaInsets().left()); | 1479 display.GetWorkAreaInsets().left()); |
| 1620 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 1480 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 1621 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 1481 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1622 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); | 1482 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); |
| 1623 EXPECT_EQ(display.bounds().x(), shelf_bounds.x()); | 1483 EXPECT_EQ(display.bounds().x(), shelf_bounds.x()); |
| 1624 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); | 1484 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); |
| 1625 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); | 1485 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); |
| 1626 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1486 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1627 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 1628 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), | 1487 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| 1629 display.GetWorkAreaInsets().left()); | 1488 display.GetWorkAreaInsets().left()); |
| 1630 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), | 1489 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| 1631 display.work_area().x()); | 1490 display.work_area().x()); |
| 1632 | 1491 |
| 1633 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1492 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1634 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 1493 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 1635 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 1636 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1494 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1637 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 1638 ASSERT_NE(-1, display.id()); | 1495 ASSERT_NE(-1, display.id()); |
| 1639 EXPECT_EQ(layout_manager->GetIdealBounds().width(), | 1496 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| 1640 display.GetWorkAreaInsets().right()); | 1497 display.GetWorkAreaInsets().right()); |
| 1641 EXPECT_GE(shelf_bounds.width(), | 1498 EXPECT_GE(shelf_bounds.width(), |
| 1642 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); | 1499 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); |
| 1643 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); | 1500 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetSystemTray()->shelf_alignment()); |
| 1644 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); | 1501 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); |
| 1645 EXPECT_GE(status_bounds.width(), | 1502 EXPECT_GE(status_bounds.width(), |
| 1646 status_area_widget->GetContentsView()->GetPreferredSize().width()); | 1503 status_area_widget->GetContentsView()->GetPreferredSize().width()); |
| 1647 EXPECT_EQ(layout_manager->GetIdealBounds().width(), | 1504 EXPECT_EQ(layout_manager->GetIdealBounds().width(), |
| 1648 display.GetWorkAreaInsets().right()); | 1505 display.GetWorkAreaInsets().right()); |
| 1649 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); | 1506 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); |
| 1650 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); | 1507 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); |
| 1651 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); | 1508 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); |
| 1652 EXPECT_EQ(display.work_area().right(), shelf_bounds.x()); | 1509 EXPECT_EQ(display.work_area().right(), shelf_bounds.x()); |
| 1653 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); | 1510 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); |
| 1654 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); | 1511 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); |
| 1655 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1512 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1656 display = screen->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()); | |
| 1657 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), | 1513 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| 1658 display.GetWorkAreaInsets().right()); | 1514 display.GetWorkAreaInsets().right()); |
| 1659 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), | 1515 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), |
| 1660 display.bounds().right() - display.work_area().right()); | 1516 display.bounds().right() - display.work_area().right()); |
| 1661 } | 1517 } |
| 1662 | 1518 |
| 1663 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) { | 1519 TEST_F(ShelfLayoutManagerTest, GestureEdgeSwipe) { |
| 1664 Shelf* shelf = GetShelf(); | 1520 Shelf* shelf = GetShelf(); |
| 1665 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1521 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1666 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1522 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1667 views::Widget* widget = new views::Widget; | 1523 views::Widget* widget = CreateTestWidget(); |
| 1668 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | |
| 1669 params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 1670 params.context = CurrentContext(); | |
| 1671 widget->Init(params); | |
| 1672 widget->Show(); | |
| 1673 widget->Maximize(); | 1524 widget->Maximize(); |
| 1674 | 1525 |
| 1675 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1526 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 1676 | 1527 |
| 1677 aura::Window* window = widget->GetNativeWindow(); | 1528 aura::Window* window = widget->GetNativeWindow(); |
| 1678 layout_manager->LayoutShelf(); | 1529 layout_manager->LayoutShelf(); |
| 1679 | 1530 |
| 1680 // Edge swipe when SHELF_VISIBLE should not change visibility state. | 1531 // Edge swipe when SHELF_VISIBLE should not change visibility state. |
| 1681 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1532 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1682 generator.GestureEdgeSwipe(); | 1533 generator.GestureEdgeSwipe(); |
| 1683 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1534 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1684 | 1535 |
| 1685 // Edge swipe when AUTO_HIDE_HIDDEN should change to AUTO_HIDE_SHOWN. | 1536 // Edge swipe when AUTO_HIDE_HIDDEN should change to AUTO_HIDE_SHOWN. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1764 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); | 1615 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); |
| 1765 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); | 1616 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); |
| 1766 | 1617 |
| 1767 monitor_2_generator.GestureEdgeSwipe(); | 1618 monitor_2_generator.GestureEdgeSwipe(); |
| 1768 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | 1619 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
| 1769 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); | 1620 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); |
| 1770 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); | 1621 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); |
| 1771 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_2->GetAutoHideState()); | 1622 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_2->GetAutoHideState()); |
| 1772 } | 1623 } |
| 1773 | 1624 |
| 1774 #if defined(OS_WIN) | 1625 TEST_F(ShelfLayoutManagerTest, GestureDrag) { |
| 1775 // RootWindow and Display can't resize on Windows Ash. http://crbug.com/165962 | |
| 1776 #define MAYBE_GestureDrag DISABLED_GestureDrag | |
| 1777 #else | |
| 1778 #define MAYBE_GestureDrag GestureDrag | |
| 1779 #endif | |
| 1780 | |
| 1781 TEST_F(ShelfLayoutManagerTest, MAYBE_GestureDrag) { | |
| 1782 // Slop is an implementation detail of gesture recognition, and complicates | 1626 // Slop is an implementation detail of gesture recognition, and complicates |
| 1783 // these tests. Ignore it. | 1627 // these tests. Ignore it. |
| 1784 ui::GestureConfiguration::GetInstance() | 1628 ui::GestureConfiguration::GetInstance() |
| 1785 ->set_max_touch_move_in_pixels_for_click(0); | 1629 ->set_max_touch_move_in_pixels_for_click(0); |
| 1786 Shelf* shelf = GetShelf(); | 1630 Shelf* shelf = GetShelf(); |
| 1787 { | 1631 { |
| 1788 SCOPED_TRACE("BOTTOM"); | 1632 SCOPED_TRACE("BOTTOM"); |
| 1789 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 1633 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 1790 RunGestureDragTests(gfx::Vector2d(0, 120)); | 1634 RunGestureDragTests(gfx::Vector2d(0, 120)); |
| 1791 } | 1635 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 window2->SetBounds(gfx::Rect(850, 50, 50, 50)); | 1697 window2->SetBounds(gfx::Rect(850, 50, 50, 50)); |
| 1854 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 1698 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 1855 // Move back to primary display. | 1699 // Move back to primary display. |
| 1856 window2->SetBounds(gfx::Rect(50, 50, 50, 50)); | 1700 window2->SetBounds(gfx::Rect(50, 50, 50, 50)); |
| 1857 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 1701 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 1858 } | 1702 } |
| 1859 | 1703 |
| 1860 // Test that the shelf animates back to its normal position upon a user | 1704 // Test that the shelf animates back to its normal position upon a user |
| 1861 // completing a gesture drag. | 1705 // completing a gesture drag. |
| 1862 TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) { | 1706 TEST_F(ShelfLayoutManagerTest, ShelfAnimatesWhenGestureComplete) { |
| 1863 if (!SupportsHostWindowResize()) | |
| 1864 return; | |
| 1865 | |
| 1866 // Test the shelf animates back to its original visible bounds when it is | 1707 // Test the shelf animates back to its original visible bounds when it is |
| 1867 // dragged when there are no visible windows. | 1708 // dragged when there are no visible windows. |
| 1868 Shelf* shelf = GetShelf(); | 1709 Shelf* shelf = GetShelf(); |
| 1869 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1710 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1870 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1711 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 1871 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 1712 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 1872 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1713 gfx::Rect visible_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1873 { | 1714 { |
| 1874 // Enable animations so that we can make sure that they occur. | 1715 // Enable animations so that we can make sure that they occur. |
| 1875 ui::ScopedAnimationDurationScaleMode regular_animations( | 1716 ui::ScopedAnimationDurationScaleMode regular_animations( |
| 1876 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 1717 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 1877 | 1718 |
| 1878 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1719 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 1879 gfx::Rect shelf_bounds_in_screen = | 1720 gfx::Rect shelf_bounds_in_screen = |
| 1880 GetShelfWidget()->GetWindowBoundsInScreen(); | 1721 GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1881 gfx::Point start(shelf_bounds_in_screen.CenterPoint()); | 1722 gfx::Point start(shelf_bounds_in_screen.CenterPoint()); |
| 1882 gfx::Point end(start.x(), shelf_bounds_in_screen.bottom()); | 1723 gfx::Point end(start.x(), shelf_bounds_in_screen.bottom()); |
| 1883 generator.GestureScrollSequence(start, end, | 1724 generator.GestureScrollSequence(start, end, |
| 1884 base::TimeDelta::FromMilliseconds(10), 5); | 1725 base::TimeDelta::FromMilliseconds(10), 5); |
| 1885 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1726 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 1886 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 1727 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 1887 | 1728 |
| 1888 ShelfAnimationWaiter waiter(visible_bounds); | 1729 ShelfAnimationWaiter waiter(visible_bounds); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1900 gfx::Rect auto_hidden_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); | 1741 gfx::Rect auto_hidden_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); |
| 1901 | 1742 |
| 1902 { | 1743 { |
| 1903 // Enable the animations so that we can make sure they do occur. | 1744 // Enable the animations so that we can make sure they do occur. |
| 1904 ui::ScopedAnimationDurationScaleMode regular_animations( | 1745 ui::ScopedAnimationDurationScaleMode regular_animations( |
| 1905 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 1746 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 1906 | 1747 |
| 1907 gfx::Point start = | 1748 gfx::Point start = |
| 1908 GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); | 1749 GetShelfWidget()->GetWindowBoundsInScreen().CenterPoint(); |
| 1909 gfx::Point end(start.x(), start.y() - 100); | 1750 gfx::Point end(start.x(), start.y() - 100); |
| 1910 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1751 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 1911 | 1752 |
| 1912 // Test that the shelf animates to the visible bounds after a swipe up on | 1753 // Test that the shelf animates to the visible bounds after a swipe up on |
| 1913 // the auto hidden shelf. | 1754 // the auto hidden shelf. |
| 1914 generator.GestureScrollSequence(start, end, | 1755 generator.GestureScrollSequence(start, end, |
| 1915 base::TimeDelta::FromMilliseconds(10), 1); | 1756 base::TimeDelta::FromMilliseconds(10), 1); |
| 1916 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1757 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1917 ShelfAnimationWaiter waiter1(visible_bounds); | 1758 ShelfAnimationWaiter waiter1(visible_bounds); |
| 1918 waiter1.WaitTillDoneAnimating(); | 1759 waiter1.WaitTillDoneAnimating(); |
| 1919 EXPECT_TRUE(waiter1.WasValidAnimation()); | 1760 EXPECT_TRUE(waiter1.WasValidAnimation()); |
| 1920 | 1761 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1950 EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); | 1791 EXPECT_TRUE(GetSystemTray()->HasSystemBubble()); |
| 1951 } | 1792 } |
| 1952 | 1793 |
| 1953 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { | 1794 TEST_F(ShelfLayoutManagerTest, WorkAreaChangeWorkspace) { |
| 1954 // Make sure the shelf is always visible. | 1795 // Make sure the shelf is always visible. |
| 1955 Shelf* shelf = GetShelf(); | 1796 Shelf* shelf = GetShelf(); |
| 1956 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1797 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1957 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1798 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1958 layout_manager->LayoutShelf(); | 1799 layout_manager->LayoutShelf(); |
| 1959 | 1800 |
| 1960 views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | 1801 views::Widget* widget_one = CreateTestWidget(); |
| 1961 params.bounds = gfx::Rect(0, 0, 200, 200); | |
| 1962 params.context = CurrentContext(); | |
| 1963 views::Widget* widget_one = CreateTestWidgetWithParams(params); | |
| 1964 widget_one->Maximize(); | 1802 widget_one->Maximize(); |
| 1965 | 1803 |
| 1966 views::Widget* widget_two = CreateTestWidgetWithParams(params); | 1804 views::Widget* widget_two = CreateTestWidget(); |
| 1967 widget_two->Maximize(); | 1805 widget_two->Maximize(); |
| 1968 widget_two->Activate(); | 1806 widget_two->Activate(); |
| 1969 | 1807 |
| 1970 // Both windows are maximized. They should be of the same size. | 1808 // Both windows are maximized. They should be of the same size. |
| 1971 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), | 1809 EXPECT_EQ(widget_one->GetNativeWindow()->bounds().ToString(), |
| 1972 widget_two->GetNativeWindow()->bounds().ToString()); | 1810 widget_two->GetNativeWindow()->bounds().ToString()); |
| 1973 int area_when_shelf_shown = | 1811 int area_when_shelf_shown = |
| 1974 widget_one->GetNativeWindow()->bounds().size().GetArea(); | 1812 widget_one->GetNativeWindow()->bounds().size().GetArea(); |
| 1975 | 1813 |
| 1976 // Now hide the shelf. | 1814 // Now hide the shelf. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 Shelf* shelf = GetShelf(); | 1868 Shelf* shelf = GetShelf(); |
| 2031 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1869 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 2032 StatusAreaWidget* status_area_widget = | 1870 StatusAreaWidget* status_area_widget = |
| 2033 shelf->shelf_widget()->status_area_widget(); | 1871 shelf->shelf_widget()->status_area_widget(); |
| 2034 SystemTray* tray = GetSystemTray(); | 1872 SystemTray* tray = GetSystemTray(); |
| 2035 | 1873 |
| 2036 // Create a visible window so auto-hide behavior is enforced. | 1874 // Create a visible window so auto-hide behavior is enforced. |
| 2037 CreateTestWidget(); | 1875 CreateTestWidget(); |
| 2038 | 1876 |
| 2039 layout_manager->LayoutShelf(); | 1877 layout_manager->LayoutShelf(); |
| 2040 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 1878 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 2041 | 1879 |
| 2042 // Make two iterations - first without a message bubble which should make | 1880 // Make two iterations - first without a message bubble which should make |
| 2043 // the shelf disappear and then with a message bubble which should keep it | 1881 // the shelf disappear and then with a message bubble which should keep it |
| 2044 // visible. | 1882 // visible. |
| 2045 for (int i = 0; i < 2; i++) { | 1883 for (int i = 0; i < 2; i++) { |
| 2046 // Make sure the shelf is visible and position the mouse over it. Then | 1884 // Make sure the shelf is visible and position the mouse over it. Then |
| 2047 // allow auto hide. | 1885 // allow auto hide. |
| 2048 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1886 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 2049 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1887 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2050 gfx::Point center = | 1888 gfx::Point center = |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2114 | 1952 |
| 2115 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1953 GetShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 2116 std::unique_ptr<aura::Window> w1(CreateTestWindow()); | 1954 std::unique_ptr<aura::Window> w1(CreateTestWindow()); |
| 2117 w1->Show(); | 1955 w1->Show(); |
| 2118 wm::ActivateWindow(w1.get()); | 1956 wm::ActivateWindow(w1.get()); |
| 2119 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); | 1957 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); |
| 2120 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1958 w1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 2121 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); | 1959 EXPECT_EQ(SHELF_BACKGROUND_OVERLAP, GetShelfWidget()->GetBackgroundType()); |
| 2122 } | 1960 } |
| 2123 | 1961 |
| 2124 #if defined(OS_CHROMEOS) | 1962 // Verify the hit bounds of the status area extend to the edge of the shelf. |
| 2125 #define MAYBE_StatusAreaHitBoxCoversEdge StatusAreaHitBoxCoversEdge | 1963 TEST_F(ShelfLayoutManagerTest, StatusAreaHitBoxCoversEdge) { |
| 2126 #else | 1964 Shelf* shelf = GetShelf(); |
| 2127 #define MAYBE_StatusAreaHitBoxCoversEdge DISABLED_StatusAreaHitBoxCoversEdge | 1965 StatusAreaWidget* status_area_widget = |
| 2128 #endif | 1966 StatusAreaWidgetTestHelper::GetStatusAreaWidget(); |
| 2129 | 1967 |
| 2130 // Verify the hit bounds of the status area extend to the edge of the shelf. | 1968 ui::test::EventGenerator& generator(GetEventGenerator()); |
| 2131 TEST_F(ShelfLayoutManagerTest, MAYBE_StatusAreaHitBoxCoversEdge) { | 1969 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 2132 UpdateDisplay("400x400"); | 1970 generator.MoveMouseTo(display.bounds().bottom_right()); |
| 2133 Shelf* shelf = GetShelf(); | |
| 2134 StatusAreaWidget* status_area_widget = Shell::GetPrimaryRootWindowController() | |
| 2135 ->shelf_widget() | |
| 2136 ->status_area_widget(); | |
| 2137 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | |
| 2138 generator.MoveMouseTo(399, 399); | |
| 2139 | 1971 |
| 2140 // Test bottom right pixel for bottom alignment. | 1972 // Test bottom right pixel for bottom alignment. |
| 2141 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1973 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2142 generator.ClickLeftButton(); | 1974 generator.ClickLeftButton(); |
| 2143 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 1975 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 2144 generator.ClickLeftButton(); | 1976 generator.ClickLeftButton(); |
| 2145 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1977 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2146 | 1978 |
| 2147 // Test bottom right pixel for right alignment. | 1979 // Test bottom right pixel for right alignment. |
| 2148 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 1980 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 2149 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1981 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2150 generator.ClickLeftButton(); | 1982 generator.ClickLeftButton(); |
| 2151 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 1983 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 2152 generator.ClickLeftButton(); | 1984 generator.ClickLeftButton(); |
| 2153 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1985 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2154 | 1986 |
| 2155 // Test bottom left pixel for left alignment. | 1987 // Test bottom left pixel for left alignment. |
| 2156 generator.MoveMouseTo(0, 399); | 1988 generator.MoveMouseTo(display.bounds().bottom_left()); |
| 2157 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1989 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 2158 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1990 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2159 generator.ClickLeftButton(); | 1991 generator.ClickLeftButton(); |
| 2160 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); | 1992 EXPECT_TRUE(status_area_widget->IsMessageBubbleShown()); |
| 2161 generator.ClickLeftButton(); | 1993 generator.ClickLeftButton(); |
| 2162 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); | 1994 EXPECT_FALSE(status_area_widget->IsMessageBubbleShown()); |
| 2163 } | 1995 } |
| 2164 | 1996 |
| 2165 // Tests that when the auto-hide behaviour is changed during an animation the | 1997 // Tests that when the auto-hide behaviour is changed during an animation the |
| 2166 // target bounds are updated to reflect the new state. | 1998 // target bounds are updated to reflect the new state. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2216 ->shelf_widget() | 2048 ->shelf_widget() |
| 2217 ->status_area_widget(); | 2049 ->status_area_widget(); |
| 2218 EXPECT_TRUE(status_area_widget->IsVisible()); | 2050 EXPECT_TRUE(status_area_widget->IsVisible()); |
| 2219 // Shelf should be in the first display's area. | 2051 // Shelf should be in the first display's area. |
| 2220 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 2052 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 2221 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 2053 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
| 2222 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 2054 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
| 2223 } | 2055 } |
| 2224 | 2056 |
| 2225 } // namespace ash | 2057 } // namespace ash |
| OLD | NEW |