OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 12 matching lines...) Expand all Loading... |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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/dom/NodeTraversal.h" | 31 #include "core/dom/NodeTraversal.h" |
32 #include "platform/testing/URLTestHelpers.h" | 32 #include "platform/testing/URLTestHelpers.h" |
| 33 #include "platform/testing/UnitTestHelpers.h" |
33 #include "public/platform/Platform.h" | 34 #include "public/platform/Platform.h" |
34 #include "public/platform/WebPrerender.h" | 35 #include "public/platform/WebPrerender.h" |
35 #include "public/platform/WebPrerenderingSupport.h" | 36 #include "public/platform/WebPrerenderingSupport.h" |
36 #include "public/platform/WebString.h" | 37 #include "public/platform/WebString.h" |
37 #include "public/platform/WebURLLoaderMockFactory.h" | 38 #include "public/platform/WebURLLoaderMockFactory.h" |
38 #include "public/web/WebCache.h" | 39 #include "public/web/WebCache.h" |
39 #include "public/web/WebFrame.h" | 40 #include "public/web/WebFrame.h" |
40 #include "public/web/WebPrerendererClient.h" | 41 #include "public/web/WebPrerendererClient.h" |
41 #include "public/web/WebScriptSource.h" | 42 #include "public/web/WebScriptSource.h" |
42 #include "public/web/WebView.h" | 43 #include "public/web/WebView.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 m_abandonedPrerenders.push_back(prerender); | 150 m_abandonedPrerenders.push_back(prerender); |
150 } | 151 } |
151 | 152 |
152 void prefetchFinished() override {} | 153 void prefetchFinished() override {} |
153 | 154 |
154 Vector<WebPrerender> m_addedPrerenders; | 155 Vector<WebPrerender> m_addedPrerenders; |
155 Vector<WebPrerender> m_canceledPrerenders; | 156 Vector<WebPrerender> m_canceledPrerenders; |
156 Vector<WebPrerender> m_abandonedPrerenders; | 157 Vector<WebPrerender> m_abandonedPrerenders; |
157 }; | 158 }; |
158 | 159 |
159 class PrerenderingTest : public testing::Test { | 160 class PrerenderingTest : public ::testing::Test { |
160 public: | 161 public: |
161 ~PrerenderingTest() override { | 162 ~PrerenderingTest() override { |
162 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 163 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
163 WebCache::clear(); | 164 WebCache::clear(); |
164 } | 165 } |
165 | 166 |
166 void initialize(const char* baseURL, const char* fileName) { | 167 void initialize(const char* baseURL, const char* fileName) { |
167 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL), | 168 URLTestHelpers::registerMockedURLLoadFromBase( |
168 WebString::fromUTF8(fileName)); | 169 WebString::fromUTF8(baseURL), blink::testing::webTestDataPath(), |
| 170 WebString::fromUTF8(fileName)); |
169 const bool RunJavascript = true; | 171 const bool RunJavascript = true; |
170 m_webViewHelper.initialize(RunJavascript); | 172 m_webViewHelper.initialize(RunJavascript); |
171 m_webViewHelper.webView()->setPrerendererClient(&m_prerendererClient); | 173 m_webViewHelper.webView()->setPrerendererClient(&m_prerendererClient); |
172 | 174 |
173 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), | 175 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), |
174 std::string(baseURL) + fileName); | 176 std::string(baseURL) + fileName); |
175 } | 177 } |
176 | 178 |
177 void navigateAway() { | 179 void navigateAway() { |
178 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), | 180 FrameTestHelpers::loadFrame(m_webViewHelper.webView()->mainFrame(), |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 | 466 |
465 WebPrerender relNextAndPrerender = prerendererClient()->releaseWebPrerender(); | 467 WebPrerender relNextAndPrerender = prerendererClient()->releaseWebPrerender(); |
466 EXPECT_EQ(toWebURL("http://rel-next-and-prerender.com/"), | 468 EXPECT_EQ(toWebURL("http://rel-next-and-prerender.com/"), |
467 relNextAndPrerender.url()); | 469 relNextAndPrerender.url()); |
468 EXPECT_EQ( | 470 EXPECT_EQ( |
469 static_cast<unsigned>(PrerenderRelTypeNext | PrerenderRelTypePrerender), | 471 static_cast<unsigned>(PrerenderRelTypeNext | PrerenderRelTypePrerender), |
470 relNextAndPrerender.relTypes()); | 472 relNextAndPrerender.relTypes()); |
471 } | 473 } |
472 | 474 |
473 } // namespace | 475 } // namespace |
OLD | NEW |