Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: ui/views/widget/widget_unittest.cc

Issue 353643002: MacViews: Implement Set/Get*Bounds for NativeWidgetMac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: import Foundation.h for NSRect Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/native_widget_mac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget_unittest.cc
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index 33a8cae11c85e63aa45dd7bb8f31ce219abc625c..da3ec9332e07ed21e7b3cf5dd1355c033a29dde7 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -855,6 +855,65 @@ TEST_F(WidgetObserverTest, WidgetBoundsChanged) {
EXPECT_EQ(child2, widget_bounds_changed());
}
+// Tests that SetBounds() and GetWindowBoundsInScreen() is symmetric when the
+// widget is visible and not maximized or fullscreen.
+TEST_F(WidgetTest, GetWindowBoundsInScreen) {
+ // Choose test coordinates away from edges and dimensions that are "small"
+ // (but not too small) to ensure the OS doesn't try to adjust them.
+ const gfx::Rect kTestBounds(150, 150, 400, 300);
+ const gfx::Size kTestSize(200, 180);
+
+ // First test a toplevel widget.
+ Widget* widget = CreateTopLevelPlatformWidget();
+ widget->Show();
+
+ EXPECT_NE(kTestSize.ToString(),
+ widget->GetWindowBoundsInScreen().size().ToString());
+ widget->SetSize(kTestSize);
+ EXPECT_EQ(kTestSize.ToString(),
+ widget->GetWindowBoundsInScreen().size().ToString());
+
+ EXPECT_NE(kTestBounds.ToString(),
+ widget->GetWindowBoundsInScreen().ToString());
+ widget->SetBounds(kTestBounds);
+ EXPECT_EQ(kTestBounds.ToString(),
+ widget->GetWindowBoundsInScreen().ToString());
+
+ // Changing just the size should not change the origin.
+ widget->SetSize(kTestSize);
+ EXPECT_EQ(kTestBounds.origin().ToString(),
+ widget->GetWindowBoundsInScreen().origin().ToString());
+
+ widget->CloseNow();
+
+ // Same tests with a frameless window.
+ widget = CreateTopLevelFramelessPlatformWidget();
+ widget->Show();
+
+ EXPECT_NE(kTestSize.ToString(),
+ widget->GetWindowBoundsInScreen().size().ToString());
+ widget->SetSize(kTestSize);
+ EXPECT_EQ(kTestSize.ToString(),
+ widget->GetWindowBoundsInScreen().size().ToString());
+
+ EXPECT_NE(kTestBounds.ToString(),
+ widget->GetWindowBoundsInScreen().ToString());
+ widget->SetBounds(kTestBounds);
+ EXPECT_EQ(kTestBounds.ToString(),
+ widget->GetWindowBoundsInScreen().ToString());
+
+ // For a frameless widget, the client bounds should also match.
+ EXPECT_EQ(kTestBounds.ToString(),
+ widget->GetClientAreaBoundsInScreen().ToString());
+
+ // Verify origin is stable for a frameless window as well.
+ widget->SetSize(kTestSize);
+ EXPECT_EQ(kTestBounds.origin().ToString(),
+ widget->GetWindowBoundsInScreen().origin().ToString());
+
+ widget->CloseNow();
+}
+
#if defined(false)
// Aura needs shell to maximize/fullscreen window.
// NativeWidgetGtk doesn't implement GetRestoredBounds.
« no previous file with comments | « ui/views/widget/native_widget_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698