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

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: 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
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},
eseidel 2014/04/13 20:57:55 Only one test?
49 {1.0, 0, "", "400.gif 400w, 6000.gif 6000w", "400.gif", std::numeric_lim its<float>::infinity(), 400}, 50 {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. 51 {0, 0, 0, 0, 0, 0} // Do not remove the terminator line.
51 }; 52 };
52 53
53 for (unsigned i = 0; testCases[i].srcInput; ++i) { 54 for (unsigned i = 0; testCases[i].srcInput; ++i) {
54 TestCase test = testCases[i]; 55 TestCase test = testCases[i];
55 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput); 56 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput);
56 ASSERT_EQ(test.outputScaleFactor, candidate.scaleFactor()); 57 ASSERT_EQ(test.outputScaleFactor, candidate.scaleFactor());
57 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth()); 58 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth());
58 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data()); 59 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data());
59 } 60 }
60 } 61 }
61 62
62 } // namespace 63 } // namespace
OLDNEW
« Source/core/html/parser/HTMLSrcsetParser.h ('K') | « Source/core/html/parser/HTMLSrcsetParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698