summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 18:03:49 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-18 18:03:49 +0000
commitb442543a9dedc630af951b9d3059898870080c01 (patch)
treeebc9b62eb72d7ec39e9eabdc123587dfbb4aae9e /content/shell
parentcc203d4e670234278d71754bb0738097f8a06334 (diff)
downloadchromium_src-b442543a9dedc630af951b9d3059898870080c01.zip
chromium_src-b442543a9dedc630af951b9d3059898870080c01.tar.gz
chromium_src-b442543a9dedc630af951b9d3059898870080c01.tar.bz2
[content shell] run headless when in layout test mode
Currently only for gtk. There's also a command line flag --show-content-shell which overrides this for debugging BUG=111316 TEST=nothing should change R=marja@chromium.org Review URL: https://chromiumcodereview.appspot.com/11576003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/shell.cc11
-rw-r--r--content/shell/shell.h2
-rw-r--r--content/shell/shell_gtk.cc24
-rw-r--r--content/shell/shell_switches.cc3
-rw-r--r--content/shell/shell_switches.h1
5 files changed, 36 insertions, 5 deletions
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
index f21b6f9..a89af8a 100644
--- a/content/shell/shell.cc
+++ b/content/shell/shell.cc
@@ -45,11 +45,16 @@ Shell::Shell(WebContents* web_contents)
: dev_tools_(NULL),
is_fullscreen_(false),
window_(NULL),
- url_edit_view_(NULL)
+ url_edit_view_(NULL),
#if defined(OS_WIN) && !defined(USE_AURA)
- , default_edit_wnd_proc_(0)
+ default_edit_wnd_proc_(0),
#endif
- {
+ headless_(false) {
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(switches::kDumpRenderTree) &&
+ !command_line.HasSwitch(switches::kShowContentShell)) {
+ headless_ = true;
+ }
registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
Source<WebContents>(web_contents));
windows_.push_back(this);
diff --git a/content/shell/shell.h b/content/shell/shell.h
index 24173b9..748f9e6 100644
--- a/content/shell/shell.h
+++ b/content/shell/shell.h
@@ -242,6 +242,8 @@ class Shell : public WebContentsDelegate,
views::Widget* window_widget_;
#endif
+ bool headless_;
+
// A container of all the open windows. We use a vector so we can keep track
// of ordering.
static std::vector<Shell*> windows_;
diff --git a/content/shell/shell_gtk.cc b/content/shell/shell_gtk.cc
index 2cfbc47..8365ea1 100644
--- a/content/shell/shell_gtk.cc
+++ b/content/shell/shell_gtk.cc
@@ -62,6 +62,9 @@ void Shell::PlatformCleanUp() {
}
void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
+ if (headless_)
+ return;
+
GtkToolItem* item = NULL;
switch (control) {
case BACK_BUTTON:
@@ -81,10 +84,16 @@ void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
}
void Shell::PlatformSetAddressBarURL(const GURL& url) {
+ if (headless_)
+ return;
+
gtk_entry_set_text(GTK_ENTRY(url_edit_view_), url.spec().c_str());
}
void Shell::PlatformSetIsLoading(bool loading) {
+ if (headless_)
+ return;
+
if (loading)
gtk_spinner_start(GTK_SPINNER(spinner_));
else
@@ -92,6 +101,9 @@ void Shell::PlatformSetIsLoading(bool loading) {
}
void Shell::PlatformCreateWindow(int width, int height) {
+ if (headless_)
+ return;
+
window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
gtk_window_set_title(window_, "Content Shell");
g_signal_connect(G_OBJECT(window_), "destroy",
@@ -187,6 +199,9 @@ void Shell::PlatformCreateWindow(int width, int height) {
}
void Shell::PlatformSetContents() {
+ if (headless_)
+ return;
+
WebContentsView* content_view = web_contents_->GetView();
gtk_container_add(GTK_CONTAINER(vbox_), content_view->GetNativeView());
}
@@ -194,9 +209,8 @@ void Shell::PlatformSetContents() {
void Shell::SizeTo(int width, int height) {
content_width_ = width;
content_height_ = height;
- if (web_contents_.get()) {
+ if (web_contents_.get())
gtk_widget_set_size_request(web_contents_->GetNativeView(), width, height);
- }
}
void Shell::PlatformResizeSubViews() {
@@ -204,6 +218,9 @@ void Shell::PlatformResizeSubViews() {
}
void Shell::Close() {
+ if (headless_)
+ return;
+
gtk_widget_destroy(GTK_WIDGET(window_));
}
@@ -269,6 +286,9 @@ gboolean Shell::OnHighlightURLView(GtkAccelGroup* accel_group,
}
void Shell::PlatformSetTitle(const string16& title) {
+ if (headless_)
+ return;
+
std::string title_utf8 = UTF16ToUTF8(title);
gtk_window_set_title(GTK_WINDOW(window_), title_utf8.c_str());
}
diff --git a/content/shell/shell_switches.cc b/content/shell/shell_switches.cc
index be7f7cd..df50d5e 100644
--- a/content/shell/shell_switches.cc
+++ b/content/shell/shell_switches.cc
@@ -27,4 +27,7 @@ const char kNoTimeout[] = "no-timeout";
// Save results when layout-as-browser tests fail.
const char kOutputLayoutTestDifferences[] = "output-layout-test-differences";
+// Show the content_shell window, even when running in layout test mode.
+const char kShowContentShell[] = "show-content-shell";
+
} // namespace switches
diff --git a/content/shell/shell_switches.h b/content/shell/shell_switches.h
index c440013..e261bf3 100644
--- a/content/shell/shell_switches.h
+++ b/content/shell/shell_switches.h
@@ -16,6 +16,7 @@ extern const char kContentShellDataPath[];
extern const char kDumpRenderTree[];
extern const char kNoTimeout[];
extern const char kOutputLayoutTestDifferences[];
+extern const char kShowContentShell[];
} // namespace switches