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/css/parser/SizesAttributeParser.h" | 6 #include "core/css/parser/SizesAttributeParser.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 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 {" /**/ 300px", 300, false}, | 45 {" /**/ 300px", 300, false}, |
46 {"300px /**/ ", 300, false}, | 46 {"300px /**/ ", 300, false}, |
47 {" /**/ (min-width:500px) /**/ 300px", 300, false}, | 47 {" /**/ (min-width:500px) /**/ 300px", 300, false}, |
48 {"-100px, 200px", 200, false}, | 48 {"-100px, 200px", 200, false}, |
49 {"-50vw, 20vw", 100, true}, | 49 {"-50vw, 20vw", 100, true}, |
50 {"50asdf, 200px", 200, false}, | 50 {"50asdf, 200px", 200, false}, |
51 {"asdf, 200px", 200, false}, | 51 {"asdf, 200px", 200, false}, |
52 {"(max-width: 3000px) 200w, 400w", 500, true}, | 52 {"(max-width: 3000px) 200w, 400w", 500, true}, |
53 {",, , /**/ ,200px", 200, false}, | 53 {",, , /**/ ,200px", 200, false}, |
54 {"50vw", 250, true}, | 54 {"50vw", 250, true}, |
| 55 {"50vh", 300, true}, |
| 56 {"50vmin", 250, true}, |
| 57 {"50vmax", 300, true}, |
55 {"5em", 80, false}, | 58 {"5em", 80, false}, |
56 {"5rem", 80, false}, | 59 {"5rem", 80, false}, |
57 {"calc(40vw*2)", 400, true}, | 60 {"calc(40vw*2)", 400, true}, |
58 {"(min-width:5000px) calc(5000px/10), (min-width:500px) calc(1200px/3)",
400, false}, | 61 {"(min-width:5000px) calc(5000px/10), (min-width:500px) calc(1200px/3)",
400, false}, |
59 {"(min-width:500px) calc(1200/3)", 500, true}, | 62 {"(min-width:500px) calc(1200/3)", 500, true}, |
60 {"(min-width:500px) calc(1200px/(0px*14))", 500, true}, | 63 {"(min-width:500px) calc(1200px/(0px*14))", 500, true}, |
61 {"(max-width: 3000px) 200px, 400px", 200, false}, | 64 {"(max-width: 3000px) 200px, 400px", 200, false}, |
62 {"(max-width: 3000px) 20em, 40em", 320, false}, | 65 {"(max-width: 3000px) 20em, 40em", 320, false}, |
63 {"(max-width: 3000px) 0, 40em", 0, false}, | 66 {"(max-width: 3000px) 0, 40em", 0, false}, |
64 {"(max-width: 3000px) 0px, 40em", 0, false}, | 67 {"(max-width: 3000px) 0px, 40em", 0, false}, |
65 {"(max-width: 3000px) 50vw, 40em", 250, true}, | 68 {"(max-width: 3000px) 50vw, 40em", 250, true}, |
66 {"(max-width: 3000px) 50px, 40vw", 50, false}, | 69 {"(max-width: 3000px) 50px, 40vw", 50, false}, |
67 {"((),1px", 500, true}, | 70 {"((),1px", 500, true}, |
68 {"{{},1px", 500, true}, | 71 {"{{},1px", 500, true}, |
69 {"[[],1px", 500, true}, | 72 {"[[],1px", 500, true}, |
70 {"x(x(),1px", 500, true}, | 73 {"x(x(),1px", 500, true}, |
71 {"(max-width: 3000px) 50.5px, 40vw", 50.5, false}, | 74 {"(max-width: 3000px) 50.5px, 40vw", 50.5, false}, |
72 {"not (blabla) 50px, 40vw", 200, true}, | 75 {"not (blabla) 50px, 40vw", 200, true}, |
73 {"not (max-width: 100px) 50px, 40vw", 50, false}, | 76 {"not (max-width: 100px) 50px, 40vw", 50, false}, |
74 {0, 0, false} // Do not remove the terminator line. | 77 {0, 0, false} // Do not remove the terminator line. |
75 }; | 78 }; |
76 | 79 |
77 MediaValuesCached::MediaValuesCachedData data; | 80 MediaValuesCached::MediaValuesCachedData data; |
78 data.viewportWidth = 500; | 81 data.viewportWidth = 500; |
79 data.viewportHeight = 500; | 82 data.viewportHeight = 600; |
80 data.deviceWidth = 500; | 83 data.deviceWidth = 500; |
81 data.deviceHeight = 500; | 84 data.deviceHeight = 500; |
82 data.devicePixelRatio = 2.0; | 85 data.devicePixelRatio = 2.0; |
83 data.colorBitsPerComponent = 24; | 86 data.colorBitsPerComponent = 24; |
84 data.monochromeBitsPerComponent = 0; | 87 data.monochromeBitsPerComponent = 0; |
85 data.primaryPointerType = PointerTypeFine; | 88 data.primaryPointerType = PointerTypeFine; |
86 data.defaultFontSize = 16; | 89 data.defaultFontSize = 16; |
87 data.threeDEnabled = true; | 90 data.threeDEnabled = true; |
88 data.mediaType = MediaTypeNames::screen; | 91 data.mediaType = MediaTypeNames::screen; |
89 data.strictMode = true; | 92 data.strictMode = true; |
90 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data); | 93 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data); |
91 | 94 |
92 for (unsigned i = 0; testCases[i].input; ++i) { | 95 for (unsigned i = 0; testCases[i].input; ++i) { |
93 SizesAttributeParser parser(mediaValues, testCases[i].input); | 96 SizesAttributeParser parser(mediaValues, testCases[i].input); |
94 ASSERT_EQ(testCases[i].effectiveSize, parser.length()); | 97 ASSERT_EQ(testCases[i].effectiveSize, parser.length()); |
95 ASSERT_EQ(testCases[i].viewportDependant, parser.viewportDependant()); | 98 ASSERT_EQ(testCases[i].viewportDependant, parser.viewportDependant()); |
96 } | 99 } |
97 } | 100 } |
98 | 101 |
99 } // namespace | 102 } // namespace |
OLD | NEW |