diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-28 04:26:11 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-28 04:26:11 +0000 |
commit | 1e57cab1ea720cd4126c398c18771df5e099e196 (patch) | |
tree | 3c60431f000890b1bf90589db850c7ce0577f0f8 /content | |
parent | 39c36df426e55c3705c138b0596a59e976aa728f (diff) | |
download | chromium_src-1e57cab1ea720cd4126c398c18771df5e099e196.zip chromium_src-1e57cab1ea720cd4126c398c18771df5e099e196.tar.gz chromium_src-1e57cab1ea720cd4126c398c18771df5e099e196.tar.bz2 |
[content shell] add support for running headless on mac
BUG=111316
Review URL: https://chromiumcodereview.appspot.com/15702006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/shell/renderer/webkit_test_runner.cc | 1 | ||||
-rw-r--r-- | content/shell/shell.cc | 13 | ||||
-rw-r--r-- | content/shell/shell.h | 3 | ||||
-rw-r--r-- | content/shell/shell_mac.mm | 26 | ||||
-rw-r--r-- | content/shell/webkit_test_controller.cc | 6 |
5 files changed, 38 insertions, 11 deletions
diff --git a/content/shell/renderer/webkit_test_runner.cc b/content/shell/renderer/webkit_test_runner.cc index 866b096..c423835 100644 --- a/content/shell/renderer/webkit_test_runner.cc +++ b/content/shell/renderer/webkit_test_runner.cc @@ -568,6 +568,7 @@ void WebKitTestRunner::Navigate(const GURL& url) { ShellRenderProcessObserver::GetInstance()->test_interfaces(); interfaces->setTestIsRunning(true); interfaces->configureForTestWithURL(GURL(), false); + ForceResizeRenderView(render_view(), WebSize(800, 600)); } } diff --git a/content/shell/shell.cc b/content/shell/shell.cc index 4911043..d1e691b 100644 --- a/content/shell/shell.cc +++ b/content/shell/shell.cc @@ -32,12 +32,11 @@ #include "content/shell/shell_javascript_dialog_manager.h" #include "content/shell/webkit_test_controller.h" -// Content area size for newly created windows. -static const int kTestWindowWidth = 800; -static const int kTestWindowHeight = 600; - namespace content { +const int Shell::kDefaultTestWindowWidthDip = 800; +const int Shell::kDefaultTestWindowHeightDip = 600; + std::vector<Shell*> Shell::windows_; base::Callback<void(Shell*)> Shell::shell_created_callback_; @@ -147,7 +146,8 @@ Shell* Shell::FromRenderViewHost(RenderViewHost* rvh) { // static void Shell::Initialize() { - PlatformInitialize(gfx::Size(kTestWindowWidth, kTestWindowHeight)); + PlatformInitialize( + gfx::Size(kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip)); } Shell* Shell::CreateNewWindow(BrowserContext* browser_context, @@ -160,7 +160,8 @@ Shell* Shell::CreateNewWindow(BrowserContext* browser_context, if (!initial_size.IsEmpty()) create_params.initial_size = initial_size; else - create_params.initial_size = gfx::Size(kTestWindowWidth, kTestWindowHeight); + create_params.initial_size = + gfx::Size(kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip); WebContents* web_contents = WebContents::Create(create_params); Shell* shell = CreateShell(web_contents, create_params.initial_size); if (!url.is_empty()) diff --git a/content/shell/shell.h b/content/shell/shell.h index d2d76cf..797256c 100644 --- a/content/shell/shell.h +++ b/content/shell/shell.h @@ -51,6 +51,9 @@ class WebContents; class Shell : public WebContentsDelegate, public NotificationObserver { public: + static const int kDefaultTestWindowWidthDip; + static const int kDefaultTestWindowHeightDip; + virtual ~Shell(); void LoadURL(const GURL& url); diff --git a/content/shell/shell_mac.mm b/content/shell/shell_mac.mm index f4c6789..be92130 100644 --- a/content/shell/shell_mac.mm +++ b/content/shell/shell_mac.mm @@ -130,6 +130,9 @@ void Shell::PlatformCleanUp() { } void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { + if (headless_) + return; + int id; switch (control) { case BACK_BUTTON: @@ -149,6 +152,9 @@ void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { } void Shell::PlatformSetAddressBarURL(const GURL& url) { + if (headless_) + return; + NSString* url_string = base::SysUTF8ToNSString(url.spec()); [url_edit_view_ setStringValue:url_string]; } @@ -157,6 +163,9 @@ void Shell::PlatformSetIsLoading(bool loading) { } void Shell::PlatformCreateWindow(int width, int height) { + if (headless_) + return; + NSRect initial_window_bounds = NSMakeRect(0, 0, width, height + kURLBarHeight); NSRect content_rect = initial_window_bounds; @@ -229,6 +238,15 @@ void Shell::PlatformCreateWindow(int width, int height) { void Shell::PlatformSetContents() { NSView* web_view = web_contents_->GetView()->GetNativeView(); + + if (headless_) { + NSRect frame = NSMakeRect( + 0, 0, kDefaultTestWindowWidthDip, kDefaultTestWindowHeightDip); + [web_view setFrame:frame]; + [web_view setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; + return; + } + NSView* content = [window_ contentView]; [content addSubview:web_view]; @@ -244,12 +262,18 @@ void Shell::PlatformResizeSubViews() { } void Shell::PlatformSetTitle(const string16& title) { + if (headless_) + return; + NSString* title_string = base::SysUTF16ToNSString(title); [window_ setTitle:title_string]; } void Shell::Close() { - [window_ performClose:nil]; + if (headless_) + delete this; + else + [window_ performClose:nil]; } void Shell::ActionPerformed(int control) { diff --git a/content/shell/webkit_test_controller.cc b/content/shell/webkit_test_controller.cc index 7239ed1..a07c83e 100644 --- a/content/shell/webkit_test_controller.cc +++ b/content/shell/webkit_test_controller.cc @@ -38,9 +38,6 @@ const int kTestTimeoutMilliseconds = 30 * 1000; // 0x20000000ms is big enough for the purpose to avoid timeout in debugging. const int kCloseEnoughToInfinity = 0x20000000; -const int kTestWindowWidthDip = 800; -const int kTestWindowHeightDip = 600; - const int kTestSVGWindowWidthDip = 480; const int kTestSVGWindowHeightDip = 360; @@ -210,7 +207,8 @@ bool WebKitTestController::PrepareForLayoutTest( ShellContentBrowserClient::Get()->browser_context(); if (test_url.spec().find("compositing/") != std::string::npos) is_compositing_test_ = true; - initial_size_ = gfx::Size(kTestWindowWidthDip, kTestWindowHeightDip); + initial_size_ = gfx::Size( + Shell::kDefaultTestWindowWidthDip, Shell::kDefaultTestWindowHeightDip); // The W3C SVG layout tests use a different size than the other layout tests. if (test_url.spec().find("W3C-SVG-1.1") != std::string::npos) initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); |