summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-27 00:37:55 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-27 00:37:55 +0000
commit96ea228ed88492c273aa234d1aa8dc630cd7a935 (patch)
tree9d431fd9167e59fe3288920f2bd202638811831c /ash
parent950f9ce2cda8b1599b086b2069f5fae5baeb4f7b (diff)
downloadchromium_src-96ea228ed88492c273aa234d1aa8dc630cd7a935.zip
chromium_src-96ea228ed88492c273aa234d1aa8dc630cd7a935.tar.gz
chromium_src-96ea228ed88492c273aa234d1aa8dc630cd7a935.tar.bz2
Open new window on active display unless the location is given.
BUG=164074 TEST=covered by test. Review URL: https://chromiumcodereview.appspot.com/11665013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@174650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/drag_drop/drag_drop_tracker_unittest.cc14
-rw-r--r--ash/test/ash_test_base.cc16
2 files changed, 20 insertions, 10 deletions
diff --git a/ash/drag_drop/drag_drop_tracker_unittest.cc b/ash/drag_drop/drag_drop_tracker_unittest.cc
index d8a1f10..7113c22 100644
--- a/ash/drag_drop/drag_drop_tracker_unittest.cc
+++ b/ash/drag_drop/drag_drop_tracker_unittest.cc
@@ -62,17 +62,17 @@ TEST_F(DragDropTrackerTest, MAYBE_GetTarget) {
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
EXPECT_EQ(2U, root_windows.size());
- Shell::GetInstance()->set_active_root_window(root_windows[0]);
-
scoped_ptr<aura::Window> window0(
CreateTestWindow(gfx::Rect(0, 0, 100, 100)));
window0->Show();
- Shell::GetInstance()->set_active_root_window(root_windows[1]);
-
scoped_ptr<aura::Window> window1(
- CreateTestWindow(gfx::Rect(100, 100, 100, 100)));
+ CreateTestWindow(gfx::Rect(300, 100, 100, 100)));
window1->Show();
+ EXPECT_EQ(root_windows[0], window0->GetRootWindow());
+ EXPECT_EQ(root_windows[1], window1->GetRootWindow());
+ EXPECT_EQ("0,0 100x100", window0->GetBoundsInScreen().ToString());
+ EXPECT_EQ("300,100 100x100", window1->GetBoundsInScreen().ToString());
// Make RootWindow0 active so that capture window is parented to it.
Shell::GetInstance()->set_active_root_window(root_windows[0]);
@@ -129,14 +129,12 @@ TEST_F(DragDropTrackerTest, MAYBE_ConvertEvent) {
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
EXPECT_EQ(2U, root_windows.size());
- Shell::GetInstance()->set_active_root_window(root_windows[0]);
scoped_ptr<aura::Window> window0(
CreateTestWindow(gfx::Rect(0, 0, 100, 100)));
window0->Show();
- Shell::GetInstance()->set_active_root_window(root_windows[1]);
scoped_ptr<aura::Window> window1(
- CreateTestWindow(gfx::Rect(100, 100, 100, 100)));
+ CreateTestWindow(gfx::Rect(300, 100, 100, 100)));
window1->Show();
// Make RootWindow0 active so that capture window is parented to it.
diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc
index b9da0d7..2f48675 100644
--- a/ash/test/ash_test_base.cc
+++ b/ash/test/ash_test_base.cc
@@ -12,6 +12,7 @@
#include "ash/shell.h"
#include "ash/test/display_manager_test_api.h"
#include "ash/test/test_shell_delegate.h"
+#include "ash/wm/coordinate_conversion.h"
#include "base/command_line.h"
#include "base/run_loop.h"
#include "content/public/test/web_contents_tester.h"
@@ -133,9 +134,20 @@ aura::Window* AshTestBase::CreateTestWindowInShellWithDelegateAndType(
window->set_id(id);
window->SetType(type);
window->Init(ui::LAYER_TEXTURED);
- window->SetBounds(bounds);
window->Show();
- SetDefaultParentByPrimaryRootWindow(window);
+
+ if (bounds.IsEmpty()) {
+ SetDefaultParentByPrimaryRootWindow(window);
+ } else {
+ gfx::Display display =
+ ash::Shell::GetInstance()->display_manager()->GetDisplayMatching(bounds);
+ aura::RootWindow* 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->SetDefaultParentByRootWindow(root, bounds);
+ }
window->SetProperty(aura::client::kCanMaximizeKey, true);
return window;
}