summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/css/cssom/computed_style_property_map_test.cc
blob: 946ad25258d42e9712f34edc27e28087fd0b0a8c (plain)
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
// Copyright 2020 The Chromium Authors. All rights reserved.
// 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/html/html_element.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"

namespace blink {

class ComputedStylePropertyMapTest : public PageTestBase {
 public:
  ComputedStylePropertyMapTest() = default;

 protected:
  ComputedStylePropertyMap* SetBodyStyle(const AtomicString& style) {
    GetDocument().body()->setAttribute(html_names::kStyleAttr, 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());
}

}  // namespace blink