OLD | NEW |
---|---|
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 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1729 delegate_->DeleteAllCookies(); | 1729 delegate_->DeleteAllCookies(); |
1730 delegate_->ResetScreenOrientation(); | 1730 delegate_->ResetScreenOrientation(); |
1731 delegate_->SetBluetoothMockDataSet(""); | 1731 delegate_->SetBluetoothMockDataSet(""); |
1732 delegate_->ClearGeofencingMockProvider(); | 1732 delegate_->ClearGeofencingMockProvider(); |
1733 delegate_->ResetPermissions(); | 1733 delegate_->ResetPermissions(); |
1734 ResetBatteryStatus(); | 1734 ResetBatteryStatus(); |
1735 ResetDeviceLight(); | 1735 ResetDeviceLight(); |
1736 } | 1736 } |
1737 | 1737 |
1738 dump_editting_callbacks_ = false; | 1738 dump_editting_callbacks_ = false; |
1739 dump_as_text_ = false; | 1739 layout_dump_flags_.dump_as_text = false; |
1740 dump_as_markup_ = false; | 1740 layout_dump_flags_.dump_as_markup = false; |
1741 generate_pixel_results_ = true; | 1741 generate_pixel_results_ = true; |
1742 dump_child_frame_scroll_positions_ = false; | 1742 layout_dump_flags_.dump_child_frame_scroll_positions = false; |
1743 dump_child_frames_as_markup_ = false; | 1743 layout_dump_flags_.dump_child_frames_as_markup = false; |
1744 dump_child_frames_as_text_ = false; | 1744 layout_dump_flags_.dump_child_frames_as_text = false; |
1745 layout_dump_flags_.dump_line_box_trees = false; | |
1746 layout_dump_flags_.debug_render_tree = false; | |
1745 dump_icon_changes_ = false; | 1747 dump_icon_changes_ = false; |
1746 dump_as_audio_ = false; | 1748 dump_as_audio_ = false; |
1747 dump_frame_load_callbacks_ = false; | 1749 dump_frame_load_callbacks_ = false; |
1748 dump_ping_loader_callbacks_ = false; | 1750 dump_ping_loader_callbacks_ = false; |
1749 dump_user_gesture_in_frame_load_callbacks_ = false; | 1751 dump_user_gesture_in_frame_load_callbacks_ = false; |
1750 dump_title_changes_ = false; | 1752 dump_title_changes_ = false; |
1751 dump_create_view_ = false; | 1753 dump_create_view_ = false; |
1752 can_open_windows_ = false; | 1754 can_open_windows_ = false; |
1753 dump_resource_load_callbacks_ = false; | 1755 dump_resource_load_callbacks_ = false; |
1754 dump_resource_request_callbacks_ = false; | 1756 dump_resource_request_callbacks_ = false; |
1755 dump_resource_response_mime_types_ = false; | 1757 dump_resource_response_mime_types_ = false; |
1756 dump_window_status_changes_ = false; | 1758 dump_window_status_changes_ = false; |
1757 dump_spell_check_callbacks_ = false; | 1759 dump_spell_check_callbacks_ = false; |
1758 dump_back_forward_list_ = false; | 1760 dump_back_forward_list_ = false; |
1759 dump_selection_rect_ = false; | 1761 dump_selection_rect_ = false; |
1760 dump_drag_image_ = false; | 1762 dump_drag_image_ = false; |
1761 dump_navigation_policy_ = false; | 1763 dump_navigation_policy_ = false; |
1762 test_repaint_ = false; | 1764 test_repaint_ = false; |
1763 sweep_horizontally_ = false; | 1765 sweep_horizontally_ = false; |
1764 is_printing_ = false; | 1766 layout_dump_flags_.is_printing = false; |
1765 midi_accessor_result_ = true; | 1767 midi_accessor_result_ = true; |
1766 should_stay_on_page_after_handling_before_unload_ = false; | 1768 should_stay_on_page_after_handling_before_unload_ = false; |
1767 should_dump_resource_priorities_ = false; | 1769 should_dump_resource_priorities_ = false; |
1768 has_custom_text_output_ = false; | 1770 has_custom_text_output_ = false; |
1769 custom_text_output_.clear(); | 1771 custom_text_output_.clear(); |
1770 | 1772 |
1771 http_headers_to_clear_.clear(); | 1773 http_headers_to_clear_.clear(); |
1772 | 1774 |
1773 platform_name_ = "chromium"; | 1775 platform_name_ = "chromium"; |
1774 tooltip_text_ = std::string(); | 1776 tooltip_text_ = std::string(); |
(...skipping 22 matching lines...) Expand all Loading... | |
1797 } | 1799 } |
1798 | 1800 |
1799 void TestRunner::InvokeCallback(scoped_ptr<InvokeCallbackTask> task) { | 1801 void TestRunner::InvokeCallback(scoped_ptr<InvokeCallbackTask> task) { |
1800 delegate_->PostTask(task.release()); | 1802 delegate_->PostTask(task.release()); |
1801 } | 1803 } |
1802 | 1804 |
1803 bool TestRunner::shouldDumpEditingCallbacks() const { | 1805 bool TestRunner::shouldDumpEditingCallbacks() const { |
1804 return dump_editting_callbacks_; | 1806 return dump_editting_callbacks_; |
1805 } | 1807 } |
1806 | 1808 |
1807 bool TestRunner::shouldDumpAsText() { | |
1808 CheckResponseMimeType(); | |
1809 return dump_as_text_; | |
1810 } | |
1811 | |
1812 void TestRunner::setShouldDumpAsText(bool value) { | 1809 void TestRunner::setShouldDumpAsText(bool value) { |
1813 dump_as_text_ = value; | 1810 layout_dump_flags_.dump_as_text = value; |
1814 } | |
1815 | |
1816 bool TestRunner::shouldDumpAsMarkup() { | |
1817 return dump_as_markup_; | |
1818 } | 1811 } |
1819 | 1812 |
1820 void TestRunner::setShouldDumpAsMarkup(bool value) { | 1813 void TestRunner::setShouldDumpAsMarkup(bool value) { |
1821 dump_as_markup_ = value; | 1814 layout_dump_flags_.dump_as_markup = value; |
1822 } | 1815 } |
1823 | 1816 |
1824 bool TestRunner::shouldDumpAsCustomText() const { | 1817 bool TestRunner::shouldDumpAsCustomText() const { |
1825 return has_custom_text_output_; | 1818 return has_custom_text_output_; |
1826 } | 1819 } |
1827 | 1820 |
1828 std::string TestRunner::customDumpText() const { | 1821 std::string TestRunner::customDumpText() const { |
1829 return custom_text_output_; | 1822 return custom_text_output_; |
1830 } | 1823 } |
1831 | 1824 |
1832 void TestRunner::setCustomTextOutput(const std::string& text) { | 1825 void TestRunner::setCustomTextOutput(const std::string& text) { |
1833 custom_text_output_ = text; | 1826 custom_text_output_ = text; |
1834 has_custom_text_output_ = true; | 1827 has_custom_text_output_ = true; |
1835 } | 1828 } |
1836 | 1829 |
1837 bool TestRunner::ShouldGeneratePixelResults() { | 1830 bool TestRunner::ShouldGeneratePixelResults() { |
1838 CheckResponseMimeType(); | 1831 CheckResponseMimeType(); |
1839 return generate_pixel_results_; | 1832 return generate_pixel_results_; |
1840 } | 1833 } |
1841 | 1834 |
1842 bool TestRunner::ShouldStayOnPageAfterHandlingBeforeUnload() const { | 1835 bool TestRunner::ShouldStayOnPageAfterHandlingBeforeUnload() const { |
1843 return should_stay_on_page_after_handling_before_unload_; | 1836 return should_stay_on_page_after_handling_before_unload_; |
1844 } | 1837 } |
1845 | 1838 |
1846 | 1839 |
1847 void TestRunner::setShouldGeneratePixelResults(bool value) { | 1840 void TestRunner::setShouldGeneratePixelResults(bool value) { |
1848 generate_pixel_results_ = value; | 1841 generate_pixel_results_ = value; |
1849 } | 1842 } |
1850 | 1843 |
1851 bool TestRunner::shouldDumpChildFrameScrollPositions() const { | |
1852 return dump_child_frame_scroll_positions_; | |
1853 } | |
1854 | |
1855 bool TestRunner::shouldDumpChildFramesAsMarkup() const { | |
1856 return dump_child_frames_as_markup_; | |
1857 } | |
1858 | |
1859 bool TestRunner::shouldDumpChildFramesAsText() const { | |
1860 return dump_child_frames_as_text_; | |
1861 } | |
1862 | |
1863 bool TestRunner::ShouldDumpAsAudio() const { | 1844 bool TestRunner::ShouldDumpAsAudio() const { |
1864 return dump_as_audio_; | 1845 return dump_as_audio_; |
1865 } | 1846 } |
1866 | 1847 |
1867 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const { | 1848 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const { |
1868 *buffer_view = audio_data_; | 1849 *buffer_view = audio_data_; |
1869 } | 1850 } |
1870 | 1851 |
1871 LayoutDumpFlags TestRunner::GetLayoutDumpFlags() { | 1852 const LayoutDumpFlags& TestRunner::GetLayoutDumpFlags() { |
1872 LayoutDumpFlags result; | 1853 CheckResponseMimeType(); |
dcheng
2016/02/23 18:26:35
Why is this line here?
Łukasz Anforowicz
2016/02/23 18:45:26
Previously this call was made by shouldDumpAsText
| |
1873 | 1854 return layout_dump_flags_; |
1874 if (shouldDumpAsText()) { | |
1875 result.main_dump_mode = LayoutDumpMode::DUMP_AS_TEXT; | |
1876 result.dump_child_frames = shouldDumpChildFramesAsText(); | |
1877 } else if (shouldDumpAsMarkup()) { | |
1878 result.main_dump_mode = LayoutDumpMode::DUMP_AS_MARKUP; | |
1879 result.dump_child_frames = shouldDumpChildFramesAsMarkup(); | |
1880 } else { | |
1881 result.main_dump_mode = LayoutDumpMode::DUMP_SCROLL_POSITIONS; | |
1882 result.dump_child_frames = shouldDumpChildFrameScrollPositions(); | |
1883 } | |
1884 | |
1885 result.dump_as_printed = isPrinting(); | |
1886 | |
1887 result.dump_line_box_trees = result.debug_render_tree = false; | |
1888 | |
1889 return result; | |
1890 } | 1855 } |
1891 | 1856 |
1892 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const { | 1857 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const { |
1893 if (shouldDumpAsCustomText()) { | 1858 if (shouldDumpAsCustomText()) { |
1894 *custom_text_dump = customDumpText(); | 1859 *custom_text_dump = customDumpText(); |
1895 return true; | 1860 return true; |
1896 } | 1861 } |
1897 | 1862 |
1898 return false; | 1863 return false; |
1899 } | 1864 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1964 | 1929 |
1965 bool TestRunner::ShouldDumpBackForwardList() const { | 1930 bool TestRunner::ShouldDumpBackForwardList() const { |
1966 return dump_back_forward_list_; | 1931 return dump_back_forward_list_; |
1967 } | 1932 } |
1968 | 1933 |
1969 bool TestRunner::shouldDumpSelectionRect() const { | 1934 bool TestRunner::shouldDumpSelectionRect() const { |
1970 return dump_selection_rect_; | 1935 return dump_selection_rect_; |
1971 } | 1936 } |
1972 | 1937 |
1973 bool TestRunner::isPrinting() const { | 1938 bool TestRunner::isPrinting() const { |
1974 return is_printing_; | 1939 return layout_dump_flags_.is_printing; |
1975 } | 1940 } |
1976 | 1941 |
1977 bool TestRunner::shouldWaitUntilExternalURLLoad() const { | 1942 bool TestRunner::shouldWaitUntilExternalURLLoad() const { |
1978 return wait_until_external_url_load_; | 1943 return wait_until_external_url_load_; |
1979 } | 1944 } |
1980 | 1945 |
1981 const std::set<std::string>* TestRunner::httpHeadersToClear() const { | 1946 const std::set<std::string>* TestRunner::httpHeadersToClear() const { |
1982 return &http_headers_to_clear_; | 1947 return &http_headers_to_clear_; |
1983 } | 1948 } |
1984 | 1949 |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2683 void TestRunner::SetPluginsEnabled(bool enabled) { | 2648 void TestRunner::SetPluginsEnabled(bool enabled) { |
2684 delegate_->Preferences()->plugins_enabled = enabled; | 2649 delegate_->Preferences()->plugins_enabled = enabled; |
2685 delegate_->ApplyPreferences(); | 2650 delegate_->ApplyPreferences(); |
2686 } | 2651 } |
2687 | 2652 |
2688 void TestRunner::DumpEditingCallbacks() { | 2653 void TestRunner::DumpEditingCallbacks() { |
2689 dump_editting_callbacks_ = true; | 2654 dump_editting_callbacks_ = true; |
2690 } | 2655 } |
2691 | 2656 |
2692 void TestRunner::DumpAsMarkup() { | 2657 void TestRunner::DumpAsMarkup() { |
2693 dump_as_markup_ = true; | 2658 layout_dump_flags_.dump_as_markup = true; |
2694 generate_pixel_results_ = false; | 2659 generate_pixel_results_ = false; |
2695 } | 2660 } |
2696 | 2661 |
2697 void TestRunner::DumpAsText() { | 2662 void TestRunner::DumpAsText() { |
2698 dump_as_text_ = true; | 2663 layout_dump_flags_.dump_as_text = true; |
2699 generate_pixel_results_ = false; | 2664 generate_pixel_results_ = false; |
2700 } | 2665 } |
2701 | 2666 |
2702 void TestRunner::DumpAsTextWithPixelResults() { | 2667 void TestRunner::DumpAsTextWithPixelResults() { |
2703 dump_as_text_ = true; | 2668 layout_dump_flags_.dump_as_text = true; |
2704 generate_pixel_results_ = true; | 2669 generate_pixel_results_ = true; |
2705 } | 2670 } |
2706 | 2671 |
2707 void TestRunner::DumpChildFrameScrollPositions() { | 2672 void TestRunner::DumpChildFrameScrollPositions() { |
2708 dump_child_frame_scroll_positions_ = true; | 2673 layout_dump_flags_.dump_child_frame_scroll_positions = true; |
2709 } | 2674 } |
2710 | 2675 |
2711 void TestRunner::DumpChildFramesAsMarkup() { | 2676 void TestRunner::DumpChildFramesAsMarkup() { |
2712 dump_child_frames_as_markup_ = true; | 2677 layout_dump_flags_.dump_child_frames_as_markup = true; |
2713 } | 2678 } |
2714 | 2679 |
2715 void TestRunner::DumpChildFramesAsText() { | 2680 void TestRunner::DumpChildFramesAsText() { |
2716 dump_child_frames_as_text_ = true; | 2681 layout_dump_flags_.dump_child_frames_as_text = true; |
2717 } | 2682 } |
2718 | 2683 |
2719 void TestRunner::DumpIconChanges() { | 2684 void TestRunner::DumpIconChanges() { |
2720 dump_icon_changes_ = true; | 2685 dump_icon_changes_ = true; |
2721 } | 2686 } |
2722 | 2687 |
2723 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) { | 2688 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) { |
2724 unsigned char* bytes = static_cast<unsigned char*>(view.bytes()); | 2689 unsigned char* bytes = static_cast<unsigned char*>(view.bytes()); |
2725 audio_data_.resize(view.num_bytes()); | 2690 audio_data_.resize(view.num_bytes()); |
2726 std::copy(bytes, bytes + view.num_bytes(), audio_data_.begin()); | 2691 std::copy(bytes, bytes + view.num_bytes(), audio_data_.begin()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2805 | 2770 |
2806 void TestRunner::DumpBackForwardList() { | 2771 void TestRunner::DumpBackForwardList() { |
2807 dump_back_forward_list_ = true; | 2772 dump_back_forward_list_ = true; |
2808 } | 2773 } |
2809 | 2774 |
2810 void TestRunner::DumpSelectionRect() { | 2775 void TestRunner::DumpSelectionRect() { |
2811 dump_selection_rect_ = true; | 2776 dump_selection_rect_ = true; |
2812 } | 2777 } |
2813 | 2778 |
2814 void TestRunner::SetPrinting() { | 2779 void TestRunner::SetPrinting() { |
2815 is_printing_ = true; | 2780 layout_dump_flags_.is_printing = true; |
2816 } | 2781 } |
2817 | 2782 |
2818 void TestRunner::ClearPrinting() { | 2783 void TestRunner::ClearPrinting() { |
2819 is_printing_ = false; | 2784 layout_dump_flags_.is_printing = false; |
2820 } | 2785 } |
2821 | 2786 |
2822 void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) { | 2787 void TestRunner::SetShouldStayOnPageAfterHandlingBeforeUnload(bool value) { |
2823 should_stay_on_page_after_handling_before_unload_ = value; | 2788 should_stay_on_page_after_handling_before_unload_ = value; |
2824 } | 2789 } |
2825 | 2790 |
2826 void TestRunner::SetWillSendRequestClearHeader(const std::string& header) { | 2791 void TestRunner::SetWillSendRequestClearHeader(const std::string& header) { |
2827 if (!header.empty()) | 2792 if (!header.empty()) |
2828 http_headers_to_clear_.insert(header); | 2793 http_headers_to_clear_.insert(header); |
2829 } | 2794 } |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3187 // No more new work after the first complete load. | 3152 // No more new work after the first complete load. |
3188 work_queue_.set_frozen(true); | 3153 work_queue_.set_frozen(true); |
3189 | 3154 |
3190 if (!wait_until_done_) | 3155 if (!wait_until_done_) |
3191 work_queue_.ProcessWorkSoon(); | 3156 work_queue_.ProcessWorkSoon(); |
3192 } | 3157 } |
3193 | 3158 |
3194 void TestRunner::CheckResponseMimeType() { | 3159 void TestRunner::CheckResponseMimeType() { |
3195 // Text output: the test page can request different types of output which we | 3160 // Text output: the test page can request different types of output which we |
3196 // handle here. | 3161 // handle here. |
3197 if (!dump_as_text_) { | 3162 if (!layout_dump_flags_.dump_as_text) { |
3198 std::string mimeType = | 3163 std::string mimeType = |
3199 web_view_->mainFrame()->dataSource()->response().mimeType().utf8(); | 3164 web_view_->mainFrame()->dataSource()->response().mimeType().utf8(); |
3200 if (mimeType == "text/plain") { | 3165 if (mimeType == "text/plain") { |
3201 dump_as_text_ = true; | 3166 layout_dump_flags_.dump_as_text = true; |
3202 generate_pixel_results_ = false; | 3167 generate_pixel_results_ = false; |
3203 } | 3168 } |
3204 } | 3169 } |
3205 } | 3170 } |
3206 | 3171 |
3207 void TestRunner::CompleteNotifyDone() { | 3172 void TestRunner::CompleteNotifyDone() { |
3208 if (wait_until_done_ && !topLoadingFrame() && work_queue_.is_empty()) | 3173 if (wait_until_done_ && !topLoadingFrame() && work_queue_.is_empty()) |
3209 delegate_->TestFinished(); | 3174 delegate_->TestFinished(); |
3210 wait_until_done_ = false; | 3175 wait_until_done_ = false; |
3211 } | 3176 } |
(...skipping 16 matching lines...) Expand all Loading... | |
3228 } | 3193 } |
3229 | 3194 |
3230 void TestRunner::DidLosePointerLockInternal() { | 3195 void TestRunner::DidLosePointerLockInternal() { |
3231 bool was_locked = pointer_locked_; | 3196 bool was_locked = pointer_locked_; |
3232 pointer_locked_ = false; | 3197 pointer_locked_ = false; |
3233 if (was_locked) | 3198 if (was_locked) |
3234 web_view_->didLosePointerLock(); | 3199 web_view_->didLosePointerLock(); |
3235 } | 3200 } |
3236 | 3201 |
3237 } // namespace test_runner | 3202 } // namespace test_runner |
OLD | NEW |