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/CSSPageRule.h" | 5 #include "core/css/CSSPageRule.h" |
6 | 6 |
7 #include "core/css/CSSRuleList.h" | 7 #include "core/css/CSSRuleList.h" |
8 #include "core/css/CSSTestHelper.h" | 8 #include "core/css/CSSTestHelper.h" |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 if (CSSPageRule* pageRule = toCSSPageRule(helper.cssRules()->item(0))) | 23 if (CSSPageRule* pageRule = toCSSPageRule(helper.cssRules()->item(0))) |
24 EXPECT_EQ(":left", pageRule->selectorText()); | 24 EXPECT_EQ(":left", pageRule->selectorText()); |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 TEST(CSSPageRule, selectorText) { | 28 TEST(CSSPageRule, selectorText) { |
29 CSSTestHelper helper; | 29 CSSTestHelper helper; |
30 | 30 |
31 const char* cssRule = "@page :left { size: auto; }"; | 31 const char* cssRule = "@page :left { size: auto; }"; |
32 helper.addCSSRules(cssRule); | 32 helper.addCSSRules(cssRule); |
33 ASSERT(helper.cssRules()); | 33 DCHECK(helper.cssRules()); |
34 EXPECT_EQ(1u, helper.cssRules()->length()); | 34 EXPECT_EQ(1u, helper.cssRules()->length()); |
35 | 35 |
36 CSSPageRule* pageRule = toCSSPageRule(helper.cssRules()->item(0)); | 36 CSSPageRule* pageRule = toCSSPageRule(helper.cssRules()->item(0)); |
37 EXPECT_EQ(":left", pageRule->selectorText()); | 37 EXPECT_EQ(":left", pageRule->selectorText()); |
38 | 38 |
39 // set invalid page selector. | 39 // set invalid page selector. |
40 pageRule->setSelectorText(":hover"); | 40 pageRule->setSelectorText(":hover"); |
41 EXPECT_EQ(":left", pageRule->selectorText()); | 41 EXPECT_EQ(":left", pageRule->selectorText()); |
42 | 42 |
43 // set invalid page selector. | 43 // set invalid page selector. |
44 pageRule->setSelectorText("right { bla"); | 44 pageRule->setSelectorText("right { bla"); |
45 EXPECT_EQ(":left", pageRule->selectorText()); | 45 EXPECT_EQ(":left", pageRule->selectorText()); |
46 | 46 |
47 // set page pseudo class selector. | 47 // set page pseudo class selector. |
48 pageRule->setSelectorText(":right"); | 48 pageRule->setSelectorText(":right"); |
49 EXPECT_EQ(":right", pageRule->selectorText()); | 49 EXPECT_EQ(":right", pageRule->selectorText()); |
50 | 50 |
51 // set page type selector. | 51 // set page type selector. |
52 pageRule->setSelectorText("namedpage"); | 52 pageRule->setSelectorText("namedpage"); |
53 EXPECT_EQ("namedpage", pageRule->selectorText()); | 53 EXPECT_EQ("namedpage", pageRule->selectorText()); |
54 } | 54 } |
55 | 55 |
56 } // namespace blink | 56 } // namespace blink |
OLD | NEW |