| 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/test/ash_test_base.h" | 5 #include "ash/test/ash_test_base.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 window->Init(ui::LAYER_TEXTURED); | 267 window->Init(ui::LAYER_TEXTURED); |
| 268 window->Show(); | 268 window->Show(); |
| 269 | 269 |
| 270 if (bounds.IsEmpty()) { | 270 if (bounds.IsEmpty()) { |
| 271 ParentWindowInPrimaryRootWindow(window); | 271 ParentWindowInPrimaryRootWindow(window); |
| 272 } else { | 272 } else { |
| 273 gfx::Display display = | 273 gfx::Display display = |
| 274 Shell::GetScreen()->GetDisplayMatching(bounds); | 274 Shell::GetScreen()->GetDisplayMatching(bounds); |
| 275 aura::Window* root = ash::Shell::GetInstance()->display_controller()-> | 275 aura::Window* root = ash::Shell::GetInstance()->display_controller()-> |
| 276 GetRootWindowForDisplayId(display.id()); | 276 GetRootWindowForDisplayId(display.id()); |
| 277 gfx::Point origin = bounds.origin(); | 277 window->SetBoundsInScreen(bounds, Shell::GetScreen()->GetPrimaryDisplay()); |
| 278 ::wm::ConvertPointFromScreen(root, &origin); | |
| 279 window->SetBounds(gfx::Rect(origin, bounds.size())); | |
| 280 aura::client::ParentWindowWithContext(window, root, bounds); | 278 aura::client::ParentWindowWithContext(window, root, bounds); |
| 281 } | 279 } |
| 282 window->SetProperty(aura::client::kCanMaximizeKey, true); | 280 window->SetProperty(aura::client::kCanMaximizeKey, true); |
| 283 window->SetProperty(aura::client::kCanMinimizeKey, true); | 281 window->SetProperty(aura::client::kCanMinimizeKey, true); |
| 284 return window; | 282 return window; |
| 285 } | 283 } |
| 286 | 284 |
| 285 aura::Window* AshTestBase::CreateTestModalWindowInShellWithBounds( |
| 286 const gfx::Rect& bounds) { |
| 287 return CreateTestModalWindowInShellWithDelegateAndType( |
| 288 nullptr, ui::wm::WINDOW_TYPE_NORMAL, 0, bounds); |
| 289 } |
| 290 |
| 291 aura::Window* AshTestBase::CreateTestModalWindowInShellWithDelegateAndType( |
| 292 aura::WindowDelegate* delegate, |
| 293 ui::wm::WindowType type, |
| 294 int id, |
| 295 const gfx::Rect& bounds) { |
| 296 aura::Window* window = new aura::Window(delegate); |
| 297 |
| 298 // Note that the system modal property must be set on |window| prior to |
| 299 // calling ParentWindowWithContext(), otherwise it will not be attached |
| 300 // as a descendant of the modal container window. |
| 301 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 302 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 303 window->Init(ui::LAYER_TEXTURED); |
| 304 window->Show(); |
| 305 |
| 306 if (bounds.IsEmpty()) { |
| 307 ParentWindowInPrimaryRootWindow(window); |
| 308 } else { |
| 309 gfx::Display display = Shell::GetScreen()->GetDisplayMatching(bounds); |
| 310 aura::Window* root = ash::Shell::GetInstance() |
| 311 ->display_controller() |
| 312 ->GetRootWindowForDisplayId(display.id()); |
| 313 window->SetBoundsInScreen(bounds, Shell::GetScreen()->GetPrimaryDisplay()); |
| 314 aura::client::ParentWindowWithContext(window, root, bounds); |
| 315 } |
| 316 return window; |
| 317 } |
| 318 |
| 287 void AshTestBase::ParentWindowInPrimaryRootWindow(aura::Window* window) { | 319 void AshTestBase::ParentWindowInPrimaryRootWindow(aura::Window* window) { |
| 288 aura::client::ParentWindowWithContext( | 320 aura::client::ParentWindowWithContext( |
| 289 window, Shell::GetPrimaryRootWindow(), gfx::Rect()); | 321 window, Shell::GetPrimaryRootWindow(), gfx::Rect()); |
| 290 } | 322 } |
| 291 | 323 |
| 292 void AshTestBase::RunAllPendingInMessageLoop() { | 324 void AshTestBase::RunAllPendingInMessageLoop() { |
| 293 ash_test_helper_->RunAllPendingInMessageLoop(); | 325 ash_test_helper_->RunAllPendingInMessageLoop(); |
| 294 } | 326 } |
| 295 | 327 |
| 296 TestScreenshotDelegate* AshTestBase::GetScreenshotDelegate() { | 328 TestScreenshotDelegate* AshTestBase::GetScreenshotDelegate() { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 | 388 |
| 357 void AshTestBase::UnblockUserSession() { | 389 void AshTestBase::UnblockUserSession() { |
| 358 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 390 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
| 359 SetSessionStarted(true); | 391 SetSessionStarted(true); |
| 360 SetUserAddingScreenRunning(false); | 392 SetUserAddingScreenRunning(false); |
| 361 } | 393 } |
| 362 | 394 |
| 363 | 395 |
| 364 } // namespace test | 396 } // namespace test |
| 365 } // namespace ash | 397 } // namespace ash |
| OLD | NEW |