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

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: Addressed CR feedback from alexmos@. 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()) {
1790 callback =
1791 CreateSelectionBoundsRectDrawingCallback(frame, std::move(callback));
1792 }
1793
1794 // Request appropriate kind of pixel dump.
1795 if (layout_test_runtime_flags_.is_printing()) {
1796 test_runner::PrintFrameAsync(frame, std::move(callback));
1797 } else {
1798 // TODO(lukasza): Ask the |delegate_| to capture the pixels in the browser
1799 // process, so that OOPIF pixels are also captured.
1800 test_runner::DumpPixelsAsync(frame, delegate_->GetDeviceScaleFactor(),
1801 std::move(callback));
1802 }
1790 } 1803 }
1791 1804
1792 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges( 1805 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges(
1793 const base::DictionaryValue& changed_values) { 1806 const base::DictionaryValue& changed_values) {
1794 if (test_is_running_) { 1807 if (test_is_running_) {
1795 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges( 1808 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges(
1796 changed_values); 1809 changed_values);
1797 1810
1798 bool allowed = layout_test_runtime_flags_.plugins_allowed(); 1811 bool allowed = layout_test_runtime_flags_.plugins_allowed();
1799 for (WebViewTestProxyBase* window : test_interfaces_->GetWindowList()) 1812 for (WebViewTestProxyBase* window : test_interfaces_->GetWindowList())
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 2848
2836 void TestRunner::NotifyDone() { 2849 void TestRunner::NotifyDone() {
2837 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && 2850 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() &&
2838 !will_navigate_ && work_queue_.is_empty()) 2851 !will_navigate_ && work_queue_.is_empty())
2839 delegate_->TestFinished(); 2852 delegate_->TestFinished();
2840 layout_test_runtime_flags_.set_wait_until_done(false); 2853 layout_test_runtime_flags_.set_wait_until_done(false);
2841 OnLayoutTestRuntimeFlagsChanged(); 2854 OnLayoutTestRuntimeFlagsChanged();
2842 } 2855 }
2843 2856
2844 } // namespace test_runner 2857 } // namespace test_runner
OLDNEW
« no previous file with comments | « content/shell/test_runner/test_runner.h ('k') | content/shell/test_runner/test_runner_for_specific_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698