| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/frame/LocalFrame.h" | 31 #include "core/frame/LocalFrame.h" |
| 32 #include "core/frame/LocalFrameView.h" | 32 #include "core/frame/LocalFrameView.h" |
| 33 #include "core/frame/PageScaleConstraints.h" | 33 #include "core/frame/PageScaleConstraints.h" |
| 34 #include "core/frame/Settings.h" | 34 #include "core/frame/Settings.h" |
| 35 #include "core/frame/WebLocalFrameBase.h" |
| 35 #include "core/page/Page.h" | 36 #include "core/page/Page.h" |
| 36 #include "platform/Length.h" | 37 #include "platform/Length.h" |
| 37 #include "platform/geometry/IntPoint.h" | 38 #include "platform/geometry/IntPoint.h" |
| 38 #include "platform/geometry/IntRect.h" | 39 #include "platform/geometry/IntRect.h" |
| 39 #include "platform/geometry/IntSize.h" | 40 #include "platform/geometry/IntSize.h" |
| 40 #include "platform/scroll/ScrollbarTheme.h" | 41 #include "platform/scroll/ScrollbarTheme.h" |
| 41 #include "platform/testing/URLTestHelpers.h" | 42 #include "platform/testing/URLTestHelpers.h" |
| 42 #include "platform/testing/UnitTestHelpers.h" | 43 #include "platform/testing/UnitTestHelpers.h" |
| 43 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
| 44 #include "public/platform/WebURLLoaderMockFactory.h" | 45 #include "public/platform/WebURLLoaderMockFactory.h" |
| 45 #include "public/web/WebConsoleMessage.h" | 46 #include "public/web/WebConsoleMessage.h" |
| 46 #include "public/web/WebFrame.h" | 47 #include "public/web/WebFrame.h" |
| 48 #include "public/web/WebLocalFrame.h" |
| 47 #include "public/web/WebScriptSource.h" | 49 #include "public/web/WebScriptSource.h" |
| 48 #include "public/web/WebSettings.h" | 50 #include "public/web/WebSettings.h" |
| 49 #include "public/web/WebViewClient.h" | 51 #include "public/web/WebViewClient.h" |
| 50 #include "testing/gtest/include/gtest/gtest.h" | 52 #include "testing/gtest/include/gtest/gtest.h" |
| 51 #include "web/tests/FrameTestHelpers.h" | 53 #include "web/tests/FrameTestHelpers.h" |
| 52 | 54 |
| 53 namespace blink { | 55 namespace blink { |
| 54 | 56 |
| 55 using blink::testing::RunPendingTasks; | 57 using blink::testing::RunPendingTasks; |
| 56 | 58 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 70 WebString::FromUTF8(base_url_), testing::WebTestDataPath(), | 72 WebString::FromUTF8(base_url_), testing::WebTestDataPath(), |
| 71 WebString::FromUTF8(file_name)); | 73 WebString::FromUTF8(file_name)); |
| 72 } | 74 } |
| 73 | 75 |
| 74 void RegisterMockedChromeURLLoad(const std::string& file_name) { | 76 void RegisterMockedChromeURLLoad(const std::string& file_name) { |
| 75 URLTestHelpers::RegisterMockedURLLoadFromBase( | 77 URLTestHelpers::RegisterMockedURLLoadFromBase( |
| 76 WebString::FromUTF8(chrome_url_), testing::WebTestDataPath(), | 78 WebString::FromUTF8(chrome_url_), testing::WebTestDataPath(), |
| 77 WebString::FromUTF8(file_name)); | 79 WebString::FromUTF8(file_name)); |
| 78 } | 80 } |
| 79 | 81 |
| 80 void ExecuteScript(WebFrame* frame, const WebString& code) { | 82 void ExecuteScript(WebLocalFrame* frame, const WebString& code) { |
| 81 frame->ExecuteScript(WebScriptSource(code)); | 83 frame->ExecuteScript(WebScriptSource(code)); |
| 82 RunPendingTasks(); | 84 RunPendingTasks(); |
| 83 } | 85 } |
| 84 | 86 |
| 85 std::string base_url_; | 87 std::string base_url_; |
| 86 std::string chrome_url_; | 88 std::string chrome_url_; |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 static void SetViewportSettings(WebSettings* settings) { | 91 static void SetViewportSettings(WebSettings* settings) { |
| 90 settings->SetViewportEnabled(true); | 92 settings->SetViewportEnabled(true); |
| (...skipping 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2873 Page* page = web_view_helper.WebView()->GetPage(); | 2875 Page* page = web_view_helper.WebView()->GetPage(); |
| 2874 PageScaleConstraints constraints = RunViewportTest(page, 320, 352); | 2876 PageScaleConstraints constraints = RunViewportTest(page, 320, 352); |
| 2875 | 2877 |
| 2876 EXPECT_EQ(320, constraints.layout_size.Width()); | 2878 EXPECT_EQ(320, constraints.layout_size.Width()); |
| 2877 EXPECT_EQ(352, constraints.layout_size.Height()); | 2879 EXPECT_EQ(352, constraints.layout_size.Height()); |
| 2878 EXPECT_NEAR(1.0f, constraints.initial_scale, 0.01f); | 2880 EXPECT_NEAR(1.0f, constraints.initial_scale, 0.01f); |
| 2879 EXPECT_NEAR(1.0f, constraints.minimum_scale, 0.01f); | 2881 EXPECT_NEAR(1.0f, constraints.minimum_scale, 0.01f); |
| 2880 EXPECT_NEAR(5.0f, constraints.maximum_scale, 0.01f); | 2882 EXPECT_NEAR(5.0f, constraints.maximum_scale, 0.01f); |
| 2881 EXPECT_TRUE(page->GetViewportDescription().user_zoom); | 2883 EXPECT_TRUE(page->GetViewportDescription().user_zoom); |
| 2882 | 2884 |
| 2883 ExecuteScript(web_view_helper.WebView()->MainFrame(), | 2885 ExecuteScript(web_view_helper.WebView()->MainFrameImpl(), |
| 2884 "originalDoctype = document.doctype;" | 2886 "originalDoctype = document.doctype;" |
| 2885 "document.removeChild(originalDoctype);"); | 2887 "document.removeChild(originalDoctype);"); |
| 2886 | 2888 |
| 2887 constraints = RunViewportTest(page, 320, 352); | 2889 constraints = RunViewportTest(page, 320, 352); |
| 2888 | 2890 |
| 2889 EXPECT_EQ(320, constraints.layout_size.Width()); | 2891 EXPECT_EQ(320, constraints.layout_size.Width()); |
| 2890 EXPECT_EQ(352, constraints.layout_size.Height()); | 2892 EXPECT_EQ(352, constraints.layout_size.Height()); |
| 2891 EXPECT_NEAR(1.0f, constraints.initial_scale, 0.01f); | 2893 EXPECT_NEAR(1.0f, constraints.initial_scale, 0.01f); |
| 2892 EXPECT_NEAR(1.0f, constraints.minimum_scale, 0.01f); | 2894 EXPECT_NEAR(1.0f, constraints.minimum_scale, 0.01f); |
| 2893 EXPECT_NEAR(5.0f, constraints.maximum_scale, 0.01f); | 2895 EXPECT_NEAR(5.0f, constraints.maximum_scale, 0.01f); |
| 2894 EXPECT_TRUE(page->GetViewportDescription().user_zoom); | 2896 EXPECT_TRUE(page->GetViewportDescription().user_zoom); |
| 2895 | 2897 |
| 2896 ExecuteScript(web_view_helper.WebView()->MainFrame(), | 2898 ExecuteScript(web_view_helper.WebView()->MainFrameImpl(), |
| 2897 "document.insertBefore(originalDoctype, document.firstChild);"); | 2899 "document.insertBefore(originalDoctype, document.firstChild);"); |
| 2898 | 2900 |
| 2899 constraints = RunViewportTest(page, 320, 352); | 2901 constraints = RunViewportTest(page, 320, 352); |
| 2900 | 2902 |
| 2901 EXPECT_EQ(320, constraints.layout_size.Width()); | 2903 EXPECT_EQ(320, constraints.layout_size.Width()); |
| 2902 EXPECT_EQ(352, constraints.layout_size.Height()); | 2904 EXPECT_EQ(352, constraints.layout_size.Height()); |
| 2903 EXPECT_NEAR(1.0f, constraints.initial_scale, 0.01f); | 2905 EXPECT_NEAR(1.0f, constraints.initial_scale, 0.01f); |
| 2904 EXPECT_NEAR(1.0f, constraints.minimum_scale, 0.01f); | 2906 EXPECT_NEAR(1.0f, constraints.minimum_scale, 0.01f); |
| 2905 EXPECT_NEAR(5.0f, constraints.maximum_scale, 0.01f); | 2907 EXPECT_NEAR(5.0f, constraints.maximum_scale, 0.01f); |
| 2906 EXPECT_TRUE(page->GetViewportDescription().user_zoom); | 2908 EXPECT_TRUE(page->GetViewportDescription().user_zoom); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3212 base_url_ + "viewport/viewport-warnings-7.html", true, &web_frame_client, | 3214 base_url_ + "viewport/viewport-warnings-7.html", true, &web_frame_client, |
| 3213 nullptr, nullptr, SetViewportSettings); | 3215 nullptr, nullptr, SetViewportSettings); |
| 3214 | 3216 |
| 3215 Page* page = web_view_helper.WebView()->GetPage(); | 3217 Page* page = web_view_helper.WebView()->GetPage(); |
| 3216 RunViewportTest(page, 320, 352); | 3218 RunViewportTest(page, 320, 352); |
| 3217 | 3219 |
| 3218 EXPECT_EQ(0U, web_frame_client.messages.size()); | 3220 EXPECT_EQ(0U, web_frame_client.messages.size()); |
| 3219 } | 3221 } |
| 3220 | 3222 |
| 3221 } // namespace blink | 3223 } // namespace blink |
| OLD | NEW |