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/shell.h" | 5 #include "ash/shell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
11 #include "ash/common/session/session_state_delegate.h" | 11 #include "ash/common/session/session_state_delegate.h" |
12 #include "ash/common/shelf/shelf.h" | |
13 #include "ash/common/shelf/shelf_layout_manager.h" | 12 #include "ash/common/shelf/shelf_layout_manager.h" |
14 #include "ash/common/shelf/shelf_widget.h" | 13 #include "ash/common/shelf/shelf_widget.h" |
| 14 #include "ash/common/shelf/wm_shelf.h" |
15 #include "ash/common/shell_window_ids.h" | 15 #include "ash/common/shell_window_ids.h" |
16 #include "ash/common/wm_shell.h" | 16 #include "ash/common/wm_shell.h" |
17 #include "ash/desktop_background/desktop_background_widget_controller.h" | 17 #include "ash/desktop_background/desktop_background_widget_controller.h" |
18 #include "ash/display/mouse_cursor_event_filter.h" | 18 #include "ash/display/mouse_cursor_event_filter.h" |
19 #include "ash/drag_drop/drag_drop_controller.h" | 19 #include "ash/drag_drop/drag_drop_controller.h" |
20 #include "ash/root_window_controller.h" | 20 #include "ash/root_window_controller.h" |
21 #include "ash/test/ash_test_base.h" | 21 #include "ash/test/ash_test_base.h" |
22 #include "ash/test/shell_test_api.h" | 22 #include "ash/test/shell_test_api.h" |
23 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 ui::MENU_SOURCE_MOUSE)); | 364 ui::MENU_SOURCE_MOUSE)); |
365 } | 365 } |
366 | 366 |
367 TEST_F(ShellTest, ManagedWindowModeBasics) { | 367 TEST_F(ShellTest, ManagedWindowModeBasics) { |
368 if (!SupportsHostWindowResize()) | 368 if (!SupportsHostWindowResize()) |
369 return; | 369 return; |
370 | 370 |
371 // We start with the usual window containers. | 371 // We start with the usual window containers. |
372 ExpectAllContainers(); | 372 ExpectAllContainers(); |
373 // Shelf is visible. | 373 // Shelf is visible. |
374 ShelfWidget* shelf_widget = Shelf::ForPrimaryDisplay()->shelf_widget(); | 374 ShelfWidget* shelf_widget = GetPrimaryShelf()->GetShelfWidgetForTesting(); |
375 EXPECT_TRUE(shelf_widget->IsVisible()); | 375 EXPECT_TRUE(shelf_widget->IsVisible()); |
376 // Shelf is at bottom-left of screen. | 376 // Shelf is at bottom-left of screen. |
377 EXPECT_EQ(0, shelf_widget->GetWindowBoundsInScreen().x()); | 377 EXPECT_EQ(0, shelf_widget->GetWindowBoundsInScreen().x()); |
378 EXPECT_EQ(Shell::GetPrimaryRootWindow()->GetHost()->GetBounds().height(), | 378 EXPECT_EQ(Shell::GetPrimaryRootWindow()->GetHost()->GetBounds().height(), |
379 shelf_widget->GetWindowBoundsInScreen().bottom()); | 379 shelf_widget->GetWindowBoundsInScreen().bottom()); |
380 // We have a desktop background but not a bare layer. | 380 // We have a desktop background but not a bare layer. |
381 // TODO (antrim): enable once we find out why it fails component build. | 381 // TODO (antrim): enable once we find out why it fails component build. |
382 // DesktopBackgroundWidgetController* background = | 382 // DesktopBackgroundWidgetController* background = |
383 // Shell::GetPrimaryRootWindow()-> | 383 // Shell::GetPrimaryRootWindow()-> |
384 // GetProperty(kWindowDesktopComponent); | 384 // GetProperty(kWindowDesktopComponent); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 // TODO(jamescook): Move this to ShelfTest. | 434 // TODO(jamescook): Move this to ShelfTest. |
435 TEST_F(ShellTest, ToggleAutoHide) { | 435 TEST_F(ShellTest, ToggleAutoHide) { |
436 std::unique_ptr<aura::Window> window(new aura::Window(NULL)); | 436 std::unique_ptr<aura::Window> window(new aura::Window(NULL)); |
437 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); | 437 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
438 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 438 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
439 window->Init(ui::LAYER_TEXTURED); | 439 window->Init(ui::LAYER_TEXTURED); |
440 ParentWindowInPrimaryRootWindow(window.get()); | 440 ParentWindowInPrimaryRootWindow(window.get()); |
441 window->Show(); | 441 window->Show(); |
442 wm::ActivateWindow(window.get()); | 442 wm::ActivateWindow(window.get()); |
443 | 443 |
444 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 444 WmShelf* shelf = GetPrimaryShelf(); |
445 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 445 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
446 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); | 446 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); |
447 | 447 |
448 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 448 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
449 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 449 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
450 | 450 |
451 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 451 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
452 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); | 452 EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_NEVER, shelf->auto_hide_behavior()); |
453 | 453 |
454 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 454 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 private: | 503 private: |
504 DISALLOW_COPY_AND_ASSIGN(ShellTest2); | 504 DISALLOW_COPY_AND_ASSIGN(ShellTest2); |
505 }; | 505 }; |
506 | 506 |
507 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { | 507 TEST_F(ShellTest2, DontCrashWhenWindowDeleted) { |
508 window_.reset(new aura::Window(NULL)); | 508 window_.reset(new aura::Window(NULL)); |
509 window_->Init(ui::LAYER_NOT_DRAWN); | 509 window_->Init(ui::LAYER_NOT_DRAWN); |
510 } | 510 } |
511 | 511 |
512 } // namespace ash | 512 } // namespace ash |
OLD | NEW |