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

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

Issue 308733005: Fix assert on unknown rule type in the BisonCSSParser::endRuleHeader. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « Source/core/css/CSSGrammar.y ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/BisonCSSParserTest.cpp
diff --git a/Source/core/css/parser/BisonCSSParserTest.cpp b/Source/core/css/parser/BisonCSSParserTest.cpp
index cad841b2f9367b26557f03cdc158360bee62c45f..1a8b3f085c7c25800807d9a8022165ce66d18629 100644
--- a/Source/core/css/parser/BisonCSSParserTest.cpp
+++ b/Source/core/css/parser/BisonCSSParserTest.cpp
@@ -6,7 +6,10 @@
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSTimingFunctionValue.h"
+#include "core/css/MediaList.h"
+#include "core/css/StyleRule.h"
#include "platform/animation/TimingFunction.h"
+#include "wtf/dtoa/utils.h"
#include <gtest/gtest.h>
@@ -64,4 +67,45 @@ TEST(BisonCSSParserTest, ParseAnimationTimingFunctionValue)
EXPECT_EQ(0, timingFunctionValue.get());
}
+static void testMediaQuery(const char* expected, MediaQuerySet& querySet)
+{
+ const WillBeHeapVector<OwnPtrWillBeMember<MediaQuery> >& queryVector = querySet.queryVector();
+ size_t queryVectorSize = queryVector.size();
+ StringBuilder output;
+
+ for (size_t i = 0; i < queryVectorSize; ) {
+ String queryText = queryVector[i]->cssText();
+ output.append(queryText);
+ ++i;
+ if (i >= queryVectorSize)
+ break;
+ output.append(", ");
+ }
+ ASSERT_STREQ(expected, output.toString().ascii().data());
+}
+
+TEST(BisonCSSParserTest, MediaQuery)
+{
+ struct {
+ const char* input;
+ const char* output;
+ } testCases[] = {
+ {"@media s} {}", "not all"},
+ {"@media } {}", "not all"},
+ {"@media tv {}", "tv"},
+ {"@media tv, screen {}", "tv, screen"},
+ {"@media s}, tv {}", "not all, tv"},
+ {"@media tv, screen and (}) {}", "tv, not all"},
+ };
+
+ BisonCSSParser parser(strictCSSParserContext());
+
+ for (unsigned i = 0; i < ARRAY_SIZE(testCases); ++i) {
+ RefPtrWillBeRawPtr<StyleRuleBase> rule = parser.parseRule(nullptr, String(testCases[i].input));
+
+ EXPECT_TRUE(rule->isMediaRule());
+ testMediaQuery(testCases[i].output, *static_cast<StyleRuleMedia*>(rule.get())->mediaQueries());
+ }
+}
+
} // namespace blink
« no previous file with comments | « Source/core/css/CSSGrammar.y ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698