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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "public/web/WebSettings.h" | 49 #include "public/web/WebSettings.h" |
50 #include "public/web/WebViewClient.h" | 50 #include "public/web/WebViewClient.h" |
51 #include "web/tests/FrameTestHelpers.h" | 51 #include "web/tests/FrameTestHelpers.h" |
52 #include "web/tests/URLTestHelpers.h" | 52 #include "web/tests/URLTestHelpers.h" |
53 #include <gmock/gmock.h> | 53 #include <gmock/gmock.h> |
54 #include <gtest/gtest.h> | 54 #include <gtest/gtest.h> |
55 | 55 |
56 #include <vector> | 56 #include <vector> |
57 | 57 |
58 using namespace blink; | 58 using namespace blink; |
59 using WebCore::LocalFrame; | 59 using blink::LocalFrame; |
60 using WebCore::FrameView; | 60 using blink::FrameView; |
61 using WebCore::IntPoint; | 61 using blink::IntPoint; |
62 using WebCore::IntRect; | 62 using blink::IntRect; |
63 using WebCore::IntSize; | 63 using blink::IntSize; |
64 using WebCore::Page; | 64 using blink::Page; |
65 using WebCore::PageScaleConstraints; | 65 using blink::PageScaleConstraints; |
66 using WebCore::ViewportDescription; | 66 using blink::ViewportDescription; |
67 using blink::FrameTestHelpers::runPendingTasks; | 67 using blink::FrameTestHelpers::runPendingTasks; |
68 | 68 |
69 namespace { | 69 namespace { |
70 | 70 |
71 class ViewportTest : public testing::Test { | 71 class ViewportTest : public testing::Test { |
72 protected: | 72 protected: |
73 ViewportTest() | 73 ViewportTest() |
74 : m_baseURL("http://www.test.com/") | 74 : m_baseURL("http://www.test.com/") |
75 , m_chromeURL("chrome://") | 75 , m_chromeURL("chrome://") |
76 { | 76 { |
(...skipping 21 matching lines...) Expand all Loading... |
98 } | 98 } |
99 | 99 |
100 std::string m_baseURL; | 100 std::string m_baseURL; |
101 std::string m_chromeURL; | 101 std::string m_chromeURL; |
102 }; | 102 }; |
103 | 103 |
104 class UseMockScrollbarSettings { | 104 class UseMockScrollbarSettings { |
105 public: | 105 public: |
106 UseMockScrollbarSettings() | 106 UseMockScrollbarSettings() |
107 { | 107 { |
108 WebCore::Settings::setMockScrollbarsEnabled(true); | 108 blink::Settings::setMockScrollbarsEnabled(true); |
109 WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); | 109 blink::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); |
110 EXPECT_TRUE(WebCore::ScrollbarTheme::theme()->usesOverlayScrollbars()); | 110 EXPECT_TRUE(blink::ScrollbarTheme::theme()->usesOverlayScrollbars()); |
111 } | 111 } |
112 | 112 |
113 ~UseMockScrollbarSettings() | 113 ~UseMockScrollbarSettings() |
114 { | 114 { |
115 WebCore::Settings::setMockScrollbarsEnabled(false); | 115 blink::Settings::setMockScrollbarsEnabled(false); |
116 WebCore::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); | 116 blink::RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); |
117 } | 117 } |
118 }; | 118 }; |
119 | 119 |
120 static void setViewportSettings(WebSettings* settings) | 120 static void setViewportSettings(WebSettings* settings) |
121 { | 121 { |
122 settings->setViewportEnabled(true); | 122 settings->setViewportEnabled(true); |
123 settings->setViewportMetaEnabled(true); | 123 settings->setViewportMetaEnabled(true); |
124 settings->setMainFrameResizesAreOrientationChanges(true); | 124 settings->setMainFrameResizesAreOrientationChanges(true); |
125 } | 125 } |
126 | 126 |
127 static PageScaleConstraints runViewportTest(Page* page, int initialWidth, int in
itialHeight) | 127 static PageScaleConstraints runViewportTest(Page* page, int initialWidth, int in
itialHeight) |
128 { | 128 { |
129 IntSize initialViewportSize(initialWidth, initialHeight); | 129 IntSize initialViewportSize(initialWidth, initialHeight); |
130 toLocalFrame(page->mainFrame())->view()->setFrameRect(IntRect(IntPoint::zero
(), initialViewportSize)); | 130 toLocalFrame(page->mainFrame())->view()->setFrameRect(IntRect(IntPoint::zero
(), initialViewportSize)); |
131 ViewportDescription description = page->viewportDescription(); | 131 ViewportDescription description = page->viewportDescription(); |
132 PageScaleConstraints constraints = description.resolve(initialViewportSize,
WebCore::Length(980, WebCore::Fixed)); | 132 PageScaleConstraints constraints = description.resolve(initialViewportSize,
blink::Length(980, blink::Fixed)); |
133 | 133 |
134 constraints.fitToContentsWidth(constraints.layoutSize.width(), initialWidth)
; | 134 constraints.fitToContentsWidth(constraints.layoutSize.width(), initialWidth)
; |
135 return constraints; | 135 return constraints; |
136 } | 136 } |
137 | 137 |
138 TEST_F(ViewportTest, viewport1) | 138 TEST_F(ViewportTest, viewport1) |
139 { | 139 { |
140 UseMockScrollbarSettings mockScrollbarSettings; | 140 UseMockScrollbarSettings mockScrollbarSettings; |
141 registerMockedHttpURLLoad("viewport/viewport-1.html"); | 141 registerMockedHttpURLLoad("viewport/viewport-1.html"); |
142 | 142 |
(...skipping 3072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3215 FrameTestHelpers::WebViewHelper webViewHelper; | 3215 FrameTestHelpers::WebViewHelper webViewHelper; |
3216 webViewHelper.initializeAndLoad(m_baseURL + "viewport/viewport-warnings-7.ht
ml", true, &webFrameClient, 0, setViewportSettings); | 3216 webViewHelper.initializeAndLoad(m_baseURL + "viewport/viewport-warnings-7.ht
ml", true, &webFrameClient, 0, setViewportSettings); |
3217 | 3217 |
3218 Page* page = webViewHelper.webViewImpl()->page(); | 3218 Page* page = webViewHelper.webViewImpl()->page(); |
3219 runViewportTest(page, 320, 352); | 3219 runViewportTest(page, 320, 352); |
3220 | 3220 |
3221 EXPECT_EQ(0U, webFrameClient.messages.size()); | 3221 EXPECT_EQ(0U, webFrameClient.messages.size()); |
3222 } | 3222 } |
3223 | 3223 |
3224 } // namespace | 3224 } // namespace |
OLD | NEW |