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

Unified Diff: components/test_runner/web_frame_test_proxy.h

Issue 1841833005: Revert of Extract WebFrameClient implementation out of WebTestProxyBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « components/test_runner/web_frame_test_client.cc ('k') | components/test_runner/web_test_interfaces.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/web_frame_test_proxy.h
diff --git a/components/test_runner/web_frame_test_proxy.h b/components/test_runner/web_frame_test_proxy.h
index ce58447b8cef30cb23bb814e6bcaf5d2469d6edd..7f90583c2fde4c0584b5858102189caee89bad44 100644
--- a/components/test_runner/web_frame_test_proxy.h
+++ b/components/test_runner/web_frame_test_proxy.h
@@ -5,92 +5,79 @@
#ifndef COMPONENTS_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_
#define COMPONENTS_TEST_RUNNER_WEB_FRAME_TEST_PROXY_H_
-#include "base/logging.h"
#include "base/macros.h"
+#include "components/test_runner/mock_screen_orientation_client.h"
+#include "components/test_runner/web_test_delegate.h"
+#include "components/test_runner/web_test_interfaces.h"
+#include "components/test_runner/web_test_proxy.h"
+#include "components/test_runner/web_test_runner.h"
#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/web/WebFrameClient.h"
-#include "third_party/WebKit/public/web/WebLocalFrame.h"
namespace test_runner {
-class WebFrameTestProxyBase {
+// Templetized wrapper around RenderFrameImpl objects, which implement
+// the WebFrameClient interface.
+template <class Base, typename P>
+class WebFrameTestProxy : public Base {
public:
- void set_test_client(blink::WebFrameClient* client) {
- DCHECK(client);
- DCHECK(!test_client_);
- test_client_ = client;
- }
-
- protected:
- WebFrameTestProxyBase() : test_client_(nullptr) {}
- blink::WebFrameClient* test_client() { return test_client_; }
-
- private:
- blink::WebFrameClient* test_client_;
-
- DISALLOW_COPY_AND_ASSIGN(WebFrameTestProxyBase);
-};
-
-// WebTestProxy is used during LayoutTests and always instantiated, at time of
-// writing with Base=RenderFrameImpl. It does not directly inherit from it for
-// layering purposes.
-template <class Base, typename P>
-class WebFrameTestProxy : public Base, public WebFrameTestProxyBase {
- public:
- explicit WebFrameTestProxy(P p) : Base(p) {}
+ explicit WebFrameTestProxy(P p) : Base(p), base_proxy_(NULL) {}
virtual ~WebFrameTestProxy() {}
+
+ void set_base_proxy(WebTestProxyBase* proxy) { base_proxy_ = proxy; }
// WebFrameClient implementation.
blink::WebPlugin* createPlugin(
blink::WebLocalFrame* frame,
const blink::WebPluginParams& params) override {
- blink::WebPlugin* plugin = test_client()->createPlugin(frame, params);
+ blink::WebPlugin* plugin = base_proxy_->CreatePlugin(frame, params);
if (plugin)
return plugin;
return Base::createPlugin(frame, params);
}
blink::WebScreenOrientationClient* webScreenOrientationClient() override {
- return test_client()->webScreenOrientationClient();
+ return base_proxy_->GetScreenOrientationClientMock();
}
void didAddMessageToConsole(const blink::WebConsoleMessage& message,
const blink::WebString& source_name,
unsigned source_line,
const blink::WebString& stack_trace) override {
- test_client()->didAddMessageToConsole(message, source_name, source_line,
- stack_trace);
+ base_proxy_->DidAddMessageToConsole(message, source_name, source_line);
Base::didAddMessageToConsole(
message, source_name, source_line, stack_trace);
}
bool canCreatePluginWithoutRenderer(
const blink::WebString& mime_type) override {
- const char suffix[] = "-can-create-without-renderer";
- return mime_type.utf8().find(suffix) != std::string::npos;
+ using blink::WebString;
+
+ const CR_DEFINE_STATIC_LOCAL(
+ WebString, suffix, ("-can-create-without-renderer"));
+ return mime_type.utf8().find(suffix.utf8()) != std::string::npos;
}
void loadURLExternally(const blink::WebURLRequest& request,
blink::WebNavigationPolicy policy,
const blink::WebString& suggested_name,
bool replaces_current_history_item) override {
- test_client()->loadURLExternally(request, policy, suggested_name,
- replaces_current_history_item);
+ base_proxy_->LoadURLExternally(request, policy, suggested_name,
+ replaces_current_history_item);
Base::loadURLExternally(request, policy, suggested_name,
replaces_current_history_item);
}
void didStartProvisionalLoad(blink::WebLocalFrame* frame,
double triggeringEventTime) override {
- test_client()->didStartProvisionalLoad(frame, triggeringEventTime);
+ base_proxy_->DidStartProvisionalLoad(frame);
Base::didStartProvisionalLoad(
frame, triggeringEventTime);
}
void didReceiveServerRedirectForProvisionalLoad(
blink::WebLocalFrame* frame) override {
- test_client()->didReceiveServerRedirectForProvisionalLoad(frame);
+ base_proxy_->DidReceiveServerRedirectForProvisionalLoad(frame);
Base::didReceiveServerRedirectForProvisionalLoad(frame);
}
@@ -98,10 +85,9 @@
blink::WebLocalFrame* frame,
const blink::WebURLError& error,
blink::WebHistoryCommitType commit_type) override {
- test_client()->didFailProvisionalLoad(frame, error, commit_type);
// If the test finished, don't notify the embedder of the failed load,
// as we already destroyed the document loader.
- if (!frame->provisionalDataSource())
+ if (base_proxy_->DidFailProvisionalLoad(frame, error, commit_type))
return;
Base::didFailProvisionalLoad(frame, error, commit_type);
}
@@ -110,47 +96,47 @@
blink::WebLocalFrame* frame,
const blink::WebHistoryItem& item,
blink::WebHistoryCommitType commit_type) override {
- test_client()->didCommitProvisionalLoad(frame, item, commit_type);
+ base_proxy_->DidCommitProvisionalLoad(frame, item, commit_type);
Base::didCommitProvisionalLoad(frame, item, commit_type);
}
void didReceiveTitle(blink::WebLocalFrame* frame,
const blink::WebString& title,
blink::WebTextDirection direction) override {
- test_client()->didReceiveTitle(frame, title, direction);
+ base_proxy_->DidReceiveTitle(frame, title, direction);
Base::didReceiveTitle(frame, title, direction);
}
void didChangeIcon(blink::WebLocalFrame* frame,
blink::WebIconURL::Type icon_type) override {
- test_client()->didChangeIcon(frame, icon_type);
+ base_proxy_->DidChangeIcon(frame, icon_type);
Base::didChangeIcon(frame, icon_type);
}
void didFinishDocumentLoad(blink::WebLocalFrame* frame) override {
- test_client()->didFinishDocumentLoad(frame);
+ base_proxy_->DidFinishDocumentLoad(frame);
Base::didFinishDocumentLoad(frame);
}
void didHandleOnloadEvents(blink::WebLocalFrame* frame) override {
- test_client()->didHandleOnloadEvents(frame);
+ base_proxy_->DidHandleOnloadEvents(frame);
Base::didHandleOnloadEvents(frame);
}
void didFailLoad(blink::WebLocalFrame* frame,
const blink::WebURLError& error,
blink::WebHistoryCommitType commit_type) override {
- test_client()->didFailLoad(frame, error, commit_type);
+ base_proxy_->DidFailLoad(frame, error, commit_type);
Base::didFailLoad(frame, error, commit_type);
}
void didFinishLoad(blink::WebLocalFrame* frame) override {
Base::didFinishLoad(frame);
- test_client()->didFinishLoad(frame);
+ base_proxy_->DidFinishLoad(frame);
}
void didChangeSelection(bool is_selection_empty) override {
- test_client()->didChangeSelection(is_selection_empty);
+ base_proxy_->DidChangeSelection(is_selection_empty);
Base::didChangeSelection(is_selection_empty);
}
@@ -158,32 +144,31 @@
blink::WebColorChooserClient* client,
const blink::WebColor& initial_color,
const blink::WebVector<blink::WebColorSuggestion>& suggestions) override {
- return test_client()->createColorChooser(client, initial_color,
- suggestions);
+ return base_proxy_->CreateColorChooser(client, initial_color, suggestions);
}
void runModalAlertDialog(const blink::WebString& message) override {
- test_client()->runModalAlertDialog(message);
+ base_proxy_->RunModalAlertDialog(message);
}
bool runModalConfirmDialog(const blink::WebString& message) override {
- return test_client()->runModalConfirmDialog(message);
+ return base_proxy_->RunModalConfirmDialog(message);
}
bool runModalPromptDialog(const blink::WebString& message,
const blink::WebString& default_value,
blink::WebString* actual_value) override {
- return test_client()->runModalPromptDialog(message, default_value,
- actual_value);
+ return base_proxy_->RunModalPromptDialog(message, default_value,
+ actual_value);
}
bool runModalBeforeUnloadDialog(bool is_reload) override {
- return test_client()->runModalBeforeUnloadDialog(is_reload);
+ return base_proxy_->RunModalBeforeUnloadDialog(is_reload);
}
void showContextMenu(
const blink::WebContextMenuData& context_menu_data) override {
- test_client()->showContextMenu(context_menu_data);
+ base_proxy_->ShowContextMenu(context_menu_data);
Base::showContextMenu(context_menu_data);
}
@@ -191,15 +176,20 @@
bool did_block_entire_page) override {
// This is not implemented in RenderFrameImpl, so need to explicitly call
// into the base proxy.
- test_client()->didDetectXSS(insecure_url, did_block_entire_page);
+ base_proxy_->DidDetectXSS(insecure_url, did_block_entire_page);
Base::didDetectXSS(insecure_url, did_block_entire_page);
}
void didDispatchPingLoader(const blink::WebURL& url) override {
// This is not implemented in RenderFrameImpl, so need to explicitly call
// into the base proxy.
- test_client()->didDispatchPingLoader(url);
+ base_proxy_->DidDispatchPingLoader(url);
Base::didDispatchPingLoader(url);
+ }
+
+ void didCreateDataSource(blink::WebLocalFrame* frame,
+ blink::WebDataSource* ds) override {
+ Base::didCreateDataSource(frame, ds);
}
void willSendRequest(
@@ -208,13 +198,12 @@
blink::WebURLRequest& request,
const blink::WebURLResponse& redirect_response) override {
Base::willSendRequest(frame, identifier, request, redirect_response);
- test_client()->willSendRequest(frame, identifier, request,
- redirect_response);
+ base_proxy_->WillSendRequest(frame, identifier, request, redirect_response);
}
void didReceiveResponse(unsigned identifier,
const blink::WebURLResponse& response) override {
- test_client()->didReceiveResponse(identifier, response);
+ base_proxy_->DidReceiveResponse(identifier, response);
Base::didReceiveResponse(identifier, response);
}
@@ -223,21 +212,21 @@
int intra_priority_value) override {
// This is not implemented in RenderFrameImpl, so need to explicitly call
// into the base proxy.
- test_client()->didChangeResourcePriority(identifier, priority,
- intra_priority_value);
+ base_proxy_->DidChangeResourcePriority(
+ identifier, priority, intra_priority_value);
Base::didChangeResourcePriority(
identifier, priority, intra_priority_value);
}
void didFinishResourceLoad(blink::WebLocalFrame* frame,
unsigned identifier) override {
- test_client()->didFinishResourceLoad(frame, identifier);
+ base_proxy_->DidFinishResourceLoad(frame, identifier);
}
blink::WebNavigationPolicy decidePolicyForNavigation(
const blink::WebFrameClient::NavigationPolicyInfo& info) override {
- blink::WebNavigationPolicy policy =
- test_client()->decidePolicyForNavigation(info);
+ blink::WebNavigationPolicy policy = base_proxy_->DecidePolicyForNavigation(
+ info);
if (policy == blink::WebNavigationPolicyIgnore)
return policy;
@@ -251,7 +240,7 @@
}
blink::WebUserMediaClient* userMediaClient() override {
- return test_client()->userMediaClient();
+ return base_proxy_->GetUserMediaClient();
}
bool willCheckAndDispatchMessageEvent(
@@ -259,7 +248,7 @@
blink::WebFrame* target_frame,
blink::WebSecurityOrigin target,
blink::WebDOMMessageEvent event) override {
- if (test_client()->willCheckAndDispatchMessageEvent(
+ if (base_proxy_->WillCheckAndDispatchMessageEvent(
source_frame, target_frame, target, event))
return true;
return Base::willCheckAndDispatchMessageEvent(
@@ -268,7 +257,7 @@
void postAccessibilityEvent(const blink::WebAXObject& object,
blink::WebAXEvent event) override {
- test_client()->postAccessibilityEvent(object, event);
+ base_proxy_->PostAccessibilityEvent(object, event);
Base::postAccessibilityEvent(object, event);
}
@@ -276,11 +265,13 @@
const blink::WebString& sink_id,
const blink::WebSecurityOrigin& security_origin,
blink::WebSetSinkIdCallbacks* web_callbacks) override {
- test_client()->checkIfAudioSinkExistsAndIsAuthorized(
- sink_id, security_origin, web_callbacks);
+ base_proxy_->CheckIfAudioSinkExistsAndIsAuthorized(sink_id, security_origin,
+ web_callbacks);
}
private:
+ WebTestProxyBase* base_proxy_;
+
DISALLOW_COPY_AND_ASSIGN(WebFrameTestProxy);
};
« no previous file with comments | « components/test_runner/web_frame_test_client.cc ('k') | components/test_runner/web_test_interfaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698