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

Side by Side Diff: Source/core/html/parser/HTMLPreloadScannerTest.cpp

Issue 1104103002: Add <meta viewport> support to the preloader (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: moved CachedDocumentParameters constructor to private Created 5 years, 7 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 | « Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "config.h" 5 #include "config.h"
6 #include "core/html/parser/HTMLPreloadScanner.h" 6 #include "core/html/parser/HTMLPreloadScanner.h"
7 7
8 #include "core/MediaTypeNames.h" 8 #include "core/MediaTypeNames.h"
9 #include "core/css/MediaValuesCached.h" 9 #include "core/css/MediaValuesCached.h"
10 #include "core/html/parser/HTMLParserOptions.h" 10 #include "core/html/parser/HTMLParserOptions.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 data.mediaType = MediaTypeNames::screen; 67 data.mediaType = MediaTypeNames::screen;
68 data.strictMode = true; 68 data.strictMode = true;
69 data.displayMode = WebDisplayModeBrowser; 69 data.displayMode = WebDisplayModeBrowser;
70 return MediaValuesCached::create(data); 70 return MediaValuesCached::create(data);
71 } 71 }
72 72
73 virtual void SetUp() 73 virtual void SetUp()
74 { 74 {
75 HTMLParserOptions options(&m_dummyPageHolder->document()); 75 HTMLParserOptions options(&m_dummyPageHolder->document());
76 KURL documentURL(ParsedURLString, "http://whatever.test/"); 76 KURL documentURL(ParsedURLString, "http://whatever.test/");
77 m_scanner = HTMLPreloadScanner::create(options, documentURL, createMedia Values()); 77 m_scanner = HTMLPreloadScanner::create(options, documentURL, CachedDocum entParameters::create(&m_dummyPageHolder->document(), createMediaValues()));
78 78
79 } 79 }
80 80
81 void test(TestCase testCase) 81 void test(TestCase testCase)
82 { 82 {
83 MockHTMLResourcePreloader preloader; 83 MockHTMLResourcePreloader preloader;
84 KURL baseURL(ParsedURLString, testCase.baseURL); 84 KURL baseURL(ParsedURLString, testCase.baseURL);
85 m_scanner->appendToEnd(String(testCase.inputHTML)); 85 m_scanner->appendToEnd(String(testCase.inputHTML));
86 m_scanner->scan(&preloader, baseURL); 86 m_scanner->scan(&preloader, baseURL);
87 87
88 preloader.preloadRequestVerification(testCase.type, testCase.preloadedUR L, testCase.outputBaseURL, testCase.resourceWidth); 88 preloader.preloadRequestVerification(testCase.type, testCase.preloadedUR L, testCase.outputBaseURL, testCase.resourceWidth);
89 } 89 }
90 90
91 private: 91 private:
92 OwnPtr<DummyPageHolder> m_dummyPageHolder; 92 OwnPtr<DummyPageHolder> m_dummyPageHolder;
93 OwnPtr<HTMLPreloadScanner> m_scanner; 93 OwnPtr<HTMLPreloadScanner> m_scanner;
94 }; 94 };
95 95
96 TEST_F(HTMLPreloadScannerTest, testImages) 96 TEST_F(HTMLPreloadScannerTest, testImages)
97 { 97 {
98 TestCase testCases[] = { 98 TestCase testCases[] = {
99 {"http://example.test", "<img src='bla.gif'>", "bla.gif", "http://exampl e.test/", Resource::Image, 0}, 99 {"http://example.test", "<img src='bla.gif'>", "bla.gif", "http://exampl e.test/", Resource::Image, 0},
100 {"http://example.test", "<img srcset='bla.gif 320w, blabla.gif 640w'>", "blabla.gif", "http://example.test/", Resource::Image, 0},
101 {"http://example.test", "<meta name=viewport content='width=160'><img sr cset='bla.gif 320w, blabla.gif 640w'>", "bla.gif", "http://example.test/", Resou rce::Image, 0},
100 {0, 0, 0, 0, Resource::Raw, 0} // Do not remove the terminator line. 102 {0, 0, 0, 0, Resource::Raw, 0} // Do not remove the terminator line.
101 }; 103 };
102 104
103 for (unsigned i = 0; testCases[i].inputHTML; ++i) { 105 for (unsigned i = 0; testCases[i].inputHTML; ++i) {
104 TestCase testCase = testCases[i]; 106 TestCase testCase = testCases[i];
105 test(testCase); 107 test(testCase);
106 } 108 }
107 } 109 }
108 110
109 } 111 }
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698