Index: content/shell/renderer/layout_test/blink_test_runner.cc |
diff --git a/content/shell/renderer/layout_test/blink_test_runner.cc b/content/shell/renderer/layout_test/blink_test_runner.cc |
index 13f30a302d973daf4c7a7e3b3b05c304fc53bff9..17c94f0ee9c2cce31e16965a306abefa53552f48 100644 |
--- a/content/shell/renderer/layout_test/blink_test_runner.cc |
+++ b/content/shell/renderer/layout_test/blink_test_runner.cc |
@@ -19,6 +19,7 @@ |
#include "base/macros.h" |
#include "base/md5.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/memory/shared_memory.h" |
#include "base/single_thread_task_runner.h" |
#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
@@ -612,15 +613,19 @@ void BlinkTestRunner::SetLocale(const std::string& locale) { |
void BlinkTestRunner::TestFinished() { |
if (!is_main_window_ || !render_view()->GetMainRenderFrame()) { |
+ VLOG(1) << "Test finished in secondary window."; |
Send(new ShellViewHostMsg_TestFinishedInSecondaryRenderer(routing_id())); |
return; |
} |
+ VLOG(1) << "Test finished."; |
+ |
test_runner::WebTestInterfaces* interfaces = |
LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
interfaces->SetTestIsRunning(false); |
if (interfaces->TestRunner()->ShouldDumpBackForwardList()) { |
SyncNavigationStateVisitor visitor; |
RenderView::ForEach(&visitor); |
+ VLOG(2) << "Capturing session history dump."; |
Send(new ShellViewHostMsg_CaptureSessionHistory(routing_id())); |
} else { |
CaptureDump(); |
@@ -708,7 +713,8 @@ void BlinkTestRunner::SetPermission(const std::string& name, |
} |
void BlinkTestRunner::ResetPermissions() { |
- Send(new LayoutTestHostMsg_ResetPermissions(routing_id())); |
+ if (is_main_window_) |
+ Send(new LayoutTestHostMsg_ResetPermissions(routing_id())); |
} |
cc::SharedBitmapManager* BlinkTestRunner::GetSharedBitmapManager() { |
@@ -820,6 +826,13 @@ void BlinkTestRunner::Navigate(const GURL& url) { |
test_runner::WebTestInterfaces* interfaces = |
LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
interfaces->SetTestIsRunning(true); |
+ |
+ // Use static / non-shared layout dump flags in secondary windows. |
+ static test_runner::LayoutDumpFlags static_layout_dump_flags; |
+ interfaces->TestRunner()->SetSharedLayoutDumpFlags( |
+ &static_layout_dump_flags); |
+ |
+ interfaces->TestRunner()->Reset(); |
interfaces->ConfigureForTestWithURL(GURL(), false); |
ForceResizeRenderView(render_view(), WebSize(800, 600)); |
} |
@@ -875,6 +888,7 @@ void BlinkTestRunner::CaptureDump() { |
if (interfaces->TestRunner()->ShouldDumpAsAudio()) { |
std::vector<unsigned char> vector_data; |
interfaces->TestRunner()->GetAudioData(&vector_data); |
+ VLOG(2) << "Sending audio dump."; |
Send(new ShellViewHostMsg_AudioDump(routing_id(), vector_data)); |
CaptureDumpContinued(); |
return; |
@@ -882,6 +896,7 @@ void BlinkTestRunner::CaptureDump() { |
std::string custom_text_dump; |
if (interfaces->TestRunner()->HasCustomTextDump(&custom_text_dump)) { |
+ VLOG(2) << "Sending custom text dump."; |
Send(new ShellViewHostMsg_TextDump(routing_id(), custom_text_dump + "\n")); |
CaptureDumpContinued(); |
return; |
@@ -896,8 +911,8 @@ void BlinkTestRunner::CaptureDump() { |
return; |
} |
- Send( |
- new ShellViewHostMsg_InitiateLayoutDump(routing_id(), layout_dump_flags)); |
+ Send(new ShellViewHostMsg_InitiateLayoutDump( |
+ routing_id(), layout_dump_flags.dump_child_frames())); |
// OnLayoutDumpCompleted will be eventually called by an IPC from the browser. |
} |
@@ -908,6 +923,7 @@ void BlinkTestRunner::OnLayoutDumpCompleted(std::string completed_layout_dump) { |
completed_layout_dump.append(proxy()->DumpBackForwardLists()); |
} |
+ VLOG(2) << "Sending layout dump."; |
Send(new ShellViewHostMsg_TextDump(routing_id(), completed_layout_dump)); |
CaptureDumpContinued(); |
@@ -948,6 +964,7 @@ void BlinkTestRunner::OnPixelsDumpCompleted(const SkBitmap& snapshot) { |
base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest); |
std::string actual_pixel_hash = base::MD5DigestToBase16(digest); |
+ VLOG(2) << "Sending pixel dump."; |
if (actual_pixel_hash == test_config_.expected_pixel_hash) { |
SkBitmap empty_image; |
Send(new ShellViewHostMsg_ImageDump( |
@@ -963,6 +980,8 @@ void BlinkTestRunner::OnPixelsDumpCompleted(const SkBitmap& snapshot) { |
void BlinkTestRunner::CaptureDumpComplete() { |
render_view()->GetWebView()->mainFrame()->stopLoading(); |
+ VLOG(1) << "Dump completed."; |
+ |
base::ThreadTaskRunnerHandle::Get()->PostTask( |
FROM_HERE, base::Bind(base::IgnoreResult(&BlinkTestRunner::Send), |
base::Unretained(this), |
@@ -971,20 +990,40 @@ void BlinkTestRunner::CaptureDumpComplete() { |
void BlinkTestRunner::OnReplicateTestConfiguration( |
const ShellTestConfiguration& params) { |
+ VLOG(2) << "Replicating test configuration."; |
+ |
test_config_ = params; |
is_main_window_ = true; |
+ layout_dump_flags_memory_.reset( |
+ new base::SharedMemory(test_config_.layout_dump_flags_memory_handle, |
+ false /* expecting read-write memory */)); |
+ if (!layout_dump_flags_memory_->Map(sizeof(test_runner::LayoutDumpFlags))) { |
+ // TODO(lukasza): DO NOT SUBMIT: Report the error somehow? |
+ CHECK(false); |
+ } |
+ DCHECK(layout_dump_flags_memory_->memory()); |
+ |
test_runner::WebTestInterfaces* interfaces = |
LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
+ interfaces->TestRunner()->SetSharedLayoutDumpFlags( |
+ static_cast<test_runner::LayoutDumpFlags*>( |
+ layout_dump_flags_memory_->memory())); |
interfaces->SetTestIsRunning(true); |
- interfaces->ConfigureForTestWithURL(params.test_url, |
- params.enable_pixel_dumping); |
} |
void BlinkTestRunner::OnSetTestConfiguration( |
const ShellTestConfiguration& params) { |
+ VLOG(1) << "Setting initial test configuration."; |
+ |
OnReplicateTestConfiguration(params); |
+ test_runner::WebTestInterfaces* interfaces = |
+ LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
+ interfaces->TestRunner()->Reset(); |
+ interfaces->ConfigureForTestWithURL(params.test_url, |
+ params.enable_pixel_dumping); |
+ |
ForceResizeRenderView( |
render_view(), |
WebSize(params.initial_size.width(), params.initial_size.height())); |
@@ -1002,7 +1041,11 @@ void BlinkTestRunner::OnSessionHistory( |
} |
void BlinkTestRunner::OnReset() { |
- LayoutTestRenderProcessObserver::GetInstance()->test_interfaces()->ResetAll(); |
+ test_runner::WebTestInterfaces* interfaces = |
+ LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
+ interfaces->ResetAll(); |
+ interfaces->TestRunner()->Reset(); |
+ |
Reset(true /* for_new_test */); |
// Navigating to about:blank will make sure that no new loads are initiated |
// by the renderer. |