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

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

Issue 153803006: Makes Wiget::OnNativeWidgetMove() be invoked during a maximize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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') | no next file » | 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 cfc94bfba8c500cf983f71b76a190462f23cee35..623352c05334563aeaa2839bc7e292c74c9e53d1 100644
--- a/ui/views/widget/native_widget_aura_unittest.cc
+++ b/ui/views/widget/native_widget_aura_unittest.cc
@@ -56,7 +56,7 @@ TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) {
scoped_ptr<aura::Window> parent(new aura::Window(NULL));
parent->Init(aura::WINDOW_LAYER_NOT_DRAWN);
parent->SetBounds(gfx::Rect(0, 0, 1024, 800));
- scoped_ptr<Widget> widget(new Widget());
+ scoped_ptr<Widget> widget(new Widget());
NativeWidgetAura* window = Init(parent.get(), widget.get());
window->CenterWindow(gfx::Size(100, 100));
@@ -369,5 +369,43 @@ TEST_F(NativeWidgetAuraTest, NoCrashOnThemeAfterClose) {
widget->GetNativeTheme(); // Shouldn't crash.
}
+// Used to track calls to WidgetDelegate::OnWidgetMove().
+class MoveTestWidgetDelegate : public WidgetDelegateView {
+ public:
+ MoveTestWidgetDelegate() : got_move_(false) {}
+ virtual ~MoveTestWidgetDelegate() {}
+
+ void ClearGotMove() { got_move_ = false; }
+ bool got_move() const { return got_move_; }
+
+ // WidgetDelegate overrides:
+ virtual void OnWidgetMove() OVERRIDE { got_move_ = true; }
+
+ private:
+ bool got_move_;
+
+ DISALLOW_COPY_AND_ASSIGN(MoveTestWidgetDelegate);
+};
+
+// This test simulates what happens when a window is normally maximized. That
+// is, it's layer is acquired for animation then the window is maximized.
+// Acquiring the layer resets the bounds of the window. This test verifies the
+// Widget is still notified correctly of a move in this case.
+TEST_F(NativeWidgetAuraTest, OnWidgetMovedInvokedAfterAcquireLayer) {
+ // |delegate| deletes itself when the widget is destroyed.
+ MoveTestWidgetDelegate* delegate = new MoveTestWidgetDelegate;
+ Widget* widget =
+ Widget::CreateWindowWithContextAndBounds(delegate,
+ root_window(),
+ gfx::Rect(10, 10, 100, 200));
+ widget->Show();
+ delegate->ClearGotMove();
+ // Simulate a maximize with animation.
+ delete widget->GetNativeView()->RecreateLayer();
+ widget->SetBounds(gfx::Rect(0, 0, 500, 500));
+ EXPECT_TRUE(delegate->got_move());
+ widget->CloseNow();
+}
+
} // namespace
} // namespace views
« no previous file with comments | « ui/views/widget/native_widget_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698