Index: ash/test/ash_test_base.cc |
diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc |
index ffb633060175ed876faa1c937714d505b0de8441..0a2faf9f1bee3f429ebb022e6404532bf65428c6 100644 |
--- a/ash/test/ash_test_base.cc |
+++ b/ash/test/ash_test_base.cc |
@@ -274,9 +274,7 @@ aura::Window* AshTestBase::CreateTestWindowInShellWithDelegateAndType( |
Shell::GetScreen()->GetDisplayMatching(bounds); |
aura::Window* root = ash::Shell::GetInstance()->display_controller()-> |
GetRootWindowForDisplayId(display.id()); |
- gfx::Point origin = bounds.origin(); |
- ::wm::ConvertPointFromScreen(root, &origin); |
- window->SetBounds(gfx::Rect(origin, bounds.size())); |
+ window->SetBoundsInScreen(bounds, Shell::GetScreen()->GetPrimaryDisplay()); |
aura::client::ParentWindowWithContext(window, root, bounds); |
} |
window->SetProperty(aura::client::kCanMaximizeKey, true); |
@@ -284,6 +282,40 @@ aura::Window* AshTestBase::CreateTestWindowInShellWithDelegateAndType( |
return window; |
} |
+aura::Window* AshTestBase::CreateTestModalWindowInShellWithBounds( |
+ const gfx::Rect& bounds) { |
+ return CreateTestModalWindowInShellWithDelegateAndType( |
+ nullptr, ui::wm::WINDOW_TYPE_NORMAL, 0, bounds); |
+} |
+ |
+aura::Window* AshTestBase::CreateTestModalWindowInShellWithDelegateAndType( |
+ aura::WindowDelegate* delegate, |
+ ui::wm::WindowType type, |
+ int id, |
+ const gfx::Rect& bounds) { |
+ aura::Window* window = new aura::Window(delegate); |
+ |
+ // Note that the system modal property must be set on |window| prior to |
+ // calling ParentWindowWithContext(), otherwise it will not be attached |
+ // as a descendant of the modal container window. |
+ window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
+ window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
+ window->Init(ui::LAYER_TEXTURED); |
+ window->Show(); |
+ |
+ if (bounds.IsEmpty()) { |
+ ParentWindowInPrimaryRootWindow(window); |
+ } else { |
+ gfx::Display display = Shell::GetScreen()->GetDisplayMatching(bounds); |
+ aura::Window* root = ash::Shell::GetInstance() |
+ ->display_controller() |
+ ->GetRootWindowForDisplayId(display.id()); |
+ window->SetBoundsInScreen(bounds, Shell::GetScreen()->GetPrimaryDisplay()); |
+ aura::client::ParentWindowWithContext(window, root, bounds); |
+ } |
+ return window; |
+} |
+ |
void AshTestBase::ParentWindowInPrimaryRootWindow(aura::Window* window) { |
aura::client::ParentWindowWithContext( |
window, Shell::GetPrimaryRootWindow(), gfx::Rect()); |