forked from facebook/yoga
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCSSLayoutStyleTest.cpp
More file actions
60 lines (48 loc) · 1.83 KB
/
CSSLayoutStyleTest.cpp
File metadata and controls
60 lines (48 loc) · 1.83 KB
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
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>
TEST(CSSLayoutTest, copy_style_same) {
const CSSNodeRef node0 = CSSNodeNew();
const CSSNodeRef node1 = CSSNodeNew();
ASSERT_FALSE(CSSNodeIsDirty(node0));
CSSNodeCopyStyle(node0, node1);
ASSERT_FALSE(CSSNodeIsDirty(node0));
CSSNodeFree(node0);
CSSNodeFree(node1);
}
TEST(CSSLayoutTest, copy_style_modified) {
const CSSNodeRef node0 = CSSNodeNew();
ASSERT_FALSE(CSSNodeIsDirty(node0));
ASSERT_EQ(CSSFlexDirectionColumn, CSSNodeStyleGetFlexDirection(node0));
ASSERT_TRUE(CSSValueIsUndefined(CSSNodeStyleGetMaxHeight(node0)));
const CSSNodeRef node1 = CSSNodeNew();
CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow);
CSSNodeStyleSetMaxHeight(node1, 10);
CSSNodeCopyStyle(node0, node1);
ASSERT_TRUE(CSSNodeIsDirty(node0));
ASSERT_EQ(CSSFlexDirectionRow, CSSNodeStyleGetFlexDirection(node0));
ASSERT_FLOAT_EQ(10, CSSNodeStyleGetMaxHeight(node0));
CSSNodeFree(node0);
CSSNodeFree(node1);
}
TEST(CSSLayoutTest, copy_style_modified_same) {
const CSSNodeRef node0 = CSSNodeNew();
CSSNodeStyleSetFlexDirection(node0, CSSFlexDirectionRow);
CSSNodeStyleSetMaxHeight(node0, 10);
CSSNodeCalculateLayout(node0, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_FALSE(CSSNodeIsDirty(node0));
const CSSNodeRef node1 = CSSNodeNew();
CSSNodeStyleSetFlexDirection(node1, CSSFlexDirectionRow);
CSSNodeStyleSetMaxHeight(node1, 10);
CSSNodeCopyStyle(node0, node1);
ASSERT_FALSE(CSSNodeIsDirty(node0));
CSSNodeFree(node0);
CSSNodeFree(node1);
}