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/css/MediaValuesCached.h" | 8 #include "core/css/MediaValuesCached.h" |
9 | 9 |
10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
(...skipping 18 matching lines...) Expand all Loading... |
29 {"(min-width:500px) 200px, 400px", 200}, | 29 {"(min-width:500px) 200px, 400px", 200}, |
30 {"400px, (min-width:500px) 200px", 400}, | 30 {"400px, (min-width:500px) 200px", 400}, |
31 {"(min-width:5000px) 200px, 400px", 400}, | 31 {"(min-width:5000px) 200px, 400px", 400}, |
32 {"(blalbadfsdf) 200px, 400px", 400}, | 32 {"(blalbadfsdf) 200px, 400px", 400}, |
33 {"0", 500}, | 33 {"0", 500}, |
34 {"-0", 500}, | 34 {"-0", 500}, |
35 {"1", 500}, | 35 {"1", 500}, |
36 {"300px, 400px", 300}, | 36 {"300px, 400px", 300}, |
37 {"(min-width:5000px) 200px, (min-width:500px) 400px", 400}, | 37 {"(min-width:5000px) 200px, (min-width:500px) 400px", 400}, |
38 {"", 500}, | 38 {"", 500}, |
| 39 {" ", 500}, |
39 {" /**/ ", 500}, | 40 {" /**/ ", 500}, |
40 {" /**/ 300px", 300}, | 41 {" /**/ 300px", 300}, |
41 {"300px /**/ ", 300}, | 42 {"300px /**/ ", 300}, |
42 {" /**/ (min-width:500px) /**/ 300px", 300}, | 43 {" /**/ (min-width:500px) /**/ 300px", 300}, |
43 {"-100px, 200px", 200}, | 44 {"-100px, 200px", 200}, |
44 {"-50vw, 20vw", 100}, | 45 {"-50vw, 20vw", 100}, |
45 {"50asdf, 200px", 200}, | 46 {"50asdf, 200px", 200}, |
46 {"asdf, 200px", 200}, | 47 {"asdf, 200px", 200}, |
47 {"(max-width: 3000px) 200w, 400w", 500}, | 48 {"(max-width: 3000px) 200w, 400w", 500}, |
48 {",, , /**/ ,200px", 200}, | 49 {",, , /**/ ,200px", 200}, |
| 50 {"50vw", 250}, |
49 // FIXME - test all other units, zero length and calc(). | 51 // FIXME - test all other units, zero length and calc(). |
50 {0, 0} // Do not remove the terminator line. | 52 {0, 0} // Do not remove the terminator line. |
51 }; | 53 }; |
52 | 54 |
53 MediaValuesCached::MediaValuesCachedData data; | 55 MediaValuesCached::MediaValuesCachedData data; |
54 data.viewportWidth = 500; | 56 data.viewportWidth = 500; |
55 data.viewportHeight = 500; | 57 data.viewportHeight = 500; |
56 data.deviceWidth = 500; | 58 data.deviceWidth = 500; |
57 data.deviceHeight = 500; | 59 data.deviceHeight = 500; |
58 data.devicePixelRatio = 2.0; | 60 data.devicePixelRatio = 2.0; |
59 data.colorBitsPerComponent = 24; | 61 data.colorBitsPerComponent = 24; |
60 data.monochromeBitsPerComponent = 0; | 62 data.monochromeBitsPerComponent = 0; |
61 data.pointer = MediaValues::MousePointer; | 63 data.pointer = MediaValues::MousePointer; |
62 data.defaultFontSize = 16; | 64 data.defaultFontSize = 16; |
63 data.threeDEnabled = true; | 65 data.threeDEnabled = true; |
64 data.scanMediaType = false; | 66 data.scanMediaType = false; |
65 data.screenMediaType = true; | 67 data.screenMediaType = true; |
66 data.printMediaType = false; | 68 data.printMediaType = false; |
67 data.strictMode = true; | 69 data.strictMode = true; |
68 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data); | 70 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data); |
69 | 71 |
70 for (unsigned i = 0; testCases[i].input; ++i) { | 72 for (unsigned i = 0; testCases[i].input; ++i) { |
71 int effectiveSize = SizesAttributeParser::findEffectiveSize(testCases[i]
.input, mediaValues); | 73 int effectiveSize = SizesAttributeParser::findEffectiveSize(testCases[i]
.input, mediaValues); |
72 ASSERT_EQ(testCases[i].output, effectiveSize); | 74 ASSERT_EQ(testCases[i].output, effectiveSize); |
73 } | 75 } |
74 } | 76 } |
75 | 77 |
76 } // namespace | 78 } // namespace |
OLD | NEW |