Commit ef264fc5 authored by lukasza's avatar lukasza Committed by Commit bot

Make test_runner::LayoutDumpFlags an internal detail of components/test_runner.

To simplify public API surface of components/test_runner we can hide
LayoutDumpFlags behind WebTestRunner interface.  For example - instead
of returning the whole LayoutDumpFlags struct, we can only expose
IsRecursiveLayoutDumpRequested method - this is consistent with how
other similar methods are exposed via WebTestRunner (i.e. we already
have ShouldDumpAsAudio and/or ShouldGeneratePixelResults).

After doing this components/test_runner/layout_dump_flags.h and
components/test_runner/layout_dump.h headers no longer needs to be
included outside of components/test_runner.

BUG=595089

Review URL: https://codereview.chromium.org/1805243002

Cr-Commit-Position: refs/heads/master@{#381819}
parent 3be0014f
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/test_runner/app_banner_client.h" #include "components/test_runner/app_banner_client.h"
#include "components/test_runner/layout_dump.h"
#include "components/test_runner/mock_credential_manager_client.h" #include "components/test_runner/mock_credential_manager_client.h"
#include "components/test_runner/mock_screen_orientation_client.h" #include "components/test_runner/mock_screen_orientation_client.h"
#include "components/test_runner/mock_web_speech_recognizer.h" #include "components/test_runner/mock_web_speech_recognizer.h"
...@@ -1836,9 +1837,14 @@ void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const { ...@@ -1836,9 +1837,14 @@ void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const {
*buffer_view = audio_data_; *buffer_view = audio_data_;
} }
const LayoutDumpFlags& TestRunner::GetLayoutDumpFlags() { bool TestRunner::IsRecursiveLayoutDumpRequested() {
CheckResponseMimeType(); CheckResponseMimeType();
return layout_dump_flags_; return layout_dump_flags_.dump_child_frames();
}
std::string TestRunner::DumpLayout(blink::WebLocalFrame* frame) {
CheckResponseMimeType();
return ::test_runner::DumpLayout(frame, layout_dump_flags_);
} }
void TestRunner::ReplicateLayoutDumpFlagsChanges( void TestRunner::ReplicateLayoutDumpFlagsChanges(
......
...@@ -73,7 +73,8 @@ class TestRunner : public WebTestRunner, ...@@ -73,7 +73,8 @@ class TestRunner : public WebTestRunner,
bool ShouldGeneratePixelResults() override; bool ShouldGeneratePixelResults() override;
bool ShouldDumpAsAudio() const override; bool ShouldDumpAsAudio() const override;
void GetAudioData(std::vector<unsigned char>* buffer_view) const override; void GetAudioData(std::vector<unsigned char>* buffer_view) const override;
const LayoutDumpFlags& GetLayoutDumpFlags() override; bool IsRecursiveLayoutDumpRequested() override;
std::string DumpLayout(blink::WebLocalFrame* frame) override;
void ReplicateLayoutDumpFlagsChanges( void ReplicateLayoutDumpFlagsChanges(
const base::DictionaryValue& changed_values) override; const base::DictionaryValue& changed_values) override;
bool HasCustomTextDump(std::string* custom_text_dump) const override; bool HasCustomTextDump(std::string* custom_text_dump) const override;
......
...@@ -14,12 +14,11 @@ class DictionaryValue; ...@@ -14,12 +14,11 @@ class DictionaryValue;
namespace blink { namespace blink {
class WebContentSettingsClient; class WebContentSettingsClient;
class WebLocalFrame;
} }
namespace test_runner { namespace test_runner {
class LayoutDumpFlags;
class WebTestRunner { class WebTestRunner {
public: public:
// Returns a mock WebContentSettings that is used for layout tests. An // Returns a mock WebContentSettings that is used for layout tests. An
...@@ -35,11 +34,16 @@ class WebTestRunner { ...@@ -35,11 +34,16 @@ class WebTestRunner {
virtual bool ShouldDumpAsAudio() const = 0; virtual bool ShouldDumpAsAudio() const = 0;
virtual void GetAudioData(std::vector<unsigned char>* buffer_view) const = 0; virtual void GetAudioData(std::vector<unsigned char>* buffer_view) const = 0;
// Gets layout dump flags (i.e. dump-as-text or dump-as-markup) requested // Reports if tests requested a recursive layout dump of all frames
// by the test (i.e. via testRunner.dumpAsText() called from javascript). // (i.e. by calling testRunner.dumpChildFramesAsText() from javascript).
virtual const LayoutDumpFlags& GetLayoutDumpFlags() = 0; virtual bool IsRecursiveLayoutDumpRequested() = 0;
// Dumps layout of |frame| using the mode requested by the current test
// (i.e. text mode if testRunner.dumpAsText() was called from javascript).
virtual std::string DumpLayout(blink::WebLocalFrame* frame) = 0;
// Replicates changes to layout dump flags. // Replicates changes to layout dump flags (i.e. changes that happened in
// another renderer). See also WebTestDelegate::OnLayoutDumpFlagsChanged.
virtual void ReplicateLayoutDumpFlagsChanges( virtual void ReplicateLayoutDumpFlagsChanges(
const base::DictionaryValue& changed_values) = 0; const base::DictionaryValue& changed_values) = 0;
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/plugins/renderer/plugin_placeholder.h" #include "components/plugins/renderer/plugin_placeholder.h"
#include "components/test_runner/gamepad_controller.h" #include "components/test_runner/gamepad_controller.h"
#include "components/test_runner/layout_dump.h"
#include "components/test_runner/layout_dump_flags.h"
#include "components/test_runner/test_interfaces.h" #include "components/test_runner/test_interfaces.h"
#include "components/test_runner/web_task.h" #include "components/test_runner/web_task.h"
#include "components/test_runner/web_test_interfaces.h" #include "components/test_runner/web_test_interfaces.h"
...@@ -885,11 +883,9 @@ void BlinkTestRunner::CaptureDump() { ...@@ -885,11 +883,9 @@ void BlinkTestRunner::CaptureDump() {
return; return;
} }
const test_runner::LayoutDumpFlags& layout_dump_flags = if (!interfaces->TestRunner()->IsRecursiveLayoutDumpRequested()) {
interfaces->TestRunner()->GetLayoutDumpFlags(); std::string layout_dump = interfaces->TestRunner()->DumpLayout(
if (!layout_dump_flags.dump_child_frames()) { render_view()->GetMainRenderFrame()->GetWebFrame());
std::string layout_dump = DumpLayout(
render_view()->GetMainRenderFrame()->GetWebFrame(), layout_dump_flags);
OnLayoutDumpCompleted(layout_dump); OnLayoutDumpCompleted(layout_dump);
return; return;
} }
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include <string> #include <string>
#include "components/test_runner/layout_dump.h"
#include "components/test_runner/layout_dump_flags.h"
#include "components/test_runner/web_test_interfaces.h" #include "components/test_runner/web_test_interfaces.h"
#include "components/test_runner/web_test_runner.h" #include "components/test_runner/web_test_runner.h"
#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame.h"
...@@ -47,13 +45,11 @@ bool LayoutTestRenderFrameObserver::OnMessageReceived( ...@@ -47,13 +45,11 @@ bool LayoutTestRenderFrameObserver::OnMessageReceived(
} }
void LayoutTestRenderFrameObserver::OnLayoutDumpRequest() { void LayoutTestRenderFrameObserver::OnLayoutDumpRequest() {
const test_runner::LayoutDumpFlags& layout_dump_flags = std::string dump =
LayoutTestRenderProcessObserver::GetInstance() LayoutTestRenderProcessObserver::GetInstance()
->test_interfaces() ->test_interfaces()
->TestRunner() ->TestRunner()
->GetLayoutDumpFlags(); ->DumpLayout(render_frame()->GetWebFrame());
std::string dump =
test_runner::DumpLayout(render_frame()->GetWebFrame(), layout_dump_flags);
Send(new ShellViewHostMsg_LayoutDumpResponse(routing_id(), dump)); Send(new ShellViewHostMsg_LayoutDumpResponse(routing_id(), dump));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment