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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/native_widget_aura.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 private: 50 private:
51 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest); 51 DISALLOW_COPY_AND_ASSIGN(NativeWidgetAuraTest);
52 }; 52 };
53 53
54 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) { 54 TEST_F(NativeWidgetAuraTest, CenterWindowLargeParent) {
55 // Make a parent window larger than the host represented by rootwindow. 55 // Make a parent window larger than the host represented by rootwindow.
56 scoped_ptr<aura::Window> parent(new aura::Window(NULL)); 56 scoped_ptr<aura::Window> parent(new aura::Window(NULL));
57 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); 57 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN);
58 parent->SetBounds(gfx::Rect(0, 0, 1024, 800)); 58 parent->SetBounds(gfx::Rect(0, 0, 1024, 800));
59 scoped_ptr<Widget> widget(new Widget()); 59 scoped_ptr<Widget> widget(new Widget());
60 NativeWidgetAura* window = Init(parent.get(), widget.get()); 60 NativeWidgetAura* window = Init(parent.get(), widget.get());
61 61
62 window->CenterWindow(gfx::Size(100, 100)); 62 window->CenterWindow(gfx::Size(100, 100));
63 EXPECT_EQ(gfx::Rect( (640 - 100) / 2, 63 EXPECT_EQ(gfx::Rect( (640 - 100) / 2,
64 (480 - 100) / 2, 64 (480 - 100) / 2,
65 100, 100), 65 100, 100),
66 window->GetNativeWindow()->bounds()); 66 window->GetNativeWindow()->bounds());
67 widget->CloseNow(); 67 widget->CloseNow();
68 } 68 }
69 69
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN); 362 parent->Init(aura::WINDOW_LAYER_NOT_DRAWN);
363 parent->SetBounds(gfx::Rect(0, 0, 480, 320)); 363 parent->SetBounds(gfx::Rect(0, 0, 480, 320));
364 scoped_ptr<Widget> widget(new Widget()); 364 scoped_ptr<Widget> widget(new Widget());
365 NativeWidgetAura* window = Init(parent.get(), widget.get()); 365 NativeWidgetAura* window = Init(parent.get(), widget.get());
366 window->Show(); 366 window->Show();
367 window->Close(); 367 window->Close();
368 base::MessageLoop::current()->RunUntilIdle(); 368 base::MessageLoop::current()->RunUntilIdle();
369 widget->GetNativeTheme(); // Shouldn't crash. 369 widget->GetNativeTheme(); // Shouldn't crash.
370 } 370 }
371 371
372 // Used to track calls to WidgetDelegate::OnWidgetMove().
373 class MoveTestWidgetDelegate : public WidgetDelegateView {
374 public:
375 MoveTestWidgetDelegate() : got_move_(false) {}
376 virtual ~MoveTestWidgetDelegate() {}
377
378 void ClearGotMove() { got_move_ = false; }
379 bool got_move() const { return got_move_; }
380
381 // WidgetDelegate overrides:
382 virtual void OnWidgetMove() OVERRIDE { got_move_ = true; }
383
384 private:
385 bool got_move_;
386
387 DISALLOW_COPY_AND_ASSIGN(MoveTestWidgetDelegate);
388 };
389
390 // This test simulates what happens when a window is normally maximized. That
391 // is, it's layer is acquired for animation then the window is maximized.
392 // Acquiring the layer resets the bounds of the window. This test verifies the
393 // Widget is still notified correctly of a move in this case.
394 TEST_F(NativeWidgetAuraTest, OnWidgetMovedInvokedAfterAcquireLayer) {
395 // |delegate| deletes itself when the widget is destroyed.
396 MoveTestWidgetDelegate* delegate = new MoveTestWidgetDelegate;
397 Widget* widget =
398 Widget::CreateWindowWithContextAndBounds(delegate,
399 root_window(),
400 gfx::Rect(10, 10, 100, 200));
401 widget->Show();
402 delegate->ClearGotMove();
403 // Simulate a maximize with animation.
404 delete widget->GetNativeView()->RecreateLayer();
405 widget->SetBounds(gfx::Rect(0, 0, 500, 500));
406 EXPECT_TRUE(delegate->got_move());
407 widget->CloseNow();
408 }
409
372 } // namespace 410 } // namespace
373 } // namespace views 411 } // namespace views
OLDNEW
« 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