Commit fd4aafc8 authored by levin@chromium.org's avatar levin@chromium.org

WidgetWin::SetBound on a maximized window leaves the window in the 'maximized' state.

Now when SetBounds is called, we detect the maximized state and take the window
out of this state.

BUG=69618
TEST=WidgetWinTest.SetBoundsForZoomedWindow (added)

Review URL: http://codereview.chromium.org/6268002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71499 0039d316-1c4b-4281-b951-d872f2087c98
parent 221287ab
# Copyright (c) 2010 The Chromium Authors. All rights reserved. # Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
...@@ -440,6 +440,7 @@ ...@@ -440,6 +440,7 @@
'run_all_unittests.cc', 'run_all_unittests.cc',
'test/test_views_delegate.h', 'test/test_views_delegate.h',
'view_unittest.cc', 'view_unittest.cc',
'widget/widget_win_unittest.cc',
'<(SHARED_INTERMEDIATE_DIR)/app/app_resources/app_resources.rc', '<(SHARED_INTERMEDIATE_DIR)/app/app_resources/app_resources.rc',
], ],
......
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -239,6 +239,8 @@ void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const { ...@@ -239,6 +239,8 @@ void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const {
} }
void WidgetWin::SetBounds(const gfx::Rect& bounds) { void WidgetWin::SetBounds(const gfx::Rect& bounds) {
if (IsZoomed())
ShowWindow(SW_SHOWNOACTIVATE);
SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(), SetWindowPos(NULL, bounds.x(), bounds.y(), bounds.width(), bounds.height(),
SWP_NOACTIVATE | SWP_NOZORDER); SWP_NOACTIVATE | SWP_NOZORDER);
} }
......
// 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();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment