summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 18:39:30 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-26 18:39:30 +0000
commita764e16efd4e104e7e0d7a6f7827d0c5f73ec3ef (patch)
tree2c01abec174498ad8673edc3d4d9083010111ee3 /ash
parent37abba2c5dab032e73cf91e8792663e852434453 (diff)
downloadchromium_src-a764e16efd4e104e7e0d7a6f7827d0c5f73ec3ef.zip
chromium_src-a764e16efd4e104e7e0d7a6f7827d0c5f73ec3ef.tar.gz
chromium_src-a764e16efd4e104e7e0d7a6f7827d0c5f73ec3ef.tar.bz2
Set screen bounds in wm::CenterWindow
BUG=229401 TEST=covered by test Review URL: https://chromiumcodereview.appspot.com/14456007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196788 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/ash.gyp1
-rw-r--r--ash/wm/window_util.cc2
-rw-r--r--ash/wm/window_util_unittest.cc29
3 files changed, 31 insertions, 1 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 4080dce..37638a4 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -691,6 +691,7 @@
'wm/window_cycle_controller_unittest.cc',
'wm/window_manager_unittest.cc',
'wm/window_modality_controller_unittest.cc',
+ 'wm/window_util_unittest.cc',
'wm/workspace_controller_test_helper.cc',
'wm/workspace_controller_test_helper.h',
'wm/workspace/magnetism_matcher_unittest.cc',
diff --git a/ash/wm/window_util.cc b/ash/wm/window_util.cc
index 481a27c..b85824f 100644
--- a/ash/wm/window_util.cc
+++ b/ash/wm/window_util.cc
@@ -142,7 +142,7 @@ void CenterWindow(aura::Window* window) {
Shell::GetScreen()->GetDisplayNearestWindow(window);
gfx::Rect center = display.work_area();
center.ClampToCenteredSize(window->bounds().size());
- window->SetBounds(center);
+ window->SetBoundsInScreen(center, display);
}
bool IsWindowPositionManaged(const aura::Window* window) {
diff --git a/ash/wm/window_util_unittest.cc b/ash/wm/window_util_unittest.cc
new file mode 100644
index 0000000..930b658
--- /dev/null
+++ b/ash/wm/window_util_unittest.cc
@@ -0,0 +1,29 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/wm/window_util.h"
+
+#include "ash/screen_ash.h"
+#include "ash/test/ash_test_base.h"
+#include "ui/aura/window.h"
+
+namespace ash {
+
+typedef test::AshTestBase WindowUtilTest;
+
+TEST_F(WindowUtilTest, CenterWindow) {
+ UpdateDisplay("500x400, 600x400");
+ scoped_ptr<aura::Window> window(
+ CreateTestWindowInShellWithBounds(gfx::Rect(12, 20, 100, 100)));
+ wm::CenterWindow(window.get());
+ EXPECT_EQ("200,126 100x100", window->bounds().ToString());
+ EXPECT_EQ("200,126 100x100", window->GetBoundsInScreen().ToString());
+ window->SetBoundsInScreen(gfx::Rect(600, 0, 100, 100),
+ ScreenAsh::GetSecondaryDisplay());
+ wm::CenterWindow(window.get());
+ EXPECT_EQ("250,126 100x100", window->bounds().ToString());
+ EXPECT_EQ("750,126 100x100", window->GetBoundsInScreen().ToString());
+}
+
+} // namespace ash