-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
computed_style_property_map_test.cc
82 lines (71 loc) · 3.32 KB
/
computed_style_property_map_test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/css/cssom/computed_style_property_map.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/css/cssom/css_unit_value.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
namespace blink {
class ComputedStylePropertyMapTest : public PageTestBase {
public:
ComputedStylePropertyMapTest() = default;
protected:
ComputedStylePropertyMap* SetBodyStyle(const char* style) {
GetDocument().body()->setAttribute(html_names::kStyleAttr,
AtomicString(style));
UpdateAllLifecyclePhasesForTest();
return MakeGarbageCollected<ComputedStylePropertyMap>(GetDocument().body());
}
};
TEST_F(ComputedStylePropertyMapTest, TransformMatrixZoom) {
ComputedStylePropertyMap* map =
SetBodyStyle("transform:matrix(1, 0, 0, 1, 100, 100);zoom:2");
CSSStyleValue* style_value = map->get(GetDocument().GetExecutionContext(),
"transform", ASSERT_NO_EXCEPTION);
ASSERT_TRUE(style_value);
EXPECT_EQ("matrix(1, 0, 0, 1, 100, 100)", style_value->toString());
}
TEST_F(ComputedStylePropertyMapTest, TransformMatrix3DZoom) {
ComputedStylePropertyMap* map = SetBodyStyle(
"transform:matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 100, 100, "
"1);zoom:2");
CSSStyleValue* style_value = map->get(GetDocument().GetExecutionContext(),
"transform", ASSERT_NO_EXCEPTION);
ASSERT_TRUE(style_value);
EXPECT_EQ("matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 100, 100, 1)",
style_value->toString());
}
TEST_F(ComputedStylePropertyMapTest, TransformPerspectiveZoom) {
ComputedStylePropertyMap* map =
SetBodyStyle("transform:perspective(100px);zoom:2");
CSSStyleValue* style_value = map->get(GetDocument().GetExecutionContext(),
"transform", ASSERT_NO_EXCEPTION);
ASSERT_TRUE(style_value);
EXPECT_EQ("perspective(100px)", style_value->toString());
}
TEST_F(ComputedStylePropertyMapTest, TopWithAnchorComputed) {
ComputedStylePropertyMap* map =
SetBodyStyle("position: absolute; top: anchor(bottom, 17px);");
CSSStyleValue* style_value =
map->get(GetDocument().GetExecutionContext(), "top", ASSERT_NO_EXCEPTION);
ASSERT_TRUE(style_value);
CSSUnitValue* unit_value = DynamicTo<CSSUnitValue>(style_value);
ASSERT_TRUE(unit_value);
EXPECT_EQ(17.0, unit_value->value());
EXPECT_EQ("px", unit_value->unit());
}
TEST_F(ComputedStylePropertyMapTest, BackgroundImageGradientCurrentColor) {
ComputedStylePropertyMap* map = SetBodyStyle(
"background-image: linear-gradient(-45deg, rgb(255, 0, 0), "
"currentcolor)");
CSSStyleValue* style_value =
map->get(GetDocument().GetExecutionContext(), "background-image",
ASSERT_NO_EXCEPTION);
ASSERT_TRUE(style_value);
String computed_string = style_value->toString();
EXPECT_EQ("linear-gradient(-45deg, rgb(255, 0, 0), currentcolor)",
computed_string);
}
} // namespace blink