| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |