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

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

Issue 236593003: Align srcset parsing with spec changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added some more tests Created 6 years, 8 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/HTMLSrcsetParser.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 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 "config.h" 5 #include "config.h"
6 #include "core/html/parser/HTMLSrcsetParser.h" 6 #include "core/html/parser/HTMLSrcsetParser.h"
7 7
8 #include <gtest/gtest.h> 8 #include <gtest/gtest.h>
9 #include <limits.h> 9 #include <limits.h>
10 10
(...skipping 28 matching lines...) Expand all
39 {2.0, -1, "", "1x,, , x ,2x ", "1x,", 1.0, -1}, 39 {2.0, -1, "", "1x,, , x ,2x ", "1x,", 1.0, -1},
40 {2.0, -1, "", "1x,, , x ,2x ", "1x,", 1.0, -1}, 40 {2.0, -1, "", "1x,, , x ,2x ", "1x,", 1.0, -1},
41 {2.0, -1, "", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg 1x, 2x.gif 2 x", "2x.gif", 2.0, -1}, 41 {2.0, -1, "", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg 1x, 2x.gif 2 x", "2x.gif", 2.0, -1},
42 {2.0, -1, "", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg 2x, 1x.gif 1 x", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg", 2.0, -1}, 42 {2.0, -1, "", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg 2x, 1x.gif 1 x", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg", 2.0, -1},
43 {2.0, -1, "", "1x,, , x ,2x , 1x.gif, 3x, 4x.gif 4x 100h, 5x.gif 5, dx.gif dx, 2x.gif 2x ,", "2x.gif", 2.0, -1}, 43 {2.0, -1, "", "1x,, , x ,2x , 1x.gif, 3x, 4x.gif 4x 100h, 5x.gif 5, dx.gif dx, 2x.gif 2x ,", "2x.gif", 2.0, -1},
44 {4.0, -1, "", "1x,, , x ,2x , 1x.gif, 3x, 4x.gif 4x 100h, 5x.gif 5, dx.gif dx, 2x.gif 2x ,", "4x.gif", 4.0, -1}, 44 {4.0, -1, "", "1x,, , x ,2x , 1x.gif, 3x, 4x.gif 4x 100h, 5x.gif 5, dx.gif dx, 2x.gif 2x ,", "4x.gif", 4.0, -1},
45 {1.0, -1, "", "1x,, , x ,2x , 1x.gif, 3x, 4x.gif 4x 100h, 5x.gif 5, dx.gif dx, 2x.gif 2x ,", "1x,", 1.0, -1}, 45 {1.0, -1, "", "1x,, , x ,2x , 1x.gif, 3x, 4x.gif 4x 100h, 5x.gif 5, dx.gif dx, 2x.gif 2x ,", "1x,", 1.0, -1},
46 {5.0, -1, "", "1x,, , x ,2x , 1x.gif, 3x, 4x.gif 4x 100h, 5x.gif 5, dx.gif dx, 2x.gif 2x ,", "4x.gif", 4.0, -1}, 46 {5.0, -1, "", "1x,, , x ,2x , 1x.gif, 3x, 4x.gif 4x 100h, 5x.gif 5, dx.gif dx, 2x.gif 2x ,", "4x.gif", 4.0, -1},
47 {1.0, 400, "", "400.gif 400w, 6000.gif 6000w", "400.gif", 1.0, 400}, 47 {1.0, 400, "", "400.gif 400w, 6000.gif 6000w", "400.gif", 1.0, 400},
48 {2.0, 400, "", "400.gif 400w, 6000.gif 6000w", "6000.gif", 15.0, 6000}, 48 {2.0, 400, "", "400.gif 400w, 6000.gif 6000w", "6000.gif", 15.0, 6000},
49 {1.0, 400, "src.gif", "800.gif 800w", "800.gif", 2.0, 800},
50 {1.0, 400, "src.gif", "0.gif 0w, 800.gif 800w", "800.gif", 2.0, 800},
51 {1.0, 400, "src.gif", "0.gif 0w, 2x.gif 2x", "src.gif", 1.0, -1},
52 {1.0, 400, "src.gif", "800.gif 2x, 1600.gif 1600w", "800.gif", 2.0, -1},
53 {1.0, 400, "", "400.gif 400w, 2x.gif 2x", "400.gif", 1.0, 400},
54 {2.0, 400, "", "400.gif 400w, 2x.gif 2x", "2x.gif", 2.0, -1},
49 {1.0, 0, "", "400.gif 400w, 6000.gif 6000w", "400.gif", std::numeric_lim its<float>::infinity(), 400}, 55 {1.0, 0, "", "400.gif 400w, 6000.gif 6000w", "400.gif", std::numeric_lim its<float>::infinity(), 400},
50 {0, 0, 0, 0, 0, 0} // Do not remove the terminator line. 56 {0, 0, 0, 0, 0, 0} // Do not remove the terminator line.
51 }; 57 };
52 58
53 for (unsigned i = 0; testCases[i].srcInput; ++i) { 59 for (unsigned i = 0; testCases[i].srcInput; ++i) {
54 TestCase test = testCases[i]; 60 TestCase test = testCases[i];
55 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput); 61 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput);
56 ASSERT_EQ(test.outputScaleFactor, candidate.scaleFactor()); 62 ASSERT_EQ(test.outputScaleFactor, candidate.scaleFactor());
57 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth()); 63 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth());
58 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data()); 64 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data());
59 } 65 }
60 } 66 }
61 67
62 } // namespace 68 } // namespace
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLSrcsetParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698