| 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/cssom/CSSUnparsedValue.h" | 5 #include "core/css/cssom/CSSUnparsedValue.h" |
| 6 | 6 |
| 7 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" | 7 #include "core/css/cssom/CSSStyleVariableReferenceValue.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 CSSUnparsedValue* unparsedValueFromCSSVariableReferenceValue( | 14 CSSUnparsedValue* unparsedValueFromCSSVariableReferenceValue( |
| 15 CSSStyleVariableReferenceValue* variableReferenceValue) { | 15 CSSStyleVariableReferenceValue* variableReferenceValue) { |
| 16 HeapVector<StringOrCSSVariableReferenceValue> fragments; | 16 HeapVector<StringOrCSSVariableReferenceValue> fragments; |
| 17 fragments.append( | 17 fragments.push_back( |
| 18 StringOrCSSVariableReferenceValue::fromCSSVariableReferenceValue( | 18 StringOrCSSVariableReferenceValue::fromCSSVariableReferenceValue( |
| 19 variableReferenceValue)); | 19 variableReferenceValue)); |
| 20 return CSSUnparsedValue::create(fragments); | 20 return CSSUnparsedValue::create(fragments); |
| 21 } | 21 } |
| 22 | 22 |
| 23 } // namespace | 23 } // namespace |
| 24 | 24 |
| 25 TEST(CSSUnparsedValueTest, EmptyList) { | 25 TEST(CSSUnparsedValueTest, EmptyList) { |
| 26 HeapVector<StringOrCSSVariableReferenceValue> fragments; | 26 HeapVector<StringOrCSSVariableReferenceValue> fragments; |
| 27 CSSUnparsedValue* unparsedValue = CSSUnparsedValue::create(fragments); | 27 CSSUnparsedValue* unparsedValue = CSSUnparsedValue::create(fragments); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 58 EXPECT_EQ(unparsedValue->fragmentAtIndex(0).getAsCSSVariableReferenceValue(), | 58 EXPECT_EQ(unparsedValue->fragmentAtIndex(0).getAsCSSVariableReferenceValue(), |
| 59 variableReferenceValue); | 59 variableReferenceValue); |
| 60 } | 60 } |
| 61 | 61 |
| 62 TEST(CSSUnparsedValueTest, MixedList) { | 62 TEST(CSSUnparsedValueTest, MixedList) { |
| 63 CSSStyleVariableReferenceValue* variableReferenceValue = | 63 CSSStyleVariableReferenceValue* variableReferenceValue = |
| 64 CSSStyleVariableReferenceValue::create( | 64 CSSStyleVariableReferenceValue::create( |
| 65 "Ref", CSSUnparsedValue::fromString("string")); | 65 "Ref", CSSUnparsedValue::fromString("string")); |
| 66 | 66 |
| 67 HeapVector<StringOrCSSVariableReferenceValue> fragments; | 67 HeapVector<StringOrCSSVariableReferenceValue> fragments; |
| 68 fragments.append(StringOrCSSVariableReferenceValue::fromString("string")); | 68 fragments.push_back(StringOrCSSVariableReferenceValue::fromString("string")); |
| 69 fragments.append( | 69 fragments.push_back( |
| 70 StringOrCSSVariableReferenceValue::fromCSSVariableReferenceValue( | 70 StringOrCSSVariableReferenceValue::fromCSSVariableReferenceValue( |
| 71 variableReferenceValue)); | 71 variableReferenceValue)); |
| 72 fragments.append(StringOrCSSVariableReferenceValue()); | 72 fragments.push_back(StringOrCSSVariableReferenceValue()); |
| 73 | 73 |
| 74 CSSUnparsedValue* unparsedValue = CSSUnparsedValue::create(fragments); | 74 CSSUnparsedValue* unparsedValue = CSSUnparsedValue::create(fragments); |
| 75 | 75 |
| 76 EXPECT_EQ(unparsedValue->size(), fragments.size()); | 76 EXPECT_EQ(unparsedValue->size(), fragments.size()); |
| 77 | 77 |
| 78 EXPECT_TRUE(unparsedValue->fragmentAtIndex(0).isString()); | 78 EXPECT_TRUE(unparsedValue->fragmentAtIndex(0).isString()); |
| 79 EXPECT_FALSE(unparsedValue->fragmentAtIndex(0).isCSSVariableReferenceValue()); | 79 EXPECT_FALSE(unparsedValue->fragmentAtIndex(0).isCSSVariableReferenceValue()); |
| 80 EXPECT_EQ(unparsedValue->fragmentAtIndex(0).getAsString(), "string"); | 80 EXPECT_EQ(unparsedValue->fragmentAtIndex(0).getAsString(), "string"); |
| 81 | 81 |
| 82 EXPECT_TRUE(unparsedValue->fragmentAtIndex(1).isCSSVariableReferenceValue()); | 82 EXPECT_TRUE(unparsedValue->fragmentAtIndex(1).isCSSVariableReferenceValue()); |
| 83 EXPECT_FALSE(unparsedValue->fragmentAtIndex(1).isString()); | 83 EXPECT_FALSE(unparsedValue->fragmentAtIndex(1).isString()); |
| 84 EXPECT_EQ(unparsedValue->fragmentAtIndex(1).getAsCSSVariableReferenceValue(), | 84 EXPECT_EQ(unparsedValue->fragmentAtIndex(1).getAsCSSVariableReferenceValue(), |
| 85 variableReferenceValue); | 85 variableReferenceValue); |
| 86 | 86 |
| 87 EXPECT_TRUE(unparsedValue->fragmentAtIndex(2).isNull()); | 87 EXPECT_TRUE(unparsedValue->fragmentAtIndex(2).isNull()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace blink | 90 } // namespace blink |
| OLD | NEW |