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

Unified Diff: third_party/WebKit/Source/core/css/parser/SizesAttributeParserTest.cpp

Issue 2596203002: Return sizes' default effective size as float (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/SizesAttributeParser.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/parser/SizesAttributeParserTest.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/SizesAttributeParserTest.cpp b/third_party/WebKit/Source/core/css/parser/SizesAttributeParserTest.cpp
index 3011b6754559200d9e5e5ff7ee928453311656e8..972e5fd8c2062b3fdce70aab60e6289e0f87f164 100644
--- a/third_party/WebKit/Source/core/css/parser/SizesAttributeParserTest.cpp
+++ b/third_party/WebKit/Source/core/css/parser/SizesAttributeParserTest.cpp
@@ -96,4 +96,85 @@ TEST(SizesAttributeParserTest, Basic) {
}
}
+TEST(SizesAttributeParserTest, FloatViewportWidth) {
+ TestCase testCases[] = {
+ {"screen", 500.5},
+ {"(min-width:500px)", 500.5},
+ {"(min-width:500px) 200px", 200},
+ {"(min-width:500px) 50vw", 250.25},
+ {"(min-width:500px) 200px, 400px", 200},
+ {"400px, (min-width:500px) 200px", 400},
+ {"40vw, (min-width:500px) 201px", 200.2},
+ {"(min-width:500px) 201px, 40vw", 201},
+ {"(min-width:5000px) 40vw, 201px", 201},
+ {"(min-width:500px) calc(201px), calc(40vw)", 201},
+ {"(min-width:5000px) calc(40vw), calc(201px)", 201},
+ {"(min-width:5000px) 200px, 400px", 400},
+ {"(blalbadfsdf) 200px, 400px", 400},
+ {"0", 0},
+ {"-0", 0},
+ {"1", 500.5},
+ {"300px, 400px", 300},
+ {"(min-width:5000px) 200px, (min-width:500px) 400px", 400},
+ {"", 500.5},
+ {" ", 500.5},
+ {" /**/ ", 500.5},
+ {" /**/ 300px", 300},
+ {"300px /**/ ", 300},
+ {" /**/ (min-width:500px) /**/ 300px", 300},
+ {"-100px, 200px", 200},
+ {"-50vw, 20vw", 100.1},
+ {"50asdf, 200px", 200},
+ {"asdf, 200px", 200},
+ {"(max-width: 3000px) 200w, 400w", 500.5},
+ {",, , /**/ ,200px", 200},
+ {"50vw", 250.25},
+ {"50vh", 300},
+ {"50vmin", 250.25},
+ {"50vmax", 300},
+ {"5em", 80},
+ {"5rem", 80},
+ {"calc(40vw*2)", 400.4},
+ {"(min-width:5000px) calc(5000px/10), (min-width:500px) calc(1200px/3)",
+ 400},
+ {"(min-width:500px) calc(1200/3)", 500.5},
+ {"(min-width:500px) calc(1200px/(0px*14))", 500.5},
+ {"(max-width: 3000px) 200px, 400px", 200},
+ {"(max-width: 3000px) 20em, 40em", 320},
+ {"(max-width: 3000px) 0, 40em", 0},
+ {"(max-width: 3000px) 0px, 40em", 0},
+ {"(max-width: 3000px) 50vw, 40em", 250.25},
+ {"(max-width: 3000px) 50px, 40vw", 50},
+ {"((),1px", 500.5},
+ {"{{},1px", 500.5},
+ {"[[],1px", 500.5},
+ {"x(x(),1px", 500.5},
+ {"(max-width: 3000px) 50.5px, 40vw", 50.5},
+ {"not (blabla) 50px, 40vw", 200.2},
+ {"not (max-width: 100px) 50px, 40vw", 50},
+ {0, 0} // Do not remove the terminator line.
+ };
+
+ MediaValuesCached::MediaValuesCachedData data;
+ data.viewportWidth = 500.5;
+ data.viewportHeight = 600;
+ data.deviceWidth = 500;
+ data.deviceHeight = 500;
+ data.devicePixelRatio = 2.0;
+ data.colorBitsPerComponent = 24;
+ data.monochromeBitsPerComponent = 0;
+ data.primaryPointerType = PointerTypeFine;
+ data.defaultFontSize = 16;
+ data.threeDEnabled = true;
+ data.mediaType = MediaTypeNames::screen;
+ data.strictMode = true;
+ data.displayMode = WebDisplayModeBrowser;
+ MediaValues* mediaValues = MediaValuesCached::create(data);
+
+ for (unsigned i = 0; testCases[i].input; ++i) {
+ SizesAttributeParser parser(mediaValues, testCases[i].input);
+ ASSERT_EQ(testCases[i].effectiveSize, parser.length());
+ }
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/css/parser/SizesAttributeParser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698