Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: webkit/tools/test_shell/gtk/test_shell.cc

Issue 8670: Switch to using the message loop rather than gtk_main(). (Closed)
Patch Set: Addressing comments Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/tools/test_shell/SConscript ('k') | webkit/tools/test_shell/gtk/test_webview_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/tools/test_shell/gtk/test_shell.cc
diff --git a/webkit/tools/test_shell/gtk/test_shell.cc b/webkit/tools/test_shell/gtk/test_shell.cc
index 97dc66cc0fb8911755c25214305ced50ac2a500a..c048f045aff4504f5092a1e380d4d845ef73734e 100644
--- a/webkit/tools/test_shell/gtk/test_shell.cc
+++ b/webkit/tools/test_shell/gtk/test_shell.cc
@@ -10,26 +10,34 @@
#include "base/path_service.h"
#include "base/string_util.h"
#include "net/base/mime_util.h"
+#include "webkit/glue/webframe.h"
#include "webkit/glue/webpreferences.h"
+#include "webkit/glue/webview.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/resource_loader_bridge.h"
#include "webkit/tools/test_shell/test_navigation_controller.h"
+#include "webkit/tools/test_shell/test_webview_delegate.h"
WebPreferences* TestShell::web_prefs_ = NULL;
WindowList* TestShell::window_list_;
-TestShell::TestShell() {
+TestShell::TestShell()
+ : delegate_(new TestWebViewDelegate(this)) {
+ layout_test_controller_.reset(new LayoutTestController(this));
+ navigation_controller_.reset(new TestNavigationController(this));
}
TestShell::~TestShell() {
}
+bool TestShell::interactive_ = false;
+
// static
void TestShell::InitializeTestShell(bool interactive) {
window_list_ = new WindowList;
-
web_prefs_ = new WebPreferences;
+ interactive_ = interactive;
}
// static
@@ -78,21 +86,116 @@ bool TestShell::Initialize(const std::wstring& startingURL) {
gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
m_webViewHost.reset(WebViewHost::Create(vbox, NULL, *TestShell::web_prefs_));
+ if (!startingURL.empty())
+ LoadURL(startingURL.c_str());
+
gtk_container_add(GTK_CONTAINER(m_mainWnd), vbox);
gtk_widget_show_all(m_mainWnd);
return true;
}
+void TestShell::TestFinished() {
+ NOTIMPLEMENTED();
+}
+
+void TestShell::Show(WebView* webview, WindowOpenDisposition disposition) {
+ delegate_->Show(webview, disposition);
+}
+
+void TestShell::SetFocus(WebWidgetHost* host, bool enable) {
+ // TODO(agl): port the body of this function
+ NOTIMPLEMENTED();
+}
+
void TestShell::BindJSObjectsToWindow(WebFrame* frame) {
NOTIMPLEMENTED();
}
-bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) {
+void TestShell::DestroyWindow(gfx::WindowHandle windowHandle) {
+ NOTIMPLEMENTED();
+}
+
+WebView* TestShell::CreateWebView(WebView* webview) {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+WebWidget* TestShell::CreatePopupWidget(WebView* webview) {
NOTIMPLEMENTED();
+ return NULL;
+}
+
+void TestShell::LoadURL(const wchar_t* url)
+{
+ LoadURLForFrame(url, NULL);
+}
+
+void TestShell::LoadURLForFrame(const wchar_t* url,
+ const wchar_t* frame_name) {
+ if (!url)
+ return;
+
+ std::wstring frame_string;
+ if (frame_name)
+ frame_string = frame_name;
+
+ navigation_controller_->LoadEntry(new TestNavigationEntry(
+ -1, GURL(WideToUTF8(url)), std::wstring(), frame_string));
+}
+
+bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) {
+ WebRequestCachePolicy cache_policy;
+ if (reload) {
+ cache_policy = WebRequestReloadIgnoringCacheData;
+ } else if (entry.GetPageID() != -1) {
+ cache_policy = WebRequestReturnCacheDataElseLoad;
+ } else {
+ cache_policy = WebRequestUseProtocolCachePolicy;
+ }
+
+ scoped_ptr<WebRequest> request(WebRequest::Create(entry.GetURL()));
+ request->SetCachePolicy(cache_policy);
+ // If we are reloading, then WebKit will use the state of the current page.
+ // Otherwise, we give it the state to navigate to.
+ if (!reload)
+ request->SetHistoryState(entry.GetContentState());
+
+ request->SetExtraData(
+ new TestShellExtraRequestData(entry.GetPageID()));
+
+ // Get the right target frame for the entry.
+ WebFrame* frame = webView()->GetMainFrame();
+ if (!entry.GetTargetFrame().empty())
+ frame = webView()->GetFrameWithName(entry.GetTargetFrame());
+ // TODO(mpcomplete): should we clear the target frame, or should
+ // back/forward navigations maintain the target frame?
+
+ frame->LoadRequest(request.get());
+ // Restore focus to the main frame prior to loading new request.
+ // This makes sure that we don't have a focused iframe. Otherwise, that
+ // iframe would keep focus when the SetFocus called immediately after
+ // LoadRequest, thus making some tests fail (see http://b/issue?id=845337
+ // for more details).
+ webView()->SetFocusedFrame(frame);
+ SetFocus(webViewHost(), true);
+
return true;
}
+void TestShell::GoBackOrForward(int offset) {
+ navigation_controller_->GoToOffset(offset);
+}
+
+void TestShell::Reload() {
+ navigation_controller_->Reload();
+}
+
+std::string TestShell::RewriteLocalUrl(const std::string& url) {
+ NOTIMPLEMENTED();
+ return "";
+}
+
//-----------------------------------------------------------------------------
namespace webkit_glue {
« no previous file with comments | « webkit/tools/test_shell/SConscript ('k') | webkit/tools/test_shell/gtk/test_webview_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698