OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/css/StyleSheetContents.h" | 5 #include "core/css/StyleSheetContents.h" |
6 | 6 |
7 #include "core/css/CSSTestHelper.h" | 7 #include "core/css/CSSTestHelper.h" |
8 #include "core/css/parser/CSSParser.h" | 8 #include "core/css/parser/CSSParser.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 TEST(StyleSheetContentsTest, InsertMediaRule) | 13 TEST(StyleSheetContentsTest, InsertMediaRule) |
14 { | 14 { |
15 CSSParserContext context(HTMLStandardMode, nullptr); | 15 CSSParserContext context(HTMLStandardMode, nullptr); |
16 | 16 |
17 RawPtr<StyleSheetContents> styleSheet = StyleSheetContents::create(context); | 17 StyleSheetContents* styleSheet = StyleSheetContents::create(context); |
18 styleSheet->parseString("@namespace ns url(test);"); | 18 styleSheet->parseString("@namespace ns url(test);"); |
19 EXPECT_EQ(1U, styleSheet->ruleCount()); | 19 EXPECT_EQ(1U, styleSheet->ruleCount()); |
20 | 20 |
21 styleSheet->setMutable(); | 21 styleSheet->setMutable(); |
22 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet.get()
, "@media all { div { color: pink } }"), 0); | 22 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet, "@me
dia all { div { color: pink } }"), 0); |
23 EXPECT_EQ(1U, styleSheet->ruleCount()); | 23 EXPECT_EQ(1U, styleSheet->ruleCount()); |
24 EXPECT_FALSE(styleSheet->hasMediaQueries()); | 24 EXPECT_FALSE(styleSheet->hasMediaQueries()); |
25 | 25 |
26 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet.get()
, "@media all { div { color: green } }"), 1); | 26 styleSheet->wrapperInsertRule(CSSParser::parseRule(context, styleSheet, "@me
dia all { div { color: green } }"), 1); |
27 EXPECT_EQ(2U, styleSheet->ruleCount()); | 27 EXPECT_EQ(2U, styleSheet->ruleCount()); |
28 EXPECT_TRUE(styleSheet->hasMediaQueries()); | 28 EXPECT_TRUE(styleSheet->hasMediaQueries()); |
29 } | 29 } |
30 | 30 |
31 } // namespace blink | 31 } // namespace blink |
OLD | NEW |