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

Unified Diff: components/test_runner/web_test_proxy.cc

Issue 1840823002: Extract WebViewClient implementation out of WebTestProxyBase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@separate-pixel-dump-code
Patch Set: Expanding a comment + an IWYU fix. Created 4 years, 8 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_test_proxy.h ('k') | components/test_runner/web_view_test_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/web_test_proxy.cc
diff --git a/components/test_runner/web_test_proxy.cc b/components/test_runner/web_test_proxy.cc
index 47112285b4026440c8ce26cc48c3f3fa3f1be361..bd5954b7dc8403de4aa242cf0f1a14a199eff52f 100644
--- a/components/test_runner/web_test_proxy.cc
+++ b/components/test_runner/web_test_proxy.cc
@@ -11,18 +11,12 @@
#include "base/callback_helpers.h"
#include "base/command_line.h"
-#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
-#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
-#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
-#include "components/test_runner/event_sender.h"
#include "components/test_runner/mock_credential_manager_client.h"
#include "components/test_runner/mock_screen_orientation_client.h"
-#include "components/test_runner/mock_web_speech_recognizer.h"
#include "components/test_runner/spell_check_client.h"
#include "components/test_runner/test_common.h"
#include "components/test_runner/test_interfaces.h"
@@ -48,7 +42,6 @@
#include "third_party/WebKit/public/web/WebRange.h"
#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
#include "third_party/WebKit/public/web/WebView.h"
-#include "third_party/WebKit/public/web/WebWidgetClient.h"
namespace test_runner {
@@ -72,18 +65,6 @@ class LayoutAndPaintCallback : public blink::WebLayoutAndPaintAsyncCallback {
bool wait_for_popup_;
};
-class HostMethodTask : public WebMethodTask<WebTestProxyBase> {
- public:
- typedef void (WebTestProxyBase::*CallbackMethodType)();
- HostMethodTask(WebTestProxyBase* object, CallbackMethodType callback)
- : WebMethodTask<WebTestProxyBase>(object), callback_(callback) {}
-
- void RunIfValid() override { (object_->*callback_)(); }
-
- private:
- CallbackMethodType callback_;
-};
-
std::string DumpAllBackForwardLists(TestInterfaces* interfaces,
WebTestDelegate* delegate) {
std::string result;
@@ -93,15 +74,15 @@ std::string DumpAllBackForwardLists(TestInterfaces* interfaces,
result.append(delegate->DumpHistoryForWindow(window_list.at(i)));
return result;
}
-}
+
+} // namespace
WebTestProxyBase::WebTestProxyBase()
- : test_interfaces_(NULL),
- delegate_(NULL),
- web_widget_(NULL),
- spellcheck_(new SpellCheckClient(this)) {
- Reset();
-}
+ : test_interfaces_(nullptr),
+ delegate_(nullptr),
+ web_view_(nullptr),
+ web_widget_(nullptr),
+ spellcheck_(new SpellCheckClient(this)) {}
WebTestProxyBase::~WebTestProxyBase() {
test_interfaces_->WindowClosed(this);
@@ -115,63 +96,12 @@ void WebTestProxyBase::SetInterfaces(WebTestInterfaces* interfaces) {
void WebTestProxyBase::SetDelegate(WebTestDelegate* delegate) {
delegate_ = delegate;
spellcheck_->SetDelegate(delegate);
- if (speech_recognizer_.get())
- speech_recognizer_->SetDelegate(delegate);
-}
-
-blink::WebView* WebTestProxyBase::GetWebView() const {
- DCHECK(web_widget_);
- // TestRunner does not support popup widgets. So |web_widget|_ is always a
- // WebView.
- return static_cast<blink::WebView*>(web_widget_);
-}
-
-void WebTestProxyBase::Reset() {
- animate_scheduled_ = false;
}
blink::WebSpellCheckClient* WebTestProxyBase::GetSpellCheckClient() const {
return spellcheck_.get();
}
-bool WebTestProxyBase::RunFileChooser(
- const blink::WebFileChooserParams& params,
- blink::WebFileChooserCompletion* completion) {
- delegate_->PrintMessage("Mock: Opening a file chooser.\n");
- // FIXME: Add ability to set file names to a file upload control.
- return false;
-}
-
-void WebTestProxyBase::ShowValidationMessage(
- const blink::WebString& main_message,
- blink::WebTextDirection main_message_hint,
- const blink::WebString& sub_message,
- blink::WebTextDirection sub_message_hint) {
- base::string16 wrapped_main_text = main_message;
- base::string16 wrapped_sub_text = sub_message;
-
- if (main_message_hint == blink::WebTextDirectionLeftToRight) {
- wrapped_main_text =
- base::i18n::GetDisplayStringInLTRDirectionality(wrapped_main_text);
- } else if (main_message_hint == blink::WebTextDirectionRightToLeft &&
- !base::i18n::IsRTL()) {
- base::i18n::WrapStringWithRTLFormatting(&wrapped_main_text);
- }
-
- if (!wrapped_sub_text.empty()) {
- if (sub_message_hint == blink::WebTextDirectionLeftToRight) {
- wrapped_sub_text =
- base::i18n::GetDisplayStringInLTRDirectionality(wrapped_sub_text);
- } else if (sub_message_hint == blink::WebTextDirectionRightToLeft) {
- base::i18n::WrapStringWithRTLFormatting(&wrapped_sub_text);
- }
- }
- delegate_->PrintMessage("ValidationMessageClient: main-message=" +
- base::UTF16ToUTF8(wrapped_main_text) +
- " sub-message=" +
- base::UTF16ToUTF8(wrapped_sub_text) + "\n");
-}
-
std::string WebTestProxyBase::DumpBackForwardLists() {
return DumpAllBackForwardLists(test_interfaces_, delegate_);
}
@@ -211,14 +141,6 @@ void WebTestProxyBase::GetScreenOrientationForTesting(
screen_info.orientationAngle = mock_client->CurrentOrientationAngle();
}
-MockWebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizerMock() {
- if (!speech_recognizer_.get()) {
- speech_recognizer_.reset(new MockWebSpeechRecognizer());
- speech_recognizer_->SetDelegate(delegate_);
- }
- return speech_recognizer_.get();
-}
-
MockCredentialManagerClient*
WebTestProxyBase::GetCredentialManagerClientMock() {
if (!credential_manager_client_.get())
@@ -226,114 +148,6 @@ WebTestProxyBase::GetCredentialManagerClientMock() {
return credential_manager_client_.get();
}
-void WebTestProxyBase::ScheduleAnimation() {
- if (!test_interfaces_->GetTestRunner()->TestIsRunning())
- return;
-
- if (!animate_scheduled_) {
- animate_scheduled_ = true;
- delegate_->PostDelayedTask(
- new HostMethodTask(this, &WebTestProxyBase::AnimateNow), 1);
- }
-}
-
-void WebTestProxyBase::AnimateNow() {
- if (animate_scheduled_) {
- base::TimeDelta animate_time = base::TimeTicks::Now() - base::TimeTicks();
- animate_scheduled_ = false;
- web_widget_->beginFrame(animate_time.InSecondsF());
- web_widget_->updateAllLifecyclePhases();
- if (blink::WebPagePopup* popup = web_widget_->pagePopup()) {
- popup->beginFrame(animate_time.InSecondsF());
- popup->updateAllLifecyclePhases();
- }
- }
-}
-
-void WebTestProxyBase::StartDragging(blink::WebLocalFrame* frame,
- const blink::WebDragData& data,
- blink::WebDragOperationsMask mask,
- const blink::WebImage& image,
- const blink::WebPoint& point) {
- test_interfaces_->GetTestRunner()->setDragImage(image);
-
- // When running a test, we need to fake a drag drop operation otherwise
- // Windows waits for real mouse events to know when the drag is over.
- test_interfaces_->GetEventSender()->DoDragDrop(data, mask);
-}
-
-// The output from these methods in layout test mode should match that
-// expected by the layout tests. See EditingDelegate.m in DumpRenderTree.
-
-void WebTestProxyBase::DidChangeContents() {
- if (test_interfaces_->GetTestRunner()->shouldDumpEditingCallbacks())
- delegate_->PrintMessage(
- "EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification\n");
-}
-
-bool WebTestProxyBase::CreateView(blink::WebLocalFrame* frame,
- const blink::WebURLRequest& request,
- const blink::WebWindowFeatures& features,
- const blink::WebString& frame_name,
- blink::WebNavigationPolicy policy,
- bool suppress_opener) {
- if (test_interfaces_->GetTestRunner()->shouldDumpNavigationPolicy()) {
- delegate_->PrintMessage("Default policy for createView for '" +
- URLDescription(request.url()) + "' is '" +
- WebNavigationPolicyToString(policy) + "'\n");
- }
-
- if (!test_interfaces_->GetTestRunner()->canOpenWindows())
- return false;
- if (test_interfaces_->GetTestRunner()->shouldDumpCreateView())
- delegate_->PrintMessage(std::string("createView(") +
- URLDescription(request.url()) + ")\n");
- return true;
-}
-
-void WebTestProxyBase::SetStatusText(const blink::WebString& text) {
- if (!test_interfaces_->GetTestRunner()->shouldDumpStatusCallbacks())
- return;
- delegate_->PrintMessage(
- std::string("UI DELEGATE STATUS CALLBACK: setStatusText:") +
- text.utf8().data() + "\n");
-}
-
-// Simulate a print by going into print mode and then exit straight away.
-void WebTestProxyBase::PrintPage(blink::WebLocalFrame* frame) {
- blink::WebSize page_size_in_pixels = web_widget_->size();
- if (page_size_in_pixels.isEmpty())
- return;
- blink::WebPrintParams printParams(page_size_in_pixels);
- frame->printBegin(printParams);
- frame->printEnd();
-}
-
-blink::WebSpeechRecognizer* WebTestProxyBase::GetSpeechRecognizer() {
- return GetSpeechRecognizerMock();
-}
-
-bool WebTestProxyBase::RequestPointerLock() {
- return test_interfaces_->GetTestRunner()->RequestPointerLock();
-}
-
-void WebTestProxyBase::RequestPointerUnlock() {
- test_interfaces_->GetTestRunner()->RequestPointerUnlock();
-}
-
-bool WebTestProxyBase::IsPointerLocked() {
- return test_interfaces_->GetTestRunner()->isPointerLocked();
-}
-
-void WebTestProxyBase::DidFocus() {
- delegate_->SetFocus(this, true);
-}
-
-void WebTestProxyBase::SetToolTipText(const blink::WebString& text,
- blink::WebTextDirection direction) {
- test_interfaces_->GetTestRunner()->setToolTipText(text);
-}
-
void WebTestProxyBase::PostSpellCheckEvent(const blink::WebString& event_name) {
if (test_interfaces_->GetTestRunner()->shouldDumpSpellCheckCallbacks()) {
delegate_->PrintMessage(std::string("SpellCheckEvent: ") +
@@ -341,16 +155,4 @@ void WebTestProxyBase::PostSpellCheckEvent(const blink::WebString& event_name) {
}
}
-void WebTestProxyBase::ResetInputMethod() {
- // If a composition text exists, then we need to let the browser process
- // to cancel the input method's ongoing composition session.
- if (web_widget_)
- web_widget_->confirmComposition();
-}
-
-blink::WebString WebTestProxyBase::acceptLanguages() {
- return blink::WebString::fromUTF8(
- test_interfaces_->GetTestRunner()->GetAcceptLanguages());
-}
-
} // namespace test_runner
« no previous file with comments | « components/test_runner/web_test_proxy.h ('k') | components/test_runner/web_view_test_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698