summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-05 02:26:06 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-05 02:26:06 +0000
commit38beb36adc653c9b2da278eb9e12bc7c3f8bb7b0 (patch)
treeed5c83b0bc73fd155503591c5f3959ce86c413df /webkit/tools/test_shell
parentfe1444158f9187f28a4ee6b06826cc485fee1ced (diff)
downloadchromium_src-38beb36adc653c9b2da278eb9e12bc7c3f8bb7b0.zip
chromium_src-38beb36adc653c9b2da278eb9e12bc7c3f8bb7b0.tar.gz
chromium_src-38beb36adc653c9b2da278eb9e12bc7c3f8bb7b0.tar.bz2
Implement and refactor some test shell functions and enable a test.
Review URL: http://codereview.chromium.org/9087 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell')
-rw-r--r--webkit/tools/test_shell/SConscript6
-rw-r--r--webkit/tools/test_shell/gtk/test_webview_delegate.cc5
-rw-r--r--webkit/tools/test_shell/gtk/webview_host.cc1
-rw-r--r--webkit/tools/test_shell/run_all_tests.cc19
-rw-r--r--webkit/tools/test_shell/test_shell.cc20
-rw-r--r--webkit/tools/test_shell/test_shell.h8
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc23
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc28
8 files changed, 73 insertions, 37 deletions
diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript
index bf4dbe1..b591b8a 100644
--- a/webkit/tools/test_shell/SConscript
+++ b/webkit/tools/test_shell/SConscript
@@ -155,9 +155,11 @@ if env['PLATFORM'] == 'win32':
test_files = [
'image_decoder_unittest.cc',
'keyboard_unittest.cc',
- 'run_all_tests.cc',
'layout_test_controller_unittest.cc',
+ 'run_all_tests.cc',
+ 'test_shell_test.cc',
'$WEBKIT_DIR/glue/autocomplete_input_listener_unittest.cc',
+ '$WEBKIT_DIR/glue/cpp_bound_class_unittest.cc',
'$WEBKIT_DIR/glue/cpp_variant_unittest.cc',
'$WEBKIT_DIR/glue/glue_serialize_unittest.cc',
'$WEBKIT_DIR/glue/multipart_response_delegate_unittest.cc',
@@ -172,11 +174,9 @@ if env['PLATFORM'] == 'win32':
test_files.extend([
'node_leak_test.cc',
'plugin_tests.cc',
- 'test_shell_test.cc',
'text_input_controller_unittest.cc',
'$WEBKIT_DIR/glue/bookmarklet_unittest.cc',
'$WEBKIT_DIR/glue/context_menu_unittest.cc',
- '$WEBKIT_DIR/glue/cpp_bound_class_unittest.cc',
'$WEBKIT_DIR/glue/dom_operations_unittest.cc',
'$WEBKIT_DIR/glue/dom_serializer_unittest.cc',
'$WEBKIT_DIR/glue/iframe_redirect_unittest.cc',
diff --git a/webkit/tools/test_shell/gtk/test_webview_delegate.cc b/webkit/tools/test_shell/gtk/test_webview_delegate.cc
index 34dada3..c439e1f 100644
--- a/webkit/tools/test_shell/gtk/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/gtk/test_webview_delegate.cc
@@ -6,6 +6,8 @@
#include "webkit/tools/test_shell/test_webview_delegate.h"
+#include <gtk/gtk.h>
+
#include "base/gfx/point.h"
#include "base/string_util.h"
#include "net/base/net_errors.h"
@@ -667,7 +669,8 @@ void TestWebViewDelegate::UpdateAddressBar(WebView* webView) {
std::string frameURL = dataSource->GetRequest().GetMainDocumentURL().spec();
LOG(INFO) << " -- Address bar " << frameURL;
- NOTIMPLEMENTED();
+
+ gtk_entry_set_text(GTK_ENTRY(shell_->editWnd()), frameURL.c_str());
}
void TestWebViewDelegate::LocationChangeDone(WebDataSource* data_source) {
diff --git a/webkit/tools/test_shell/gtk/webview_host.cc b/webkit/tools/test_shell/gtk/webview_host.cc
index e21099d..020dd57 100644
--- a/webkit/tools/test_shell/gtk/webview_host.cc
+++ b/webkit/tools/test_shell/gtk/webview_host.cc
@@ -25,7 +25,6 @@ WebViewHost* WebViewHost::Create(GtkWidget* box,
g_object_set_data(G_OBJECT(host->view_), "webwidgethost", host);
host->webwidget_ = WebView::Create(delegate, prefs);
- host->webwidget_->Resize(gfx::Size(640, 480));
host->webwidget_->Layout();
return host;
diff --git a/webkit/tools/test_shell/run_all_tests.cc b/webkit/tools/test_shell/run_all_tests.cc
index 6b81c80..60de050 100644
--- a/webkit/tools/test_shell/run_all_tests.cc
+++ b/webkit/tools/test_shell/run_all_tests.cc
@@ -10,9 +10,12 @@
#if defined(OS_WIN)
#include <windows.h>
#include <commctrl.h>
+#elif defined(OS_LINUX)
+#include <gtk/gtk.h>
#endif
#include "base/at_exit.h"
+#include "base/command_line.h"
#include "base/icu_util.h"
#include "base/message_loop.h"
#include "base/process_util.h"
@@ -36,13 +39,17 @@ int main(int argc, char* argv[]) {
// the AtExitManager or else we will leak objects.
base::AtExitManager at_exit_manager;
+#if defined(OS_LINUX)
+ gtk_init(&argc, &argv);
+#endif
+
+#if defined(OS_POSIX)
+ CommandLine::SetArgcArgv(argc, argv);
+#endif
+
#if defined(OS_WIN)
TestShell::InitLogging(true, false); // suppress error dialogs
- // Initialize test shell in non-interactive mode, which will let us load one
- // request than automatically quit.
- TestShell::InitializeTestShell(false);
-
// Some of the individual tests wind up calling TestShell::WaitTestFinished
// which has a timeout in it. For these tests, we don't care about a timeout
// so just set it to be a really large number. This is necessary because
@@ -50,6 +57,10 @@ int main(int argc, char* argv[]) {
TestShell::SetFileTestTimeout(USER_TIMER_MAXIMUM);
#endif
+ // Initialize test shell in non-interactive mode, which will let us load one
+ // request than automatically quit.
+ TestShell::InitializeTestShell(false);
+
// Allocate a message loop for this thread. Although it is not used
// directly, its constructor sets up some necessary state.
MessageLoop main_message_loop;
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 5199a87..8fac9aa 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -312,6 +312,26 @@ void TestShell::Reload() {
navigation_controller_->Reload();
}
+void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
+ if (interactive_) {
+ InteractiveSetFocus(host, enable);
+ } else {
+ if (enable) {
+ if (m_focusedWidgetHost != host) {
+ if (m_focusedWidgetHost)
+ m_focusedWidgetHost->webwidget()->SetFocus(false);
+ host->webwidget()->SetFocus(enable);
+ m_focusedWidgetHost = host;
+ }
+ } else {
+ if (m_focusedWidgetHost == host) {
+ host->webwidget()->SetFocus(enable);
+ m_focusedWidgetHost = NULL;
+ }
+ }
+ }
+}
+
//-----------------------------------------------------------------------------
namespace webkit_glue {
diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h
index a0e7f34..bfafd37 100644
--- a/webkit/tools/test_shell/test_shell.h
+++ b/webkit/tools/test_shell/test_shell.h
@@ -233,6 +233,9 @@ protected:
void SizeTo(int width, int height);
void ResizeSubViews();
+ // Set the focus in interactive mode (pass through to relevant system call).
+ void InteractiveSetFocus(WebWidgetHost* host, bool enable);
+
#if defined(OS_WIN)
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM);
@@ -297,6 +300,11 @@ private:
// Dump the stats table counters on exit.
bool dump_stats_table_on_exit_;
+
+#if defined(OS_LINUX)
+ // The height of the non-rendering area of the main window, in pixels.
+ int toolbar_height_;
+#endif
};
#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_SHELL_H_
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index d30e4c1..543fd9c 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -120,16 +120,22 @@ bool TestShell::Initialize(const std::wstring& startingURL) {
gtk_container_add(GTK_CONTAINER(m_mainWnd), vbox);
gtk_widget_show_all(m_mainWnd);
+ toolbar_height_ = toolbar->allocation.height +
+ gtk_box_get_spacing(GTK_BOX(vbox));
return true;
}
void TestShell::TestFinished() {
- NOTIMPLEMENTED();
+ if(!test_is_pending_)
+ return;
+
+ test_is_pending_ = false;
+ MessageLoop::current()->Quit();
}
void TestShell::SizeTo(int width, int height) {
- NOTIMPLEMENTED();
+ gtk_window_resize(GTK_WINDOW(m_mainWnd), width, height + toolbar_height_);
}
void TestShell::WaitTestFinished() {
@@ -147,9 +153,16 @@ void TestShell::WaitTestFinished() {
MessageLoop::current()->Run();
}
-void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
- // TODO(agl): port the body of this function
- NOTIMPLEMENTED();
+void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) {
+ GtkWidget* widget = GTK_WIDGET(host->window_handle());
+
+ if (enable) {
+ gtk_widget_grab_focus(widget);
+ } else if (gtk_widget_is_focus(widget)) {
+ GtkWidget *toplevel = gtk_widget_get_toplevel(widget);
+ if (GTK_WIDGET_TOPLEVEL(toplevel))
+ gtk_window_set_focus(GTK_WINDOW(toplevel), NULL);
+ }
}
void TestShell::DestroyWindow(gfx::WindowHandle windowHandle) {
diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc
index b8b6ef0..1c05414 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -435,29 +435,11 @@ void TestShell::WaitTestFinished() {
WaitForSingleObject(thread_handle, 1000);
}
-void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
- if (interactive_) {
- if (enable) {
- ::SetFocus(host->window_handle());
- } else {
- if (GetFocus() == host->window_handle())
- ::SetFocus(NULL);
- }
- } else {
- if (enable) {
- if (m_focusedWidgetHost != host) {
- if (m_focusedWidgetHost)
- m_focusedWidgetHost->webwidget()->SetFocus(false);
- host->webwidget()->SetFocus(enable);
- m_focusedWidgetHost = host;
- }
- } else {
- if (m_focusedWidgetHost == host) {
- host->webwidget()->SetFocus(enable);
- m_focusedWidgetHost = NULL;
- }
- }
- }
+void TestShell::InteractiveSetFocus(WebWidgetHost* host, bool enable) {
+ if (enable)
+ ::SetFocus(host->window_handle());
+ else if (::GetFocus() == host->window_handle())
+ ::SetFocus(NULL);
}
WebWidget* TestShell::CreatePopupWidget(WebView* webview) {