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

Side by Side Diff: Source/core/css/CSSValueTest.cpp

Issue 1164573002: CSSValue Immediates: Change CSSValue to an object instead of a pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « Source/core/css/CSSValuePool.cpp ('k') | Source/core/css/CSSValueTestHelper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/css/CSSValue.h"
7
8 #include "core/css/CSSPrimitiveValue.h"
9 #include "core/css/CSSValueTestHelper.h"
10 #include <gtest/gtest.h>
11
12 using namespace blink;
13
14 namespace {
15
16 // Helper functions since PassRefPtrWillBeRawPtr cannot be a member variable.
17 CSSValue makeCSSValueWithPassRefPtr(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> pr imitiveValue)
18 {
19 return CSSValue(primitiveValue);
20 }
21 NullableCSSValue makeNullableCSSValueWithPassRefPtr(PassRefPtrWillBeRawPtr<CSSPr imitiveValue> primitiveValue)
22 {
23 return NullableCSSValue(primitiveValue);
24 }
25
26 TEST(CSSValueTest, CSSValueTest)
27 {
28 RefPtrWillBeRawPtr<CSSPrimitiveValue> primitiveValueRef = CSSPrimitiveValue: :createIdentifier(CSSValueBold);
29
30 CSSValue passRefPtrConstructor = makeCSSValueWithPassRefPtr(CSSPrimitiveValu e::createIdentifier(CSSValueBold));
31 EXPECT_STREQ("bold", passRefPtrConstructor.cssText().utf8().data());
32
33 CSSValue refPtrConstructor(primitiveValueRef);
34 EXPECT_STREQ("bold", refPtrConstructor.cssText().utf8().data());
35
36 CSSValue copyConstructor(refPtrConstructor);
37 EXPECT_STREQ("bold", copyConstructor.cssText().utf8().data());
38
39 CSSValue constCopyConstructor(*const_cast<const CSSValue*>(&refPtrConstructo r));
40 EXPECT_STREQ("bold", constCopyConstructor.cssText().utf8().data());
41
42 CSSValue newAssignmentOperator = refPtrConstructor;
43 EXPECT_STREQ("bold", newAssignmentOperator.cssText().utf8().data());
44 EXPECT_STREQ("bold", refPtrConstructor.cssText().utf8().data());
45
46 CSSValue existingAssignmentOperator(primitiveValueRef);
47 existingAssignmentOperator = passRefPtrConstructor;
48 EXPECT_STREQ("bold", existingAssignmentOperator.cssText().utf8().data());
49 EXPECT_STREQ("bold", refPtrConstructor.cssText().utf8().data());
50
51 CSSValue selfAssignmentOperator(primitiveValueRef);
52 selfAssignmentOperator = refPtrConstructor;
53 EXPECT_STREQ("bold", selfAssignmentOperator.cssText().utf8().data());
54 EXPECT_STREQ("bold", refPtrConstructor.cssText().utf8().data());
55 }
56
57 TEST(CSSValueTest, NullableCSSValueTest)
58 {
59 RefPtrWillBeRawPtr<CSSPrimitiveValue> primitiveValueRef = CSSPrimitiveValue: :createIdentifier(CSSValueBold);
60
61 NullableCSSValue defaultConstructor;
62 EXPECT_FALSE(defaultConstructor);
63
64 NullableCSSValue nullPtrConstructor(nullptr);
65 EXPECT_FALSE(nullPtrConstructor);
66
67 NullableCSSValue passRefPtrConstructor = makeNullableCSSValueWithPassRefPtr( CSSPrimitiveValue::createIdentifier(CSSValueBold));
68 EXPECT_STREQ("bold", passRefPtrConstructor->cssText().utf8().data());
69
70 NullableCSSValue refPtrConstructor(primitiveValueRef);
71 EXPECT_STREQ("bold", refPtrConstructor->cssText().utf8().data());
72
73 NullableCSSValue copyConstructor(refPtrConstructor);
74 EXPECT_STREQ("bold", copyConstructor->cssText().utf8().data());
75
76 NullableCSSValue constCopyConstructor(*const_cast<const NullableCSSValue*>(& refPtrConstructor));
77 EXPECT_STREQ("bold", constCopyConstructor->cssText().utf8().data());
78
79 NullableCSSValue nullCopyConstructor(nullPtrConstructor);
80 EXPECT_FALSE(nullCopyConstructor);
81
82 NullableCSSValue nullConstCopyConstructor(*const_cast<const NullableCSSValue *>(&nullPtrConstructor));
83 EXPECT_FALSE(nullConstCopyConstructor);
84
85 CSSValue cssValue(primitiveValueRef);
86 NullableCSSValue cssValueCopyConstructor(cssValue);
87 EXPECT_STREQ("bold", cssValueCopyConstructor->cssText().utf8().data());
88
89 const CSSValue constCssValue(primitiveValueRef);
90 NullableCSSValue constCssValueCopyConstructor(constCssValue);
91 EXPECT_STREQ("bold", constCssValueCopyConstructor->cssText().utf8().data());
92 }
93
94 } // namespace
OLDNEW
« no previous file with comments | « Source/core/css/CSSValuePool.cpp ('k') | Source/core/css/CSSValueTestHelper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698