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

Unified Diff: Source/web/tests/FrameTestHelpers.cpp

Issue 23506013: Make the embedder responsible for creating the WebFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix lifetime on frame detach Created 7 years, 3 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 | « Source/web/tests/FrameTestHelpers.h ('k') | Source/web/tests/LinkHighlightTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/FrameTestHelpers.cpp
diff --git a/Source/web/tests/FrameTestHelpers.cpp b/Source/web/tests/FrameTestHelpers.cpp
index 97fa4a87cdc1b5d7691fa659048d8edb43169ea3..90872adfb8901882e474a44ae4f8b56ada052ca4 100644
--- a/Source/web/tests/FrameTestHelpers.cpp
+++ b/Source/web/tests/FrameTestHelpers.cpp
@@ -33,11 +33,11 @@
#include "URLTestHelpers.h"
#include "wtf/StdLibExtras.h"
-#include "WebFrame.h"
#include "WebFrameClient.h"
+#include "WebFrameImpl.h"
#include "WebSettings.h"
-#include "WebView.h"
#include "WebViewClient.h"
+#include "WebViewImpl.h"
#include "public/platform/Platform.h"
#include "public/platform/WebString.h"
#include "public/platform/WebThread.h"
@@ -48,6 +48,30 @@
namespace WebKit {
namespace FrameTestHelpers {
+namespace {
+
+class QuitTask : public WebThread::Task {
+public:
+ virtual void run()
+ {
+ Platform::current()->currentThread()->exitRunLoop();
+ }
+};
+
+WebFrameClient* defaultWebFrameClient()
+{
+ DEFINE_STATIC_LOCAL(WebFrameClient, client, ());
+ return &client;
+}
+
+WebViewClient* defaultWebViewClient()
+{
+ DEFINE_STATIC_LOCAL(WebViewClient, client, ());
+ return &client;
+}
+
+} // namespace
+
void loadFrame(WebFrame* frame, const std::string& url)
{
WebURLRequest urlRequest;
@@ -56,61 +80,66 @@ void loadFrame(WebFrame* frame, const std::string& url)
frame->loadRequest(urlRequest);
}
-class TestWebFrameClient : public WebFrameClient {
-};
-
-static WebFrameClient* defaultWebFrameClient()
+void runPendingTasks()
{
- DEFINE_STATIC_LOCAL(TestWebFrameClient, client, ());
- return &client;
+ Platform::current()->currentThread()->postTask(new QuitTask);
+ Platform::current()->currentThread()->enterRunLoop();
}
-class TestWebViewClient : public WebViewClient {
-};
+WebViewHelper::WebViewHelper()
+ : m_mainFrame(0)
+ , m_webView(0)
+{
+}
-static WebViewClient* defaultWebViewClient()
+WebViewHelper::~WebViewHelper()
{
- DEFINE_STATIC_LOCAL(TestWebViewClient, client, ());
- return &client;
+ reset();
}
-WebView* createWebView(bool enableJavascript, WebFrameClient* webFrameClient, WebViewClient* webViewClient)
+WebViewImpl* WebViewHelper::initialize(bool enableJavascript, WebFrameClient* webFrameClient, WebViewClient* webViewClient, void (*updateSettingsFunc)(WebSettings*))
{
+ reset();
+
if (!webFrameClient)
webFrameClient = defaultWebFrameClient();
if (!webViewClient)
webViewClient = defaultWebViewClient();
- WebView* webView = WebView::create(webViewClient);
- webView->settings()->setJavaScriptEnabled(enableJavascript);
- webView->settings()->setDeviceSupportsMouse(false);
- webView->settings()->setForceCompositingMode(true);
- webView->initializeMainFrame(webFrameClient);
+ m_webView = WebViewImpl::create(webViewClient);
+ m_webView->settings()->setJavaScriptEnabled(enableJavascript);
+ if (updateSettingsFunc) {
+ updateSettingsFunc(m_webView->settings());
+ } else {
+ m_webView->settings()->setDeviceSupportsMouse(false);
+ m_webView->settings()->setForceCompositingMode(true);
+ }
+
+ m_mainFrame = WebFrameImpl::create(webFrameClient);
+ m_webView->setMainFrame(m_mainFrame);
- return webView;
+ return m_webView;
}
-WebView* createWebViewAndLoad(const std::string& url, bool enableJavascript, WebFrameClient* webFrameClient, WebViewClient* webViewClient)
+WebViewImpl* WebViewHelper::initializeAndLoad(const std::string& url, bool enableJavascript, WebFrameClient* webFrameClient, WebViewClient* webViewClient, void (*updateSettingsFunc)(WebSettings*))
{
- WebView* webView = createWebView(enableJavascript, webFrameClient, webViewClient);
+ initialize(enableJavascript, webFrameClient, webViewClient, updateSettingsFunc);
- loadFrame(webView->mainFrame(), url);
+ loadFrame(webView()->mainFrame(), url);
Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();
- return webView;
+ return webViewImpl();
}
-class QuitTask : public WebThread::Task {
-public:
- virtual void run()
- {
- Platform::current()->currentThread()->exitRunLoop();
- }
-};
-
-void runPendingTasks()
+void WebViewHelper::reset()
{
- Platform::current()->currentThread()->postTask(new QuitTask);
- Platform::current()->currentThread()->enterRunLoop();
+ if (m_webView) {
+ m_webView->close();
+ m_webView = 0;
+ }
+ if (m_mainFrame) {
+ m_mainFrame->close();
+ m_mainFrame = 0;
+ }
}
} // namespace FrameTestHelpers
« no previous file with comments | « Source/web/tests/FrameTestHelpers.h ('k') | Source/web/tests/LinkHighlightTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698