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

Side by Side Diff: content/shell/test_runner/test_runner.cc

Issue 2963593002: Split DumpPixelsAsync in pixel_dump.h into more granular functions. (Closed)
Patch Set: . Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/test_runner/test_runner.h" 5 #include "content/shell/test_runner/test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 CheckResponseMimeType(); 1761 CheckResponseMimeType();
1762 return layout_test_runtime_flags_.dump_child_frames(); 1762 return layout_test_runtime_flags_.dump_child_frames();
1763 } 1763 }
1764 1764
1765 std::string TestRunner::DumpLayout(blink::WebLocalFrame* frame) { 1765 std::string TestRunner::DumpLayout(blink::WebLocalFrame* frame) {
1766 CheckResponseMimeType(); 1766 CheckResponseMimeType();
1767 return ::test_runner::DumpLayout(frame, layout_test_runtime_flags_); 1767 return ::test_runner::DumpLayout(frame, layout_test_runtime_flags_);
1768 } 1768 }
1769 1769
1770 void TestRunner::DumpPixelsAsync( 1770 void TestRunner::DumpPixelsAsync(
1771 blink::WebView* web_view, 1771 blink::WebLocalFrame* frame,
1772 const base::Callback<void(const SkBitmap&)>& callback) { 1772 base::OnceCallback<void(const SkBitmap&)> callback) {
1773 if (layout_test_runtime_flags_.dump_drag_image()) { 1773 if (layout_test_runtime_flags_.dump_drag_image()) {
1774 if (drag_image_.IsNull()) { 1774 if (drag_image_.IsNull()) {
1775 // This means the test called dumpDragImage but did not initiate a drag. 1775 // This means the test called dumpDragImage but did not initiate a drag.
1776 // Return a blank image so that the test fails. 1776 // Return a blank image so that the test fails.
1777 SkBitmap bitmap; 1777 SkBitmap bitmap;
1778 bitmap.allocN32Pixels(1, 1); 1778 bitmap.allocN32Pixels(1, 1);
1779 bitmap.eraseColor(0); 1779 bitmap.eraseColor(0);
1780 callback.Run(bitmap); 1780 std::move(callback).Run(bitmap);
1781 return; 1781 return;
1782 } 1782 }
1783 1783
1784 callback.Run(drag_image_.GetSkBitmap()); 1784 std::move(callback).Run(drag_image_.GetSkBitmap());
1785 return; 1785 return;
1786 } 1786 }
1787 1787
1788 test_runner::DumpPixelsAsync(web_view, layout_test_runtime_flags_, 1788 // See if we need to draw the selection bounds rect on top of the snapshot.
1789 delegate_->GetDeviceScaleFactor(), callback); 1789 if (layout_test_runtime_flags_.dump_selection_rect()) {
alexmos 2017/07/11 15:01:07 nit: { not needed
Łukasz Anforowicz 2017/07/11 16:30:24 After renaming the function to CreateSelectionBoun
alexmos 2017/07/11 16:48:10 Acknowledged.
1790 callback = CreateSelectionDrawingCallback(frame, std::move(callback));
1791 }
1792
1793 // Request appropriate kind of pixel dump.
1794 if (layout_test_runtime_flags_.is_printing()) {
1795 test_runner::PrintFrameAsync(frame, std::move(callback));
1796 } else {
1797 // TODO(lukasza): Ask the |delegate_| to capture the pixels in the browser
1798 // process, so that OOPIF pixels are also captured.
1799 test_runner::DumpPixelsAsync(frame, delegate_->GetDeviceScaleFactor(),
1800 std::move(callback));
1801 }
1790 } 1802 }
1791 1803
1792 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges( 1804 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges(
1793 const base::DictionaryValue& changed_values) { 1805 const base::DictionaryValue& changed_values) {
1794 if (test_is_running_) { 1806 if (test_is_running_) {
1795 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges( 1807 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges(
1796 changed_values); 1808 changed_values);
1797 1809
1798 bool allowed = layout_test_runtime_flags_.plugins_allowed(); 1810 bool allowed = layout_test_runtime_flags_.plugins_allowed();
1799 for (WebViewTestProxyBase* window : test_interfaces_->GetWindowList()) 1811 for (WebViewTestProxyBase* window : test_interfaces_->GetWindowList())
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 2847
2836 void TestRunner::NotifyDone() { 2848 void TestRunner::NotifyDone() {
2837 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && 2849 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() &&
2838 !will_navigate_ && work_queue_.is_empty()) 2850 !will_navigate_ && work_queue_.is_empty())
2839 delegate_->TestFinished(); 2851 delegate_->TestFinished();
2840 layout_test_runtime_flags_.set_wait_until_done(false); 2852 layout_test_runtime_flags_.set_wait_until_done(false);
2841 OnLayoutTestRuntimeFlagsChanged(); 2853 OnLayoutTestRuntimeFlagsChanged();
2842 } 2854 }
2843 2855
2844 } // namespace test_runner 2856 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698