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

Unified Diff: content/shell/browser/blink_test_controller.cc

Issue 1589643003: OOPIF support for testRunner.dumpAsText and similar layout dumps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 4 years, 11 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 | « content/shell/browser/blink_test_controller.h ('k') | content/shell/common/shell_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/browser/blink_test_controller.cc
diff --git a/content/shell/browser/blink_test_controller.cc b/content/shell/browser/blink_test_controller.cc
index 623a6677e64e862ee15d86d44ad20b58e96cc2ee..61b3ac1bdbf3c585b6bc00d22590d55341ac1894 100644
--- a/content/shell/browser/blink_test_controller.cc
+++ b/content/shell/browser/blink_test_controller.cc
@@ -7,11 +7,13 @@
#include <stddef.h>
#include <iostream>
+#include <utility>
#include "base/base64.h"
#include "base/callback.h"
#include "base/command_line.h"
#include "base/location.h"
+#include "base/logging.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
@@ -25,6 +27,7 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
@@ -47,9 +50,27 @@
namespace content {
+namespace {
+
const int kTestSVGWindowWidthDip = 480;
const int kTestSVGWindowHeightDip = 360;
+void AppendLayoutDumpForFrame(
+ const std::map<int, std::string>& frame_to_layout_dump_map,
+ std::string* stitched_layout_dump,
+ RenderFrameHost* target) {
+ auto it = frame_to_layout_dump_map.find(target->GetFrameTreeNodeId());
+
+ // No match will happen if frames have been added since OnInitiateLayoutDump.
+ if (it == frame_to_layout_dump_map.end())
+ return;
+
+ const std::string& dump = it->second;
+ stitched_layout_dump->append(dump);
+}
+
+} // namespace
+
// BlinkTestResultPrinter ----------------------------------------------------
BlinkTestResultPrinter::BlinkTestResultPrinter(std::ostream* output,
@@ -257,6 +278,7 @@ bool BlinkTestController::PrepareForLayoutTest(
expected_pixel_hash_ = expected_pixel_hash;
test_url_ = test_url;
printer_->reset();
+ frame_to_layout_dump_map_.clear();
ShellBrowserContext* browser_context =
ShellContentBrowserClient::Get()->browser_context();
if (test_url.spec().find("compositing/") != std::string::npos)
@@ -392,6 +414,8 @@ bool BlinkTestController::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_InitiateLayoutDump,
+ OnInitiateLayoutDump)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump)
IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences,
@@ -422,6 +446,19 @@ bool BlinkTestController::OnMessageReceived(const IPC::Message& message) {
return handled;
}
+bool BlinkTestController::OnMessageReceived(
+ const IPC::Message& message,
+ RenderFrameHost* render_frame_host) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(BlinkTestController, message,
+ render_frame_host)
+ IPC_MESSAGE_HANDLER(ShellViewHostMsg_LayoutDumpResponse,
+ OnLayoutDumpResponse)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path,
base::ProcessId plugin_pid) {
DCHECK(CalledOnValidThread());
@@ -597,6 +634,42 @@ void BlinkTestController::OnTextDump(const std::string& dump) {
printer_->PrintTextFooter();
}
+void BlinkTestController::OnInitiateLayoutDump(
+ test_runner::LayoutDumpFlags layout_dump_flags) {
+ DCHECK(layout_dump_flags.dump_child_frames);
+ pending_layout_dumps_ = main_window_->web_contents()->SendToAllFrames(
+ new ShellViewMsg_LayoutDumpRequest(MSG_ROUTING_NONE, layout_dump_flags));
+}
+
+void BlinkTestController::OnLayoutDumpResponse(RenderFrameHost* sender,
+ const std::string& dump) {
+ // Store the result.
+ auto pair = frame_to_layout_dump_map_.insert(
+ std::make_pair(sender->GetFrameTreeNodeId(), dump));
+ bool insertion_took_place = pair.second;
+ DCHECK(insertion_took_place);
+
+ // See if we need to wait for more responses.
+ pending_layout_dumps_--;
+ DCHECK_LE(0, pending_layout_dumps_);
+ if (pending_layout_dumps_ > 0)
+ return;
+
+ // Stitch the frame-specific results in the right order.
+ // TODO(lukasza): Replace with a for loop similar to crrev.com/1612503003.
+ std::string stitched_layout_dump;
+ main_window_->web_contents()->ForEachFrame(base::Bind(
+ &AppendLayoutDumpForFrame,
+ base::ConstRef(frame_to_layout_dump_map_),
+ &stitched_layout_dump));
+
+ // Continue finishing the test.
+ RenderViewHost* render_view_host =
+ main_window_->web_contents()->GetRenderViewHost();
+ render_view_host->Send(new ShellViewMsg_LayoutDumpCompleted(
+ render_view_host->GetRoutingID(), stitched_layout_dump));
+}
+
void BlinkTestController::OnPrintMessage(const std::string& message) {
printer_->AddMessageRaw(message);
}
« no previous file with comments | « content/shell/browser/blink_test_controller.h ('k') | content/shell/common/shell_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698