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

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

Issue 1306743003: Fix float parsing in srcset (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: switched clamp to cast Created 5 years, 3 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 {2.0, 800, "src.gif", "400.gif 400w", "400.gif", 0.5, 400}, 93 {2.0, 800, "src.gif", "400.gif 400w", "400.gif", 0.5, 400},
94 {1.0, 400, "src.gif", "800.gif 800w", "800.gif", 2.0, 800}, 94 {1.0, 400, "src.gif", "800.gif 800w", "800.gif", 2.0, 800},
95 {1.0, 400, "src.gif", "0.gif 0w, 800.gif 800w", "800.gif", 2.0, 800}, 95 {1.0, 400, "src.gif", "0.gif 0w, 800.gif 800w", "800.gif", 2.0, 800},
96 {1.0, 400, "src.gif", "0.gif 0w, 2x.gif 2x", "src.gif", 1.0, -1}, 96 {1.0, 400, "src.gif", "0.gif 0w, 2x.gif 2x", "src.gif", 1.0, -1},
97 {1.0, 400, "src.gif", "800.gif 2x, 1600.gif 1600w", "800.gif", 2.0, -1}, 97 {1.0, 400, "src.gif", "800.gif 2x, 1600.gif 1600w", "800.gif", 2.0, -1},
98 {1.0, 400, "", "400.gif 400w, 2x.gif 2x", "400.gif", 1.0, 400}, 98 {1.0, 400, "", "400.gif 400w, 2x.gif 2x", "400.gif", 1.0, 400},
99 {2.0, 400, "", "400.gif 400w, 2x.gif 2x", "2x.gif", 2.0, -1}, 99 {2.0, 400, "", "400.gif 400w, 2x.gif 2x", "2x.gif", 2.0, -1},
100 {1.0, 0, "", "400.gif 400w, 6000.gif 6000w", "400.gif", std::numeric_lim its<float>::infinity(), 400}, 100 {1.0, 0, "", "400.gif 400w, 6000.gif 6000w", "400.gif", std::numeric_lim its<float>::infinity(), 400},
101 {2.0, -1, "", ", 1x.gif 1x, 2x.gif 2x", "2x.gif", 2.0, -1}, 101 {2.0, -1, "", ", 1x.gif 1x, 2x.gif 2x", "2x.gif", 2.0, -1},
102 {1.0, -1, "", ",1x.gif 1x, 2x.gif 2x", "1x.gif", 1.0, -1}, 102 {1.0, -1, "", ",1x.gif 1x, 2x.gif 2x", "1x.gif", 1.0, -1},
103 {1.0, -1, "", ",1x.gif 1.x , 2x.gif 2x", "2x.gif", 2.0, -1},
103 {1.2, -1, "", ",1x.gif 1x, 1.4x.gif 1.4x, 2x.gif 2x", "1.4x.gif", 1.4, - 1}, 104 {1.2, -1, "", ",1x.gif 1x, 1.4x.gif 1.4x, 2x.gif 2x", "1.4x.gif", 1.4, - 1},
104 {1.0, -1, "", "inf.gif 0.00000000001x", "inf.gif", 1e-11, -1}, 105 {1.0, -1, "", "inf.gif 0.00000000001x", "inf.gif", 1e-11, -1},
105 {1.0, -1, "", "data:,a ( , data:,b 1x, ), data:,c", "data:,c", 1.0, -1}, 106 {1.0, -1, "", "data:,a ( , data:,b 1x, ), data:,c", "data:,c", 1.0, -1},
106 {1.0, 1, "", "data:,a 1w 1h", "data:,a", 1.0, 1}, 107 {1.0, 1, "", "data:,a 1w 1h", "data:,a", 1.0, 1},
107 {1.0, -1, "", ",1x.gif 1x future-descriptor(3x, 4h, whatever), 2x.gif 2x ", "2x.gif", 2.0, -1}, 108 {1.0, -1, "", ",1x.gif 1x future-descriptor(3x, 4h, whatever), 2x.gif 2x ", "2x.gif", 2.0, -1},
108 {2.0, -1, "", ",1x.gif 1x future-descriptor(3x, 4h, whatever), 2x.gif 2x ", "2x.gif", 2.0, -1}, 109 {2.0, -1, "", ",1x.gif 1x future-descriptor(3x, 4h, whatever), 2x.gif 2x ", "2x.gif", 2.0, -1},
109 {1.0, -1, "", "data:,a 1 w", "", 1.0, -1}, 110 {1.0, -1, "", "data:,a 1 w", "", 1.0, -1},
110 {1.0, -1, "", "data:,a 1 w", "", 1.0, -1}, 111 {1.0, -1, "", "data:,a 1 w", "", 1.0, -1},
111 {1.0, -1, "", "data:,a +1x", "", 1.0, -1}, 112 {1.0, -1, "", "data:,a +1x", "", 1.0, -1},
112 {1.0, -1, "", "data:,a +1x", "", 1.0, -1}, 113 {1.0, -1, "", "data:,a +1x", "", 1.0, -1},
113 {1.0, -1, "", "data:,a 1.0x", "data:,a", 1.0, -1}, 114 {1.0, -1, "", "data:,a 1.0x", "data:,a", 1.0, -1},
114 {1.0, -1, "", "1%20and%202.gif 1x", "1%20and%202.gif", 1.0, -1}, 115 {1.0, -1, "", "1%20and%202.gif 1x", "1%20and%202.gif", 1.0, -1},
115 {1.0, 700, "", "data:,a 0.5x, data:,b 1400w", "data:,b", 2.0, 1400}, 116 {1.0, 700, "", "data:,a 0.5x, data:,b 1400w", "data:,b", 2.0, 1400},
116 {0, 0, 0, 0, 0, 0} // Do not remove the terminator line. 117 {0, 0, 0, 0, 0, 0} // Do not remove the terminator line.
117 }; 118 };
118 119
119 for (unsigned i = 0; testCases[i].srcInput; ++i) { 120 for (unsigned i = 0; testCases[i].srcInput; ++i) {
120 TestCase test = testCases[i]; 121 TestCase test = testCases[i];
121 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput); 122 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput);
122 ASSERT_EQ(test.outputDensity, candidate.density()); 123 ASSERT_EQ(test.outputDensity, candidate.density());
123 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth()); 124 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth());
124 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data()); 125 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data());
125 } 126 }
126 } 127 }
127 128
128 } // namespace 129 } // 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