OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 {2.5, -1, "src.gif", "2x.gif 2x", "2x.gif", 2.0, -1}, | 37 {2.5, -1, "src.gif", "2x.gif 2x", "2x.gif", 2.0, -1}, |
38 {2.5, -1, "src.gif", "2x.gif 2x, 3x.gif 3x", "3x.gif", 3.0, -1}, | 38 {2.5, -1, "src.gif", "2x.gif 2x, 3x.gif 3x", "3x.gif", 3.0, -1}, |
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 {2.0, -1, "", "1x.gif 1x, data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0
cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIj4KCTxyZWN0IHdp
ZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJncmVlbiIvPgo8L3N2Zz4K 2x", "data:image/sv
g+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDA
iIGhlaWdodD0iMTAwIj4KCTxyZWN0IHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJncmVlbiI
vPgo8L3N2Zz4K", 2.0, -1 }, |
| 48 {2.0, -1, "1x.gif", "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL
3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIj4KCTxyZWN0IHdpZHRoP
SIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJncmVlbiIvPgo8L3N2Zz4K 2x", "data:image/svg+xml
;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDAiIGhl
aWdodD0iMTAwIj4KCTxyZWN0IHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJncmVlbiIvPgo8
L3N2Zz4K", 2.0, -1 }, |
| 49 {2.0, -1, "1x.svg#red", "1x.svg#green 2x", "1x.svg#green", 2.0, -1 }, |
| 50 {2.0, -1, "", "1x.svg#red 1x, 1x.svg#green 2x", "1x.svg#green", 2.0, -1
}, |
47 {1.0, 400, "", "400.gif 400w, 6000.gif 6000w", "400.gif", 1.0, 400}, | 51 {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}, | 52 {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}, | 53 {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}, | 54 {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}, | 55 {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}, | 56 {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}, | 57 {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}, | 58 {2.0, 400, "", "400.gif 400w, 2x.gif 2x", "2x.gif", 2.0, -1}, |
55 {1.0, 0, "", "400.gif 400w, 6000.gif 6000w", "400.gif", std::numeric_lim
its<float>::infinity(), 400}, | 59 {1.0, 0, "", "400.gif 400w, 6000.gif 6000w", "400.gif", std::numeric_lim
its<float>::infinity(), 400}, |
56 {0, 0, 0, 0, 0, 0} // Do not remove the terminator line. | 60 {0, 0, 0, 0, 0, 0} // Do not remove the terminator line. |
57 }; | 61 }; |
58 | 62 |
59 for (unsigned i = 0; testCases[i].srcInput; ++i) { | 63 for (unsigned i = 0; testCases[i].srcInput; ++i) { |
60 TestCase test = testCases[i]; | 64 TestCase test = testCases[i]; |
61 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc
aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput); | 65 ImageCandidate candidate = bestFitSourceForImageAttributes(test.deviceSc
aleFactor, test.effectiveSize, test.srcInput, test.srcsetInput); |
62 ASSERT_EQ(test.outputScaleFactor, candidate.scaleFactor()); | 66 ASSERT_EQ(test.outputScaleFactor, candidate.scaleFactor()); |
63 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth()); | 67 ASSERT_EQ(test.outputResourceWidth, candidate.resourceWidth()); |
64 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data()); | 68 ASSERT_STREQ(test.outputURL, candidate.toString().ascii().data()); |
65 } | 69 } |
66 } | 70 } |
67 | 71 |
68 } // namespace | 72 } // namespace |
OLD | NEW |