summaryrefslogtreecommitdiffstats
path: root/ash/screen_ash_unittest.cc
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-18 16:40:06 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-18 16:40:06 +0000
commit8d625fbd16a1d20f5e34bd01b83b0402bd3b4c80 (patch)
tree4fd429027e6fe44e79e8395ae63d6542d7edf657 /ash/screen_ash_unittest.cc
parent87cc09add3a1a9ef94aaec1865fc3aaa23720aaa (diff)
downloadchromium_src-8d625fbd16a1d20f5e34bd01b83b0402bd3b4c80.zip
chromium_src-8d625fbd16a1d20f5e34bd01b83b0402bd3b4c80.tar.gz
chromium_src-8d625fbd16a1d20f5e34bd01b83b0402bd3b4c80.tar.bz2
* Use Virtual Screen Coordinates in more places
- When setting widget bounds. - Workspace Manager - When resizing - Restore bounds * Refactored ScreenPositionClient to manage Screen coordinates for different configurations. * Renamed GetBounds/SetBounds methods to GetScreen/ParentBounds to make it clear that in which coordinates you're dealing with. * I used InScreen/InParent for RestoreBounds because RestoreParent/ScreenBounds sounds strange. Converted Linux/Aura to use ScreenPositionClient. BUG=123160 TEST=several tests are updated to match VSC. added screen_ash_unittests. I'll update rest of tests when this is enable by default. Review URL: https://chromiumcodereview.appspot.com/10696023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147250 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/screen_ash_unittest.cc')
-rw-r--r--ash/screen_ash_unittest.cc115
1 files changed, 115 insertions, 0 deletions
diff --git a/ash/screen_ash_unittest.cc b/ash/screen_ash_unittest.cc
new file mode 100644
index 0000000..96727c8
--- /dev/null
+++ b/ash/screen_ash_unittest.cc
@@ -0,0 +1,115 @@
+// Copyright (c) 2012 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/screen_ash.h"
+
+#include "ash/display/display_controller.h"
+#include "ash/shell.h"
+#include "ash/test/ash_test_base.h"
+#include "ash/wm/window_util.h"
+#include "ui/aura/env.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#include "ui/views/widget/widget.h"
+#include "ui/views/widget/widget_delegate.h"
+
+namespace ash {
+namespace test {
+class ScreenAshTest : public test::AshTestBase {
+ public:
+ ScreenAshTest() {}
+ virtual ~ScreenAshTest() {}
+
+ virtual void SetUp() OVERRIDE {
+ internal::DisplayController::SetExtendedDesktopEnabled(true);
+ internal::DisplayController::SetVirtualScreenCoordinatesEnabled(true);
+ AshTestBase::SetUp();
+ }
+
+ virtual void TearDown() OVERRIDE {
+ AshTestBase::TearDown();
+ internal::DisplayController::SetExtendedDesktopEnabled(false);
+ internal::DisplayController::SetVirtualScreenCoordinatesEnabled(false);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScreenAshTest);
+};
+
+#if !defined(OS_WIN)
+TEST_F(ScreenAshTest, Bounds) {
+ UpdateDisplay("0+0-600x600,600+0-500x500");
+
+ views::Widget* primary =
+ views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100));
+ primary->Show();
+ views::Widget* secondary =
+ views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100));
+ secondary->Show();
+
+ // Maximized bounds
+ EXPECT_EQ("0,0 600x598",
+ ScreenAsh::GetMaximizedWindowParentBounds(
+ primary->GetNativeView()).ToString());
+ EXPECT_EQ("0,0 500x500",
+ ScreenAsh::GetMaximizedWindowParentBounds(
+ secondary->GetNativeView()).ToString());
+
+ // Unmaximized work area bounds
+ EXPECT_EQ("0,0 600x552",
+ ScreenAsh::GetUnmaximizedWorkAreaParentBounds(
+ primary->GetNativeView()).ToString());
+ EXPECT_EQ("0,0 500x500",
+ ScreenAsh::GetUnmaximizedWorkAreaParentBounds(
+ secondary->GetNativeView()).ToString());
+
+ // Display bounds
+ EXPECT_EQ("0,0 600x600",
+ ScreenAsh::GetDisplayParentBounds(
+ primary->GetNativeView()).ToString());
+ EXPECT_EQ("0,0 500x500",
+ ScreenAsh::GetDisplayParentBounds(
+ secondary->GetNativeView()).ToString());
+
+ // Work area bounds
+ EXPECT_EQ("0,0 600x552",
+ ScreenAsh::GetDisplayWorkAreaParentBounds(
+ primary->GetNativeView()).ToString());
+ EXPECT_EQ("0,0 500x500",
+ ScreenAsh::GetDisplayWorkAreaParentBounds(
+ secondary->GetNativeView()).ToString());
+}
+#endif
+
+TEST_F(ScreenAshTest, ConvertRect) {
+ UpdateDisplay("0+0-600x600,600+0-500x500");
+
+ views::Widget* primary =
+ views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(10, 10, 100, 100));
+ primary->Show();
+ views::Widget* secondary =
+ views::Widget::CreateWindowWithBounds(NULL, gfx::Rect(610, 10, 100, 100));
+ secondary->Show();
+
+ EXPECT_EQ(
+ "0,0 100x100",
+ ScreenAsh::ConvertRectFromScreen(
+ primary->GetNativeView(), gfx::Rect(10, 10, 100, 100)).ToString());
+ EXPECT_EQ(
+ "10,10 100x100",
+ ScreenAsh::ConvertRectFromScreen(
+ secondary->GetNativeView(), gfx::Rect(620, 20, 100, 100)).ToString());
+
+ EXPECT_EQ(
+ "40,40 100x100",
+ ScreenAsh::ConvertRectToScreen(
+ primary->GetNativeView(), gfx::Rect(30, 30, 100, 100)).ToString());
+ EXPECT_EQ(
+ "650,50 100x100",
+ ScreenAsh::ConvertRectToScreen(
+ secondary->GetNativeView(), gfx::Rect(40, 40, 100, 100)).ToString());
+}
+
+} // namespace test
+} // namespace ash