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

Side by Side Diff: components/test_runner/test_runner.cc

Issue 1689283003: Remove duplication between TestRunner's fields and LayoutDumpFlags struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Despite LayoutDumpFlags constructor, we still need to set the flags in TestRunner::Reset. Created 4 years, 9 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
« no previous file with comments | « components/test_runner/test_runner.h ('k') | components/test_runner/web_test_runner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/test_runner/test_runner.h" 5 #include "components/test_runner/test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 object_->ProcessWork(); 1668 object_->ProcessWork();
1669 } 1669 }
1670 1670
1671 TestRunner::TestRunner(TestInterfaces* interfaces) 1671 TestRunner::TestRunner(TestInterfaces* interfaces)
1672 : test_is_running_(false), 1672 : test_is_running_(false),
1673 close_remaining_windows_(false), 1673 close_remaining_windows_(false),
1674 work_queue_(this), 1674 work_queue_(this),
1675 disable_notify_done_(false), 1675 disable_notify_done_(false),
1676 web_history_item_count_(0), 1676 web_history_item_count_(0),
1677 intercept_post_message_(false), 1677 intercept_post_message_(false),
1678 layout_dump_flags_(
1679 false, // dump_as_text
1680 false, // dump_child_frames_as_text
1681 false, // dump_as_markup
1682 false, // dump_child_frames_as_markup
1683 false, // dump_child_frame_scroll_positions
1684 false, // is_printing
1685 false, // dump_line_box_trees
1686 false), // debug_render_tree
1678 test_interfaces_(interfaces), 1687 test_interfaces_(interfaces),
1679 delegate_(nullptr), 1688 delegate_(nullptr),
1680 web_view_(nullptr), 1689 web_view_(nullptr),
1681 web_content_settings_(new WebContentSettings()), 1690 web_content_settings_(new WebContentSettings()),
1682 weak_factory_(this) {} 1691 weak_factory_(this) {}
1683 1692
1684 TestRunner::~TestRunner() {} 1693 TestRunner::~TestRunner() {}
1685 1694
1686 void TestRunner::Install(WebFrame* frame) { 1695 void TestRunner::Install(WebFrame* frame) {
1687 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame); 1696 TestRunnerBindings::Install(weak_factory_.GetWeakPtr(), frame);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 delegate_->DeleteAllCookies(); 1747 delegate_->DeleteAllCookies();
1739 delegate_->ResetScreenOrientation(); 1748 delegate_->ResetScreenOrientation();
1740 delegate_->SetBluetoothMockDataSet(""); 1749 delegate_->SetBluetoothMockDataSet("");
1741 delegate_->ClearGeofencingMockProvider(); 1750 delegate_->ClearGeofencingMockProvider();
1742 delegate_->ResetPermissions(); 1751 delegate_->ResetPermissions();
1743 ResetBatteryStatus(); 1752 ResetBatteryStatus();
1744 ResetDeviceLight(); 1753 ResetDeviceLight();
1745 } 1754 }
1746 1755
1747 dump_editting_callbacks_ = false; 1756 dump_editting_callbacks_ = false;
1748 dump_as_text_ = false; 1757 layout_dump_flags_.dump_as_text = false;
1749 dump_as_markup_ = false; 1758 layout_dump_flags_.dump_as_markup = false;
1750 generate_pixel_results_ = true; 1759 generate_pixel_results_ = true;
1751 dump_child_frame_scroll_positions_ = false; 1760 layout_dump_flags_.dump_child_frame_scroll_positions = false;
1752 dump_child_frames_as_markup_ = false; 1761 layout_dump_flags_.dump_child_frames_as_text = false;
1753 dump_child_frames_as_text_ = false; 1762 layout_dump_flags_.dump_child_frames_as_markup = false;
1754 dump_icon_changes_ = false; 1763 dump_icon_changes_ = false;
1755 dump_as_audio_ = false; 1764 dump_as_audio_ = false;
1756 dump_frame_load_callbacks_ = false; 1765 dump_frame_load_callbacks_ = false;
1757 dump_ping_loader_callbacks_ = false; 1766 dump_ping_loader_callbacks_ = false;
1758 dump_user_gesture_in_frame_load_callbacks_ = false; 1767 dump_user_gesture_in_frame_load_callbacks_ = false;
1759 dump_title_changes_ = false; 1768 dump_title_changes_ = false;
1760 dump_create_view_ = false; 1769 dump_create_view_ = false;
1761 can_open_windows_ = false; 1770 can_open_windows_ = false;
1762 dump_resource_load_callbacks_ = false; 1771 dump_resource_load_callbacks_ = false;
1763 dump_resource_request_callbacks_ = false; 1772 dump_resource_request_callbacks_ = false;
1764 dump_resource_response_mime_types_ = false; 1773 dump_resource_response_mime_types_ = false;
1765 dump_window_status_changes_ = false; 1774 dump_window_status_changes_ = false;
1766 dump_spell_check_callbacks_ = false; 1775 dump_spell_check_callbacks_ = false;
1767 dump_back_forward_list_ = false; 1776 dump_back_forward_list_ = false;
1768 dump_selection_rect_ = false; 1777 dump_selection_rect_ = false;
1769 dump_drag_image_ = false; 1778 dump_drag_image_ = false;
1770 dump_navigation_policy_ = false; 1779 dump_navigation_policy_ = false;
1771 test_repaint_ = false; 1780 test_repaint_ = false;
1772 sweep_horizontally_ = false; 1781 sweep_horizontally_ = false;
1773 is_printing_ = false; 1782 layout_dump_flags_.is_printing = false;
1774 midi_accessor_result_ = true; 1783 midi_accessor_result_ = true;
1775 should_stay_on_page_after_handling_before_unload_ = false; 1784 should_stay_on_page_after_handling_before_unload_ = false;
1776 should_dump_resource_priorities_ = false; 1785 should_dump_resource_priorities_ = false;
1777 has_custom_text_output_ = false; 1786 has_custom_text_output_ = false;
1778 custom_text_output_.clear(); 1787 custom_text_output_.clear();
1779 1788
1780 http_headers_to_clear_.clear(); 1789 http_headers_to_clear_.clear();
1781 1790
1782 platform_name_ = "chromium"; 1791 platform_name_ = "chromium";
1783 tooltip_text_ = std::string(); 1792 tooltip_text_ = std::string();
(...skipping 22 matching lines...) Expand all
1806 } 1815 }
1807 1816
1808 void TestRunner::InvokeCallback(scoped_ptr<InvokeCallbackTask> task) { 1817 void TestRunner::InvokeCallback(scoped_ptr<InvokeCallbackTask> task) {
1809 delegate_->PostTask(task.release()); 1818 delegate_->PostTask(task.release());
1810 } 1819 }
1811 1820
1812 bool TestRunner::shouldDumpEditingCallbacks() const { 1821 bool TestRunner::shouldDumpEditingCallbacks() const {
1813 return dump_editting_callbacks_; 1822 return dump_editting_callbacks_;
1814 } 1823 }
1815 1824
1816 bool TestRunner::shouldDumpAsText() {
1817 CheckResponseMimeType();
1818 return dump_as_text_;
1819 }
1820
1821 void TestRunner::setShouldDumpAsText(bool value) { 1825 void TestRunner::setShouldDumpAsText(bool value) {
1822 dump_as_text_ = value; 1826 layout_dump_flags_.dump_as_text = value;
1823 }
1824
1825 bool TestRunner::shouldDumpAsMarkup() {
1826 return dump_as_markup_;
1827 } 1827 }
1828 1828
1829 void TestRunner::setShouldDumpAsMarkup(bool value) { 1829 void TestRunner::setShouldDumpAsMarkup(bool value) {
1830 dump_as_markup_ = value; 1830 layout_dump_flags_.dump_as_markup = value;
1831 } 1831 }
1832 1832
1833 bool TestRunner::shouldDumpAsCustomText() const { 1833 bool TestRunner::shouldDumpAsCustomText() const {
1834 return has_custom_text_output_; 1834 return has_custom_text_output_;
1835 } 1835 }
1836 1836
1837 std::string TestRunner::customDumpText() const { 1837 std::string TestRunner::customDumpText() const {
1838 return custom_text_output_; 1838 return custom_text_output_;
1839 } 1839 }
1840 1840
1841 void TestRunner::setCustomTextOutput(const std::string& text) { 1841 void TestRunner::setCustomTextOutput(const std::string& text) {
1842 custom_text_output_ = text; 1842 custom_text_output_ = text;
1843 has_custom_text_output_ = true; 1843 has_custom_text_output_ = true;
1844 } 1844 }
1845 1845
1846 bool TestRunner::ShouldGeneratePixelResults() { 1846 bool TestRunner::ShouldGeneratePixelResults() {
1847 CheckResponseMimeType(); 1847 CheckResponseMimeType();
1848 return generate_pixel_results_; 1848 return generate_pixel_results_;
1849 } 1849 }
1850 1850
1851 bool TestRunner::ShouldStayOnPageAfterHandlingBeforeUnload() const { 1851 bool TestRunner::ShouldStayOnPageAfterHandlingBeforeUnload() const {
1852 return should_stay_on_page_after_handling_before_unload_; 1852 return should_stay_on_page_after_handling_before_unload_;
1853 } 1853 }
1854 1854
1855 1855
1856 void TestRunner::setShouldGeneratePixelResults(bool value) { 1856 void TestRunner::setShouldGeneratePixelResults(bool value) {
1857 generate_pixel_results_ = value; 1857 generate_pixel_results_ = value;
1858 } 1858 }
1859 1859
1860 bool TestRunner::shouldDumpChildFrameScrollPositions() const {
1861 return dump_child_frame_scroll_positions_;
1862 }
1863
1864 bool TestRunner::shouldDumpChildFramesAsMarkup() const {
1865 return dump_child_frames_as_markup_;
1866 }
1867
1868 bool TestRunner::shouldDumpChildFramesAsText() const {
1869 return dump_child_frames_as_text_;
1870 }
1871
1872 bool TestRunner::ShouldDumpAsAudio() const { 1860 bool TestRunner::ShouldDumpAsAudio() const {
1873 return dump_as_audio_; 1861 return dump_as_audio_;
1874 } 1862 }
1875 1863
1876 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const { 1864 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const {
1877 *buffer_view = audio_data_; 1865 *buffer_view = audio_data_;
1878 } 1866 }
1879 1867
1880 LayoutDumpFlags TestRunner::GetLayoutDumpFlags() { 1868 const LayoutDumpFlags& TestRunner::GetLayoutDumpFlags() {
1881 LayoutDumpFlags result; 1869 CheckResponseMimeType();
1882 1870 return layout_dump_flags_;
1883 if (shouldDumpAsText()) {
1884 result.main_dump_mode = LayoutDumpMode::DUMP_AS_TEXT;
1885 result.dump_child_frames = shouldDumpChildFramesAsText();
1886 } else if (shouldDumpAsMarkup()) {
1887 result.main_dump_mode = LayoutDumpMode::DUMP_AS_MARKUP;
1888 result.dump_child_frames = shouldDumpChildFramesAsMarkup();
1889 } else {
1890 result.main_dump_mode = LayoutDumpMode::DUMP_SCROLL_POSITIONS;
1891 result.dump_child_frames = shouldDumpChildFrameScrollPositions();
1892 }
1893
1894 result.dump_as_printed = isPrinting();
1895
1896 result.dump_line_box_trees = result.debug_render_tree = false;
1897
1898 return result;
1899 } 1871 }
1900 1872
1901 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const { 1873 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const {
1902 if (shouldDumpAsCustomText()) { 1874 if (shouldDumpAsCustomText()) {
1903 *custom_text_dump = customDumpText(); 1875 *custom_text_dump = customDumpText();
1904 return true; 1876 return true;
1905 } 1877 }
1906 1878
1907 return false; 1879 return false;
1908 } 1880 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1973 1945
1974 bool TestRunner::ShouldDumpBackForwardList() const { 1946 bool TestRunner::ShouldDumpBackForwardList() const {
1975 return dump_back_forward_list_; 1947 return dump_back_forward_list_;
1976 } 1948 }
1977 1949
1978 bool TestRunner::shouldDumpSelectionRect() const { 1950 bool TestRunner::shouldDumpSelectionRect() const {
1979 return dump_selection_rect_; 1951 return dump_selection_rect_;
1980 } 1952 }
1981 1953
1982 bool TestRunner::isPrinting() const { 1954 bool TestRunner::isPrinting() const {
1983 return is_printing_; 1955 return layout_dump_flags_.is_printing;
1984 } 1956 }
1985 1957
1986 bool TestRunner::shouldWaitUntilExternalURLLoad() const { 1958 bool TestRunner::shouldWaitUntilExternalURLLoad() const {
1987 return wait_until_external_url_load_; 1959 return wait_until_external_url_load_;
1988 } 1960 }
1989 1961
1990 const std::set<std::string>* TestRunner::httpHeadersToClear() const { 1962 const std::set<std::string>* TestRunner::httpHeadersToClear() const {
1991 return &http_headers_to_clear_; 1963 return &http_headers_to_clear_;
1992 } 1964 }
1993 1965
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2696 2668
2697 bool TestRunner::AnimationScheduled() { 2669 bool TestRunner::AnimationScheduled() {
2698 return proxy_->AnimationScheduled(); 2670 return proxy_->AnimationScheduled();
2699 } 2671 }
2700 2672
2701 void TestRunner::DumpEditingCallbacks() { 2673 void TestRunner::DumpEditingCallbacks() {
2702 dump_editting_callbacks_ = true; 2674 dump_editting_callbacks_ = true;
2703 } 2675 }
2704 2676
2705 void TestRunner::DumpAsMarkup() { 2677 void TestRunner::DumpAsMarkup() {
2706 dump_as_markup_ = true; 2678 layout_dump_flags_.dump_as_markup = true;
2707 generate_pixel_results_ = false; 2679 generate_pixel_results_ = false;
2708 } 2680 }
2709 2681
2710 void TestRunner::DumpAsText() { 2682 void TestRunner::DumpAsText() {
2711 dump_as_text_ = true; 2683 layout_dump_flags_.dump_as_text = true;
2712 generate_pixel_results_ = false; 2684 generate_pixel_results_ = false;
2713 } 2685 }
2714 2686
2715 void TestRunner::DumpAsTextWithPixelResults() { 2687 void TestRunner::DumpAsTextWithPixelResults() {
2716 dump_as_text_ = true; 2688 layout_dump_flags_.dump_as_text = true;
2717 generate_pixel_results_ = true; 2689 generate_pixel_results_ = true;
2718 } 2690 }
2719 2691
2720 void TestRunner::DumpChildFrameScrollPositions() { 2692 void TestRunner::DumpChildFrameScrollPositions() {
2721 dump_child_frame_scroll_positions_ = true; 2693 layout_dump_flags_.dump_child_frame_scroll_positions = true;
2722 } 2694 }
2723 2695
2724 void TestRunner::DumpChildFramesAsMarkup() { 2696 void TestRunner::DumpChildFramesAsMarkup() {
2725 dump_child_frames_as_markup_ = true; 2697 layout_dump_flags_.dump_child_frames_as_markup = true;
2726 } 2698 }
2727 2699
2728 void TestRunner::DumpChildFramesAsText() { 2700 void TestRunner::DumpChildFramesAsText() {
2729 dump_child_frames_as_text_ = true; 2701 layout_dump_flags_.dump_child_frames_as_text = true;
2730 } 2702 }
2731 2703
2732 void TestRunner::DumpIconChanges() { 2704 void TestRunner::DumpIconChanges() {
2733 dump_icon_changes_ = true; 2705 dump_icon_changes_ = true;
2734 } 2706 }
2735 2707
2736 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) { 2708 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) {
2737 unsigned char* bytes = static_cast<unsigned char*>(view.bytes()); 2709 unsigned char* bytes = static_cast<unsigned char*>(view.bytes());
2738 audio_data_.resize(view.num_bytes()); 2710 audio_data_.resize(view.num_bytes());
2739 std::copy(bytes, bytes + view.num_bytes(), audio_data_.begin()); 2711 std::copy(bytes, bytes + view.num_bytes(), audio_data_.begin());
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2818 2790
2819 void TestRunner::DumpBackForwardList() { 2791 void TestRunner::DumpBackForwardList() {
2820 dump_back_forward_list_ = true; 2792 dump_back_forward_list_ = true;
2821 } 2793 }
2822 2794
2823 void TestRunner::DumpSelectionRect() { 2795 void TestRunner::DumpSelectionRect() {
2824 dump_selection_rect_ = true; 2796 dump_selection_rect_ = true;
2825 } 2797 }
2826 2798
2827 void TestRunner::SetPrinting() { 2799 void TestRunner::SetPrinting() {
2828 is_printing_ = true; 2800 layout_dump_flags_.is_printing = true;
2829 } 2801 }
2830 2802
2831 void TestRunner::ClearPrinting() { 2803 void TestRunner::ClearPrinting() {
2832 is_printing_ = false; 2804 layout_dump_flags_.is_printing = false;
2833 } 2805 }
2834 2806
2835 void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) { 2807 void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) {
2836 should_stay_on_page_after_handling_before_unload_ = value; 2808 should_stay_on_page_after_handling_before_unload_ = value;
2837 } 2809 }
2838 2810
2839 void TestRunner::SetWillSendRequestClearHeader(const std::string& header) { 2811 void TestRunner::SetWillSendRequestClearHeader(const std::string& header) {
2840 if (!header.empty()) 2812 if (!header.empty())
2841 http_headers_to_clear_.insert(header); 2813 http_headers_to_clear_.insert(header);
2842 } 2814 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 // No more new work after the first complete load. 3172 // No more new work after the first complete load.
3201 work_queue_.set_frozen(true); 3173 work_queue_.set_frozen(true);
3202 3174
3203 if (!wait_until_done_) 3175 if (!wait_until_done_)
3204 work_queue_.ProcessWorkSoon(); 3176 work_queue_.ProcessWorkSoon();
3205 } 3177 }
3206 3178
3207 void TestRunner::CheckResponseMimeType() { 3179 void TestRunner::CheckResponseMimeType() {
3208 // Text output: the test page can request different types of output which we 3180 // Text output: the test page can request different types of output which we
3209 // handle here. 3181 // handle here.
3210 if (!dump_as_text_) { 3182 if (!layout_dump_flags_.dump_as_text) {
3211 std::string mimeType = 3183 std::string mimeType =
3212 web_view_->mainFrame()->dataSource()->response().mimeType().utf8(); 3184 web_view_->mainFrame()->dataSource()->response().mimeType().utf8();
3213 if (mimeType == "text/plain") { 3185 if (mimeType == "text/plain") {
3214 dump_as_text_ = true; 3186 layout_dump_flags_.dump_as_text = true;
3215 generate_pixel_results_ = false; 3187 generate_pixel_results_ = false;
3216 } 3188 }
3217 } 3189 }
3218 } 3190 }
3219 3191
3220 void TestRunner::CompleteNotifyDone() { 3192 void TestRunner::CompleteNotifyDone() {
3221 if (wait_until_done_ && !topLoadingFrame() && work_queue_.is_empty()) 3193 if (wait_until_done_ && !topLoadingFrame() && work_queue_.is_empty())
3222 delegate_->TestFinished(); 3194 delegate_->TestFinished();
3223 wait_until_done_ = false; 3195 wait_until_done_ = false;
3224 } 3196 }
(...skipping 16 matching lines...) Expand all
3241 } 3213 }
3242 3214
3243 void TestRunner::DidLosePointerLockInternal() { 3215 void TestRunner::DidLosePointerLockInternal() {
3244 bool was_locked = pointer_locked_; 3216 bool was_locked = pointer_locked_;
3245 pointer_locked_ = false; 3217 pointer_locked_ = false;
3246 if (was_locked) 3218 if (was_locked)
3247 web_view_->didLosePointerLock(); 3219 web_view_->didLosePointerLock();
3248 } 3220 }
3249 3221
3250 } // namespace test_runner 3222 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/test_runner.h ('k') | components/test_runner/web_test_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698