| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/session/session_controller.h" | 9 #include "ash/common/session/session_controller.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return widget; | 128 return widget; |
| 129 } | 129 } |
| 130 | 130 |
| 131 aura::Window* GetModalContainer(aura::Window* root_window) { | 131 aura::Window* GetModalContainer(aura::Window* root_window) { |
| 132 return Shell::GetContainer(root_window, | 132 return Shell::GetContainer(root_window, |
| 133 kShellWindowId_SystemModalContainer); | 133 kShellWindowId_SystemModalContainer); |
| 134 } | 134 } |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { | 137 TEST_F(RootWindowControllerTest, MoveWindows_Basic) { |
| 138 // TODO: triggers shutdown crash in mash. http://crbug.com/695632. | |
| 139 if (WmShell::Get()->IsRunningInMash()) | |
| 140 return; | |
| 141 | |
| 142 // Windows origin should be doubled when moved to the 1st display. | 138 // Windows origin should be doubled when moved to the 1st display. |
| 143 UpdateDisplay("600x600,300x300"); | 139 UpdateDisplay("600x600,300x300"); |
| 144 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 140 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 145 | 141 |
| 146 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); | 142 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); |
| 147 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); | 143 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); |
| 148 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); | 144 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); |
| 149 EXPECT_EQ("50,10 100x100", | 145 EXPECT_EQ("50,10 100x100", |
| 150 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 146 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 151 | 147 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 EXPECT_EQ(root_windows[1], | 180 EXPECT_EQ(root_windows[1], |
| 185 unparented_control->GetNativeView()->GetRootWindow()); | 181 unparented_control->GetNativeView()->GetRootWindow()); |
| 186 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, | 182 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, |
| 187 unparented_control->GetNativeView()->parent()->id()); | 183 unparented_control->GetNativeView()->parent()->id()); |
| 188 | 184 |
| 189 aura::Window* panel = CreateTestWindowInShellWithDelegateAndType( | 185 aura::Window* panel = CreateTestWindowInShellWithDelegateAndType( |
| 190 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, gfx::Rect(700, 100, 100, 100)); | 186 NULL, ui::wm::WINDOW_TYPE_PANEL, 0, gfx::Rect(700, 100, 100, 100)); |
| 191 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); | 187 EXPECT_EQ(root_windows[1], panel->GetRootWindow()); |
| 192 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); | 188 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); |
| 193 | 189 |
| 194 // Make sure a window that will delete itself when losing focus | 190 if (WmShell::Get()->IsRunningInMash()) { |
| 195 // will not crash. | 191 // TODO(erg): Ignore this one part of the test when running mash. We would |
| 196 aura::WindowTracker tracker; | 192 // crash because the aura::Window |d2| created in the other block doesn't |
| 197 DeleteOnBlurDelegate delete_on_blur_delegate; | 193 // get deleted, and thus continues to contain a reference to its delegate, |
| 198 aura::Window* d2 = CreateTestWindowInShellWithDelegate( | 194 // |delete_on_blur_delegate|, which is declared on the stack. |
| 199 &delete_on_blur_delegate, 0, gfx::Rect(50, 50, 100, 100)); | 195 // |
| 200 delete_on_blur_delegate.SetWindow(d2); | 196 // Making this work requires building out enough of the display management |
| 201 aura::client::GetFocusClient(root_windows[0])->FocusWindow(d2); | 197 // system; notably the part where updating the display may cause focus |
| 202 tracker.Add(d2); | 198 // changes. http://crbug.com/695632. |
| 199 UpdateDisplay("600x600"); |
| 200 } else { |
| 201 // Make sure a window that will delete itself when losing focus |
| 202 // will not crash. |
| 203 aura::WindowTracker tracker; |
| 204 DeleteOnBlurDelegate delete_on_blur_delegate; |
| 205 aura::Window* d2 = CreateTestWindowInShellWithDelegate( |
| 206 &delete_on_blur_delegate, 0, gfx::Rect(50, 50, 100, 100)); |
| 207 delete_on_blur_delegate.SetWindow(d2); |
| 208 aura::client::GetFocusClient(root_windows[0])->FocusWindow(d2); |
| 209 tracker.Add(d2); |
| 203 | 210 |
| 204 UpdateDisplay("600x600"); | 211 UpdateDisplay("600x600"); |
| 205 | 212 |
| 206 // d2 must have been deleted. | 213 // d2 must have been deleted. |
| 207 EXPECT_FALSE(tracker.Contains(d2)); | 214 EXPECT_FALSE(tracker.Contains(d2)); |
| 215 } |
| 208 | 216 |
| 209 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); | 217 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); |
| 210 EXPECT_EQ("100,20 100x100", normal->GetWindowBoundsInScreen().ToString()); | 218 EXPECT_EQ("100,20 100x100", normal->GetWindowBoundsInScreen().ToString()); |
| 211 EXPECT_EQ("100,20 100x100", | 219 EXPECT_EQ("100,20 100x100", |
| 212 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); | 220 normal->GetNativeView()->GetBoundsInRootWindow().ToString()); |
| 213 | 221 |
| 214 // Maximized area on primary display has 47px for non-md and 48px for md | 222 // Maximized area on primary display has 47px for non-md and 48px for md |
| 215 // (defined in SHELF_SIZE) inset at the bottom. | 223 // (defined in SHELF_SIZE) inset at the bottom. |
| 216 | 224 |
| 217 // First clear fullscreen status, since both fullscreen and maximized windows | 225 // First clear fullscreen status, since both fullscreen and maximized windows |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( | 1239 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( |
| 1232 gfx::Rect(0, 400, 800, 200)); | 1240 gfx::Rect(0, 400, 800, 200)); |
| 1233 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); | 1241 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); |
| 1234 | 1242 |
| 1235 UpdateDisplay("600x800"); | 1243 UpdateDisplay("600x800"); |
| 1236 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); | 1244 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); |
| 1237 } | 1245 } |
| 1238 | 1246 |
| 1239 } // namespace test | 1247 } // namespace test |
| 1240 } // namespace ash | 1248 } // namespace ash |
| OLD | NEW |