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

Side by Side Diff: Source/core/css/parser/SizesAttributeParserTest.cpp

Issue 259193004: Enable calc() parsing in the sizes attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@calc4
Patch Set: Fixed a test following zcorpan's comment Created 6 years, 7 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/css/parser/SizesAttributeParser.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/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 30 matching lines...) Expand all
41 {" /**/ 300px", 300}, 41 {" /**/ 300px", 300},
42 {"300px /**/ ", 300}, 42 {"300px /**/ ", 300},
43 {" /**/ (min-width:500px) /**/ 300px", 300}, 43 {" /**/ (min-width:500px) /**/ 300px", 300},
44 {"-100px, 200px", 200}, 44 {"-100px, 200px", 200},
45 {"-50vw, 20vw", 100}, 45 {"-50vw, 20vw", 100},
46 {"50asdf, 200px", 200}, 46 {"50asdf, 200px", 200},
47 {"asdf, 200px", 200}, 47 {"asdf, 200px", 200},
48 {"(max-width: 3000px) 200w, 400w", 500}, 48 {"(max-width: 3000px) 200w, 400w", 500},
49 {",, , /**/ ,200px", 200}, 49 {",, , /**/ ,200px", 200},
50 {"50vw", 250}, 50 {"50vw", 250},
51 {"calc(40vw*2)", 400},
52 {"(min-width:5000px) calc(5000px/10), (min-width:500px) calc(1200px/3)", 400},
53 {"(min-width:500px) calc(1200/3)", 500},
54 {"(min-width:500px) calc(1200px/(0px*14))", 500},
51 // FIXME - test all other units, zero length and calc(). 55 // FIXME - test all other units, zero length and calc().
52 {0, 0} // Do not remove the terminator line. 56 {0, 0} // Do not remove the terminator line.
53 }; 57 };
54 58
55 MediaValuesCached::MediaValuesCachedData data; 59 MediaValuesCached::MediaValuesCachedData data;
56 data.viewportWidth = 500; 60 data.viewportWidth = 500;
57 data.viewportHeight = 500; 61 data.viewportHeight = 500;
58 data.deviceWidth = 500; 62 data.deviceWidth = 500;
59 data.deviceHeight = 500; 63 data.deviceHeight = 500;
60 data.devicePixelRatio = 2.0; 64 data.devicePixelRatio = 2.0;
61 data.colorBitsPerComponent = 24; 65 data.colorBitsPerComponent = 24;
62 data.monochromeBitsPerComponent = 0; 66 data.monochromeBitsPerComponent = 0;
63 data.pointer = MediaValues::MousePointer; 67 data.pointer = MediaValues::MousePointer;
64 data.defaultFontSize = 16; 68 data.defaultFontSize = 16;
65 data.threeDEnabled = true; 69 data.threeDEnabled = true;
66 data.scanMediaType = false; 70 data.scanMediaType = false;
67 data.screenMediaType = true; 71 data.screenMediaType = true;
68 data.printMediaType = false; 72 data.printMediaType = false;
69 data.strictMode = true; 73 data.strictMode = true;
70 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data); 74 RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data);
71 75
72 for (unsigned i = 0; testCases[i].input; ++i) { 76 for (unsigned i = 0; testCases[i].input; ++i) {
73 int effectiveSize = SizesAttributeParser::findEffectiveSize(testCases[i] .input, mediaValues); 77 int effectiveSize = SizesAttributeParser::findEffectiveSize(testCases[i] .input, mediaValues);
74 ASSERT_EQ(testCases[i].output, effectiveSize); 78 ASSERT_EQ(testCases[i].output, effectiveSize);
75 } 79 }
76 } 80 }
77 81
78 } // namespace 82 } // namespace
OLDNEW
« no previous file with comments | « Source/core/css/parser/SizesAttributeParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698