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

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

Issue 369423002: Have srcset respond to viewport changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Got rid of assert Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/css/parser/SizesAttributeParserTest.cpp
diff --git a/Source/core/css/parser/SizesAttributeParserTest.cpp b/Source/core/css/parser/SizesAttributeParserTest.cpp
index 6af36fb8204cdcd45a0461feba70bad6d0d9635d..262dacdce930c2f494c753f1849daa08a3984ca9 100644
--- a/Source/core/css/parser/SizesAttributeParserTest.cpp
+++ b/Source/core/css/parser/SizesAttributeParserTest.cpp
@@ -14,47 +14,49 @@ namespace blink {
typedef struct {
const char* input;
- const int output;
+ const unsigned effectiveSize;
+ const bool viewportDependant;
} TestCase;
TEST(SizesAttributeParserTest, Basic)
{
TestCase testCases[] = {
- {"screen", 500},
- {"(min-width:500px)", 500},
- {"(min-width:500px) 200px", 200},
- {"(min-width:500px) 50vw", 250},
- {"(min-width:500px) 200px, 400px", 200},
- {"400px, (min-width:500px) 200px", 400},
- {"(min-width:5000px) 200px, 400px", 400},
- {"(blalbadfsdf) 200px, 400px", 400},
- {"0", 0},
- {"-0", 0},
- {"1", 500},
- {"300px, 400px", 300},
- {"(min-width:5000px) 200px, (min-width:500px) 400px", 400},
- {"", 500},
- {" ", 500},
- {" /**/ ", 500},
- {" /**/ 300px", 300},
- {"300px /**/ ", 300},
- {" /**/ (min-width:500px) /**/ 300px", 300},
- {"-100px, 200px", 200},
- {"-50vw, 20vw", 100},
- {"50asdf, 200px", 200},
- {"asdf, 200px", 200},
- {"(max-width: 3000px) 200w, 400w", 500},
- {",, , /**/ ,200px", 200},
- {"50vw", 250},
- {"calc(40vw*2)", 400},
- {"(min-width:5000px) calc(5000px/10), (min-width:500px) calc(1200px/3)", 400},
- {"(min-width:500px) calc(1200/3)", 500},
- {"(min-width:500px) calc(1200px/(0px*14))", 500},
- {"(max-width: 3000px) 200px, 400px", 200},
- {"(max-width: 3000px) 20em, 40em", 320},
- {"(max-width: 3000px) 0, 40em", 0},
- {"(max-width: 3000px) 50vw, 40em", 250},
- {0, 0} // Do not remove the terminator line.
+ {"screen", 500, true},
+ {"(min-width:500px)", 500, true},
+ {"(min-width:500px) 200px", 200, false},
+ {"(min-width:500px) 50vw", 250, true},
+ {"(min-width:500px) 200px, 400px", 200, false},
+ {"400px, (min-width:500px) 200px", 400, false},
+ {"(min-width:5000px) 200px, 400px", 400, false},
+ {"(blalbadfsdf) 200px, 400px", 400, false},
+ {"0", 0, false},
+ {"-0", 0, false},
+ {"1", 500, true},
+ {"300px, 400px", 300, false},
+ {"(min-width:5000px) 200px, (min-width:500px) 400px", 400, false},
+ {"", 500, true},
+ {" ", 500, true},
+ {" /**/ ", 500, true},
+ {" /**/ 300px", 300, false},
+ {"300px /**/ ", 300, false},
+ {" /**/ (min-width:500px) /**/ 300px", 300, false},
+ {"-100px, 200px", 200, false},
+ {"-50vw, 20vw", 100, true},
+ {"50asdf, 200px", 200, false},
+ {"asdf, 200px", 200, false},
+ {"(max-width: 3000px) 200w, 400w", 500, true},
+ {",, , /**/ ,200px", 200, false},
+ {"50vw", 250, true},
+ {"calc(40vw*2)", 400, true},
+ {"(min-width:5000px) calc(5000px/10), (min-width:500px) calc(1200px/3)", 400, false},
+ {"(min-width:500px) calc(1200/3)", 500, true},
+ {"(min-width:500px) calc(1200px/(0px*14))", 500, true},
+ {"(max-width: 3000px) 200px, 400px", 200, false},
+ {"(max-width: 3000px) 20em, 40em", 320, false},
+ {"(max-width: 3000px) 0, 40em", 0, false},
+ {"(max-width: 3000px) 50vw, 40em", 250, true},
+ {"(max-width: 3000px) 50px, 40vw", 50, false},
+ {0, 0, false} // Do not remove the terminator line.
};
MediaValuesCached::MediaValuesCachedData data;
@@ -73,8 +75,9 @@ TEST(SizesAttributeParserTest, Basic)
RefPtr<MediaValues> mediaValues = MediaValuesCached::create(data);
for (unsigned i = 0; testCases[i].input; ++i) {
- int effectiveSize = SizesAttributeParser::findEffectiveSize(testCases[i].input, mediaValues);
- ASSERT_EQ(testCases[i].output, effectiveSize);
+ SizesAttributeParser parser(mediaValues, testCases[i].input);
+ ASSERT_EQ(testCases[i].effectiveSize, parser.length());
+ ASSERT_EQ(testCases[i].viewportDependant, parser.viewportDependant());
}
}

Powered by Google App Engine
This is Rietveld 408576698