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

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

Issue 10795078: Fixes two bugs related to constrained windows: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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_aura.cc ('k') | ui/views/window/client_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/native_widget_aura_unittest.cc
diff --git a/ui/views/widget/native_widget_aura_unittest.cc b/ui/views/widget/native_widget_aura_unittest.cc
index d589f4d96e1bce7c446e58f3a6cd47083ebfc852..a516e1435bbc2344cd8010aa4735e74e9d329ad2 100644
--- a/ui/views/widget/native_widget_aura_unittest.cc
+++ b/ui/views/widget/native_widget_aura_unittest.cc
@@ -81,7 +81,7 @@ TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) {
parent->Init(ui::LAYER_NOT_DRAWN);
parent->SetBounds(gfx::Rect(0, 0, 480, 320));
scoped_ptr<Widget> widget(new Widget());
- NativeWidgetAura* window = Init(parent.get(), widget.get());
+ NativeWidgetAura* window = Init(parent.get(), widget.get());
window->CenterWindow(gfx::Size(100, 100));
EXPECT_EQ(gfx::Rect( (480 - 100) / 2,
@@ -91,6 +91,22 @@ TEST_F(NativeWidgetAuraTest, CenterWindowSmallParent) {
widget->CloseNow();
}
+// Verifies CenterWindow() constrains to parent size.
+TEST_F(NativeWidgetAuraTest, CenterWindowSmallParentNotAtOrigin) {
+ // Make a parent window smaller than the host represented by rootwindow and
+ // offset it slightly from the origin.
+ scoped_ptr<aura::Window> parent(new aura::Window(NULL));
+ parent->Init(ui::LAYER_NOT_DRAWN);
+ parent->SetBounds(gfx::Rect(20, 40, 480, 320));
+ scoped_ptr<Widget> widget(new Widget());
+ NativeWidgetAura* window = Init(parent.get(), widget.get());
+ window->CenterWindow(gfx::Size(500, 600));
+
+ // |window| should be no bigger than |parent|.
+ EXPECT_EQ("20,40 480x320", window->GetNativeWindow()->bounds().ToString());
+ widget->CloseNow();
+}
+
// Used by ShowMaximizedDoesntBounceAround. See it for details.
class TestLayoutManager : public aura::LayoutManager {
public:
« no previous file with comments | « ui/views/widget/native_widget_aura.cc ('k') | ui/views/window/client_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698