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

Unified Diff: views/widget/widget_win_unittest.cc

Issue 6268002: WidgetWin::SetBound on a maximized window leaves the window in the 'maximized' state. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated copyright year in the modified files. Created 9 years, 11 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 | « views/widget/widget_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/widget/widget_win_unittest.cc
diff --git a/views/widget/widget_win_unittest.cc b/views/widget/widget_win_unittest.cc
new file mode 100755
index 0000000000000000000000000000000000000000..28b4d9fe79d9bd70c6428b883dc152831604256d
--- /dev/null
+++ b/views/widget/widget_win_unittest.cc
@@ -0,0 +1,81 @@
+// Copyright (c) 2011 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 "views/widget/widget_win.h"
+
+#include "base/basictypes.h"
+#include "base/message_loop.h"
+#include "base/scoped_ptr.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using namespace views;
+
+class WidgetWinTest : public testing::Test {
+ public:
+ WidgetWinTest() {
+ OleInitialize(NULL);
+ }
+
+ ~WidgetWinTest() {
+ OleUninitialize();
+ }
+
+ virtual void TearDown() {
+ // Flush the message loop because we have pending release tasks
+ // and these tasks if un-executed would upset Valgrind.
+ RunPendingMessages();
+ }
+
+ // Create a simple widget win. The caller is responsible for taking ownership
+ // of the returned value.
+ WidgetWin* CreateWidgetWin();
+
+ void RunPendingMessages() {
+ message_loop_.RunAllPending();
+ }
+
+ private:
+ MessageLoopForUI message_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(WidgetWinTest);
+};
+
+
+WidgetWin* WidgetWinTest::CreateWidgetWin() {
+ scoped_ptr<WidgetWin> window(new WidgetWin());
+ window->set_delete_on_destroy(false);
+ window->set_window_style(WS_OVERLAPPEDWINDOW);
+ window->Init(NULL, gfx::Rect(50, 50, 650, 650));
+ return window.release();
+}
+
+TEST_F(WidgetWinTest, ZoomWindow) {
+ scoped_ptr<WidgetWin> window(CreateWidgetWin());
+ window->ShowWindow(SW_HIDE);
+ EXPECT_FALSE(window->IsActive());
+ window->ShowWindow(SW_MAXIMIZE);
+ EXPECT_TRUE(window->IsZoomed());
+ window->CloseNow();
+}
+
+TEST_F(WidgetWinTest, SetBoundsForZoomedWindow) {
+ scoped_ptr<WidgetWin> window(CreateWidgetWin());
+ window->ShowWindow(SW_MAXIMIZE);
+ EXPECT_TRUE(window->IsZoomed());
+
+ // Create another window, so that it will be active.
+ scoped_ptr<WidgetWin> window2(CreateWidgetWin());
+ window2->ShowWindow(SW_MAXIMIZE);
+ EXPECT_TRUE(window2->IsActive());
+
+ // Verify that setting the bounds of a zoomed window will unzoom it and not
+ // cause it to be activated.
+ window->SetBounds(gfx::Rect(50, 50, 650, 650));
+ EXPECT_FALSE(window->IsZoomed());
+ EXPECT_FALSE(window->IsActive());
+
+ // Cleanup.
+ window->CloseNow();
+ window2->CloseNow();
+}
« no previous file with comments | « views/widget/widget_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698