| 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/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
| 6 | 6 |
| 7 #include "ash/session_state_delegate.h" | 7 #include "ash/session_state_delegate.h" |
| 8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, | 138 views::Widget* CreateModalWidgetWithParent(const gfx::Rect& bounds, |
| 139 gfx::NativeWindow parent) { | 139 gfx::NativeWindow parent) { |
| 140 views::Widget* widget = | 140 views::Widget* widget = |
| 141 views::Widget::CreateWindowWithParentAndBounds(new TestDelegate(true), | 141 views::Widget::CreateWindowWithParentAndBounds(new TestDelegate(true), |
| 142 parent, | 142 parent, |
| 143 bounds); | 143 bounds); |
| 144 widget->Show(); | 144 widget->Show(); |
| 145 return widget; | 145 return widget; |
| 146 } | 146 } |
| 147 | 147 |
| 148 aura::Window* GetModalContainer(aura::RootWindow* root_window) { | 148 aura::Window* GetModalContainer(aura::Window* root_window) { |
| 149 return Shell::GetContainer( | 149 return Shell::GetContainer( |
| 150 root_window, | 150 root_window, |
| 151 ash::internal::kShellWindowId_SystemModalContainer); | 151 ash::internal::kShellWindowId_SystemModalContainer); |
| 152 } | 152 } |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { | 155 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { |
| 156 if (!SupportsMultipleDisplays()) | 156 if (!SupportsMultipleDisplays()) |
| 157 return; | 157 return; |
| 158 | 158 |
| 159 UpdateDisplay("600x600,500x500"); | 159 UpdateDisplay("600x600,500x500"); |
| 160 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 160 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 161 internal::RootWindowController* controller = | 161 internal::RootWindowController* controller = |
| 162 Shell::GetPrimaryRootWindowController(); | 162 Shell::GetPrimaryRootWindowController(); |
| 163 internal::ShelfLayoutManager* shelf_layout_manager = | 163 internal::ShelfLayoutManager* shelf_layout_manager = |
| 164 controller->GetShelfLayoutManager(); | 164 controller->GetShelfLayoutManager(); |
| 165 shelf_layout_manager->SetAutoHideBehavior( | 165 shelf_layout_manager->SetAutoHideBehavior( |
| 166 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 166 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 167 | 167 |
| 168 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); | 168 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
| 169 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); | 169 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
| 170 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 170 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); | 283 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); |
| 284 EXPECT_EQ(internal::kShellWindowId_PanelContainer, panel->parent()->id()); | 284 EXPECT_EQ(internal::kShellWindowId_PanelContainer, panel->parent()->id()); |
| 285 } | 285 } |
| 286 | 286 |
| 287 TEST_F(RootWindowControllerTest, MoveWindows_Modal) { | 287 TEST_F(RootWindowControllerTest, MoveWindows_Modal) { |
| 288 if (!SupportsMultipleDisplays()) | 288 if (!SupportsMultipleDisplays()) |
| 289 return; | 289 return; |
| 290 | 290 |
| 291 UpdateDisplay("500x500,500x500"); | 291 UpdateDisplay("500x500,500x500"); |
| 292 | 292 |
| 293 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 293 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 294 // Emulate virtual screen coordinate system. | 294 // Emulate virtual screen coordinate system. |
| 295 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); | 295 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); |
| 296 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); | 296 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); |
| 297 | 297 |
| 298 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); | 298 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); |
| 299 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); | 299 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
| 300 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); | 300 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); |
| 301 | 301 |
| 302 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); | 302 views::Widget* modal = CreateModalWidget(gfx::Rect(650, 10, 100, 100)); |
| 303 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); | 303 EXPECT_EQ(root_windows[1], modal->GetNativeView()->GetRootWindow()); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 | 631 |
| 632 // Test for http://crbug.com/297858. Virtual keyboard container should only show | 632 // Test for http://crbug.com/297858. Virtual keyboard container should only show |
| 633 // on primary root window. | 633 // on primary root window. |
| 634 TEST_F(VirtualKeyboardRootWindowControllerTest, | 634 TEST_F(VirtualKeyboardRootWindowControllerTest, |
| 635 VirtualKeyboardOnPrimaryRootWindowOnly) { | 635 VirtualKeyboardOnPrimaryRootWindowOnly) { |
| 636 if (!SupportsMultipleDisplays()) | 636 if (!SupportsMultipleDisplays()) |
| 637 return; | 637 return; |
| 638 | 638 |
| 639 UpdateDisplay("500x500,500x500"); | 639 UpdateDisplay("500x500,500x500"); |
| 640 | 640 |
| 641 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 641 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 642 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); | 642 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); |
| 643 aura::Window* secondary_root_window = | 643 aura::Window* secondary_root_window = |
| 644 root_windows[0] == primary_root_window ? | 644 root_windows[0] == primary_root_window ? |
| 645 root_windows[1] : root_windows[0]; | 645 root_windows[1] : root_windows[0]; |
| 646 | 646 |
| 647 ASSERT_TRUE(Shell::GetContainer( | 647 ASSERT_TRUE(Shell::GetContainer( |
| 648 primary_root_window, | 648 primary_root_window, |
| 649 internal::kShellWindowId_VirtualKeyboardContainer)); | 649 internal::kShellWindowId_VirtualKeyboardContainer)); |
| 650 ASSERT_FALSE(Shell::GetContainer( | 650 ASSERT_FALSE(Shell::GetContainer( |
| 651 secondary_root_window, | 651 secondary_root_window, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 aura::WindowTracker tracker; | 697 aura::WindowTracker tracker; |
| 698 tracker.Add(keyboard_container); | 698 tracker.Add(keyboard_container); |
| 699 // Mock a login state change to reinitialize the keyboard. | 699 // Mock a login state change to reinitialize the keyboard. |
| 700 ash::Shell::GetInstance()->OnLoginStateChanged(user::LOGGED_IN_OWNER); | 700 ash::Shell::GetInstance()->OnLoginStateChanged(user::LOGGED_IN_OWNER); |
| 701 // keyboard_container should no longer be present. | 701 // keyboard_container should no longer be present. |
| 702 EXPECT_FALSE(tracker.Contains(keyboard_container)); | 702 EXPECT_FALSE(tracker.Contains(keyboard_container)); |
| 703 } | 703 } |
| 704 | 704 |
| 705 } // namespace test | 705 } // namespace test |
| 706 } // namespace ash | 706 } // namespace ash |
| OLD | NEW |