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

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

Issue 166443003: Move CSSCalcExpressionNode and subclasses to the oilpan heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review feedback Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSCalculationValue.cpp ('k') | Source/wtf/RawPtr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 24 matching lines...) Expand all
35 #include "core/css/CSSToLengthConversionData.h" 35 #include "core/css/CSSToLengthConversionData.h"
36 #include "core/rendering/style/RenderStyle.h" 36 #include "core/rendering/style/RenderStyle.h"
37 #include "core/rendering/style/StyleInheritedData.h" 37 #include "core/rendering/style/StyleInheritedData.h"
38 38
39 #include <gtest/gtest.h> 39 #include <gtest/gtest.h>
40 40
41 using namespace WebCore; 41 using namespace WebCore;
42 42
43 namespace { 43 namespace {
44 44
45 void testExpression(PassRefPtr<CSSCalcExpressionNode> expression, const RenderSt yle* style) 45 void testExpression(PassRefPtrWillBeRawPtr<CSSCalcExpressionNode> expression, co nst RenderStyle* style)
46 { 46 {
47 EXPECT_TRUE( 47 EXPECT_TRUE(
48 expression->equals( 48 expression->equals(
49 *CSSCalcValue::createExpressionNode( 49 *CSSCalcValue::createExpressionNode(
50 expression->toCalcValue(CSSToLengthConversionData(style, style, 0)).get(), 50 expression->toCalcValue(CSSToLengthConversionData(style, style, 0)).get(),
51 style->effectiveZoom()).get())); 51 style->effectiveZoom()).get()));
52 } 52 }
53 53
54 TEST(CSSCalculationValue, CreateExpressionNodeFromLength) 54 TEST(CSSCalculationValue, CreateExpressionNodeFromLength)
55 { 55 {
56 RefPtr<RenderStyle> style = RenderStyle::create(); 56 RefPtr<RenderStyle> style = RenderStyle::create();
57 RefPtr<CSSCalcExpressionNode> expected; 57 RefPtrWillBeRawPtr<CSSCalcExpressionNode> expected;
58 RefPtr<CSSCalcExpressionNode> actual; 58 RefPtrWillBeRawPtr<CSSCalcExpressionNode> actual;
59 59
60 expected = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX), true); 60 expected = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrimitiveValue::CSS_PX), true);
61 actual = CSSCalcValue::createExpressionNode(Length(10, WebCore::Fixed), styl e->effectiveZoom()); 61 actual = CSSCalcValue::createExpressionNode(Length(10, WebCore::Fixed), styl e->effectiveZoom());
62 EXPECT_TRUE(actual->equals(*expected.get())); 62 EXPECT_TRUE(actual->equals(*expected.get()));
63 63
64 expected = CSSCalcValue::createExpressionNode( 64 expected = CSSCalcValue::createExpressionNode(
65 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrim itiveValue::CSS_PX), true), 65 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrim itiveValue::CSS_PX), true),
66 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(20, CSSPrim itiveValue::CSS_PX), true), 66 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(20, CSSPrim itiveValue::CSS_PX), true),
67 CalcAdd); 67 CalcAdd);
68 actual = CSSCalcValue::createExpressionNode( 68 actual = CSSCalcValue::createExpressionNode(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 actual = CSSCalcValue::createExpressionNode( 102 actual = CSSCalcValue::createExpressionNode(
103 Length(CalculationValue::create( 103 Length(CalculationValue::create(
104 adoptPtr(new CalcExpressionBlendLength(Length(50, WebCore::Fixed), L ength(60, WebCore::Fixed), 0.75)), 104 adoptPtr(new CalcExpressionBlendLength(Length(50, WebCore::Fixed), L ength(60, WebCore::Fixed), 0.75)),
105 ValueRangeAll)), 105 ValueRangeAll)),
106 style->effectiveZoom()); 106 style->effectiveZoom());
107 EXPECT_TRUE(actual->equals(*expected.get())); 107 EXPECT_TRUE(actual->equals(*expected.get()));
108 } 108 }
109 109
110 TEST(CSSCalculationValue, CreateExpressionNodeFromLengthFromExpressionNode) 110 TEST(CSSCalculationValue, CreateExpressionNodeFromLengthFromExpressionNode)
111 { 111 {
112 RefPtr<CSSCalcExpressionNode> expression; 112 RefPtrWillBeRawPtr<CSSCalcExpressionNode> expression;
113 RefPtr<RenderStyle> style = RenderStyle::createDefaultStyle(); 113 RefPtr<RenderStyle> style = RenderStyle::createDefaultStyle();
114 style->setEffectiveZoom(5); 114 style->setEffectiveZoom(5);
115 115
116 testExpression( 116 testExpression(
117 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrim itiveValue::CSS_PX), true), 117 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSSPrim itiveValue::CSS_PX), true),
118 style.get()); 118 style.get());
119 119
120 testExpression( 120 testExpression(
121 CSSCalcValue::createExpressionNode( 121 CSSCalcValue::createExpressionNode(
122 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSS PrimitiveValue::CSS_PX), true), 122 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(10, CSS PrimitiveValue::CSS_PX), true),
(...skipping 16 matching lines...) Expand all
139 CalcMultiply), 139 CalcMultiply),
140 CSSCalcValue::createExpressionNode( 140 CSSCalcValue::createExpressionNode(
141 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(60, CSSPrimitiveValue::CSS_PX), true), 141 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(60, CSSPrimitiveValue::CSS_PX), true),
142 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(0.7 5, CSSPrimitiveValue::CSS_NUMBER), false), 142 CSSCalcValue::createExpressionNode(CSSPrimitiveValue::create(0.7 5, CSSPrimitiveValue::CSS_NUMBER), false),
143 CalcMultiply), 143 CalcMultiply),
144 CalcAdd), 144 CalcAdd),
145 style.get()); 145 style.get());
146 } 146 }
147 147
148 } 148 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSCalculationValue.cpp ('k') | Source/wtf/RawPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698