Commit 8f04ff93 authored by arv@google.com's avatar arv@google.com

Adds a way to set the boundaries of the browser window through

automation and use that to set the size of the window in the

"New Tab Cold" to ensure we are testing the normal case and not the
small case.

BUG=None

TEST=The NewTabUIStartupTest, PerfCold should still work.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20124 0039d316-1c4b-4281-b951-d872f2087c98
parent 7b3013e6
......@@ -950,6 +950,7 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand,
ExecuteBrowserCommand)
IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds)
IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds)
IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible)
#if defined(OS_WIN)
IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick)
......@@ -1713,6 +1714,18 @@ void AutomationProvider::GetFocusedViewID(int handle, int* view_id) {
}
}
void AutomationProvider::SetWindowBounds(int handle, const gfx::Rect& bounds,
bool* success) {
*success = false;
if (window_tracker_->ContainsHandle(handle)) {
HWND hwnd = window_tracker_->GetResource(handle);
if (::MoveWindow(hwnd, bounds.x(), bounds.y(), bounds.width(),
bounds.height(), true)) {
*success = true;
}
}
}
void AutomationProvider::SetWindowVisible(int handle, bool visible,
bool* result) {
if (window_tracker_->ContainsHandle(handle)) {
......
......@@ -180,6 +180,7 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
int handle,
wchar_t key,
int flags);
void SetWindowBounds(int handle, const gfx::Rect& bounds, bool* result);
void SetWindowVisible(int handle, bool visible, bool* result);
void IsWindowActive(int handle, bool* success, bool* is_active);
void ActivateWindow(int handle);
......
......@@ -47,6 +47,12 @@ void AutomationProvider::ActivateWindow(int handle) { NOTIMPLEMENTED(); }
void AutomationProvider::SetWindowVisible(int handle, bool visible,
bool* result) { NOTIMPLEMENTED(); }
void AutomationProvider::SetWindowBounds(int handle, const gfx::Rect& bounds,
bool* success) {
NOTIMPLEMENTED();
}
void AutomationProvider::GetFocusedViewID(int handle, int* view_id) {
NOTIMPLEMENTED();
}
......
......@@ -257,6 +257,15 @@ IPC_BEGIN_MESSAGES(Automation)
IPC_SYNC_MESSAGE_ROUTED3_2(AutomationMsg_WindowViewBounds, int, int,
bool, bool, gfx::Rect)
// This message sets the bounds of the window.
// Request:
// int - the handle of the window to resize
// gfx::Rect - the bounds of the window
// Response:
// bool - true if the resize was successful
IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_SetWindowBounds, int, gfx::Rect,
bool)
#if defined(OS_WIN)
// TODO(port): Port these messages.
//
......
......@@ -106,6 +106,15 @@ bool WindowProxy::GetViewBoundsWithTimeout(int view_id, gfx::Rect* bounds,
return result;
}
bool WindowProxy::SetBounds(const gfx::Rect& bounds) {
if (!is_valid())
return false;
bool result = false;
sender_->Send(new AutomationMsg_SetWindowBounds(0, handle_, bounds,
&result));
return result;
}
bool WindowProxy::GetFocusedViewID(int* view_id) {
if (!is_valid()) return false;
......
......@@ -82,6 +82,11 @@ class WindowProxy : public AutomationResourceProxy {
bool GetViewBoundsWithTimeout(int view_id, gfx::Rect* bounds,
bool screen_coordinates, uint32 timeout_ms,
bool* is_timeout);
// Sets the position and size of the window. Returns true if setting the
// bounds was successful.
bool SetBounds(const gfx::Rect& bounds);
// Gets the id of the view that currently has focus. Returns true if the id
// was retrieved.
bool GetFocusedViewID(int* view_id);
......
......@@ -3,12 +3,14 @@
// found in the LICENSE file.
#include "base/file_util.h"
#include "base/gfx/rect.h"
#include "base/path_service.h"
#include "base/perftimer.h"
#include "base/time.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/automation/browser_proxy.h"
#include "chrome/test/automation/window_proxy.h"
#include "chrome/test/ui/ui_test.h"
#include "net/base/net_util.h"
......@@ -61,6 +63,7 @@ class NewTabUIStartupTest : public UITest {
// first (the first is about:blank).
scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
ASSERT_TRUE(window.get());
ASSERT_TRUE(window->GetWindow().get()->SetBounds(gfx::Rect(1000, 1000)));
int tab_count = -1;
ASSERT_TRUE(window->GetTabCount(&tab_count));
ASSERT_EQ(1, tab_count);
......
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