Skip to content

Commit 5805562

Browse files
align items tests
1 parent d9d1c85 commit 5805562

36 files changed

Lines changed: 4551 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- https://github.com/DioxusLabs/taffy/blob/3cc24a253541875779d524c4c86b9d1bc8660ddf/test_fixtures/grid/grid_align_content_space_evenly_with_padding_border.html -->
2+
3+
<div id="grid_align_content_space_evenly_with_padding_border" style="height: 200px; width: 200px; display: grid; grid-template-columns: 40px 40px 40px; grid-template-rows: 40px 40px 40px; align-content: space-evenly; padding: 10px 20px 30px 40px; border-width: 2px 4px 6px 8px;">
4+
<div></div>
5+
<div></div>
6+
<div></div>
7+
<div></div>
8+
<div></div>
9+
<div></div>
10+
<div></div>
11+
<div></div>
12+
<div></div>
13+
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- https://github.com/DioxusLabs/taffy/blob/3cc24a253541875779d524c4c86b9d1bc8660ddf/test_fixtures/grid/grid_align_content_start.html -->
2+
3+
<div id="grid_align_content_start" style="height: 200px; width: 200px; display: grid; grid-template-columns: 40px 40px 40px; grid-template-rows: 40px 40px 40px; align-content: start;">
4+
<div></div>
5+
<div></div>
6+
<div></div>
7+
<div></div>
8+
<div></div>
9+
<div></div>
10+
<div></div>
11+
<div></div>
12+
<div></div>
13+
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- https://github.com/DioxusLabs/taffy/blob/3cc24a253541875779d524c4c86b9d1bc86660ddf/test_fixtures/grid/grid_align_content_start_negative_space_gap.html -->
2+
3+
<div id="grid_align_content_start_negative_space_gap" style="display: grid; width: 240px; height: 240px; border-width: 60px;">
4+
<div id="grid_align_content_start_negative_space_gap_inner" style="height: 120px; width: 120px; display: grid; grid-template-columns: 20px 20px 20px; grid-template-rows: 40px 40px 40px; justify-content: center; align-content: start; gap: 10px;">
5+
<div></div>
6+
<div></div>
7+
<div></div>
8+
<div></div>
9+
<div></div>
10+
<div></div>
11+
<div></div>
12+
<div></div>
13+
<div></div>
14+
</div>
15+
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- https://github.com/DioxusLabs/taffy/blob/3cc24a253541875779d524c4c86b9d1bc8660ddf/test_fixtures/grid/grid_align_content_start_with_padding_border.html -->
2+
3+
<div id="grid_align_content_start_with_padding_border" style="height: 200px; width: 200px; display: grid; grid-template-columns: 40px 40px 40px; grid-template-rows: 40px 40px 40px; align-content: start; padding: 10px 20px 30px 40px; border-width: 2px 4px 6px 8px;">
4+
<div></div>
5+
<div></div>
6+
<div></div>
7+
<div></div>
8+
<div></div>
9+
<div></div>
10+
<div></div>
11+
<div></div>
12+
<div></div>
13+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- https://github.com/DioxusLabs/taffy/blob/3cc24a253541875779d524c4c86b9d1bc8660ddf/test_fixtures/grid/grid_align_items_sized_center.html -->
2+
3+
<div id="grid_align_items_sized_center" style="height: 120px; width: 120px; display: grid; grid-template-columns: 40px 40px 40px; grid-template-rows: 40px 40px 40px; align-items: center;">
4+
<div style="width: 20px; height: 20px; grid-row: 1; grid-column: 1;"></div>
5+
<div style="width: 60px; height: 60px; grid-row: 3; grid-column: 3;"></div>
6+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- https://github.com/DioxusLabs/taffy/blob/3cc24a253541875779d524c4c86b9d1bc8660ddf/test_fixtures/grid/grid_align_items_sized_end.html -->
2+
3+
<div id="grid_align_items_sized_end" style="height: 120px; width: 120px; display: grid; grid-template-columns: 40px 40px 40px; grid-template-rows: 40px 40px 40px; align-items: end;">
4+
<div style="width: 20px; height: 20px; grid-row: 1; grid-column: 1;"></div>
5+
<div style="width: 60px; height: 60px; grid-row: 3; grid-column: 3;"></div>
6+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- https://github.com/DioxusLabs/taffy/blob/3cc24a253541875779d524c4c86b9d1bc8660ddf/test_fixtures/grid/grid_align_items_sized_start.html -->
2+
3+
<div id="grid_align_items_sized_start" style="height: 120px; width: 120px; display: grid; grid-template-columns: 40px 40px 40px; grid-template-rows: 40px 40px 40px; align-items: start;">
4+
<div style="width: 20px; height: 20px; grid-row: 1; grid-column: 1;"></div>
5+
<div style="width: 60px; height: 60px; grid-row: 3; grid-column: 3;"></div>
6+
</div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- https://github.com/DioxusLabs/taffy/blob/3cc24a253541875779d524c4c86b9d1bc8660ddf/test_fixtures/grid/grid_align_items_sized_stretch.html -->
2+
3+
<div id="grid_align_items_sized_stretch" style="height: 120px; width: 120px; display: grid; grid-template-columns: 40px 40px 40px; grid-template-rows: 40px 40px 40px; align-items: stretch;">
4+
<div style="width: 20px; height: 20px; grid-row: 1; grid-column: 1;"></div>
5+
<div style="width: 60px; height: 60px; grid-row: 3; grid-column: 3;"></div>
6+
</div>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- https://github.com/DioxusLabs/taffy/blob/3cc24a253541875779d524c4c86b9d1bc8660ddf/test_fixtures/grid/grid_align_self_sized_all.html -->
2+
3+
<div id="grid_align_self_sized_all" style="height: 120px; width: 120px; display: grid; grid-template-columns: 40px 40px 40px; grid-template-rows: 40px 40px 40px;">
4+
<div style="width: 20px; height: 20px; align-self: start;"></div>
5+
<div style="width: 60px; height: 60px; align-self: start;"></div>
6+
<div style="width: 20px; height: 20px; align-self: end;"></div>
7+
<div style="width: 60px; height: 60px; align-self: end;"></div>
8+
<div style="width: 20px; height: 20px; align-self: center;"></div>
9+
<div style="width: 60px; height: 60px; align-self: center;"></div>
10+
<div style="width: 20px; height: 20px; align-self: stretch;"></div>
11+
<div style="width: 60px; height: 60px; align-self: stretch;"></div>
12+
</div>
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @generated SignedSource<<ce9f7f93536e52e63e409874ac2f0fc0>>
8+
* generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly_with_padding_border.html
9+
*/
10+
11+
package com.facebook.yoga;
12+
13+
import static org.junit.Assert.assertEquals;
14+
15+
import org.junit.Ignore;
16+
import org.junit.Test;
17+
import org.junit.runner.RunWith;
18+
import org.junit.runners.Parameterized;
19+
import com.facebook.yoga.utils.TestUtils;
20+
21+
@RunWith(Parameterized.class)
22+
public class grid_align_content_space_evenly_with_padding_border {
23+
@Parameterized.Parameters(name = "{0}")
24+
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
25+
return TestParametrization.nodeFactories();
26+
}
27+
28+
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
29+
30+
@Test
31+
public void test_grid_align_content_space_evenly_with_padding_border() {
32+
YogaConfig config = YogaConfigFactory.create();
33+
34+
final YogaNode root = createNode(config);
35+
root.setAlignContent(YogaAlign.SPACE_EVENLY);
36+
root.setPositionType(YogaPositionType.ABSOLUTE);
37+
root.setPadding(YogaEdge.LEFT, 40);
38+
root.setPadding(YogaEdge.TOP, 10);
39+
root.setPadding(YogaEdge.RIGHT, 20);
40+
root.setPadding(YogaEdge.BOTTOM, 30);
41+
root.setBorder(YogaEdge.LEFT, 8f);
42+
root.setBorder(YogaEdge.TOP, 2f);
43+
root.setBorder(YogaEdge.RIGHT, 4f);
44+
root.setBorder(YogaEdge.BOTTOM, 6f);
45+
root.setWidth(200f);
46+
root.setHeight(200f);
47+
root.setDisplay(YogaDisplay.GRID);
48+
YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList();
49+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
50+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
51+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
52+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
53+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
54+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
55+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
56+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
57+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
58+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
59+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
60+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
61+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
62+
rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto());
63+
root.setGridTemplateColumns(rootGridTemplateColumns);
64+
YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList();
65+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
66+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
67+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
68+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
69+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
70+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
71+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
72+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
73+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
74+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
75+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
76+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
77+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
78+
rootGridTemplateRows.addTrack(YogaGridTrackValue.auto());
79+
root.setGridTemplateRows(rootGridTemplateRows);
80+
81+
final YogaNode root_child0 = createNode(config);
82+
root.addChildAt(root_child0, 0);
83+
84+
final YogaNode root_child1 = createNode(config);
85+
root.addChildAt(root_child1, 1);
86+
87+
final YogaNode root_child2 = createNode(config);
88+
root.addChildAt(root_child2, 2);
89+
90+
final YogaNode root_child3 = createNode(config);
91+
root.addChildAt(root_child3, 3);
92+
93+
final YogaNode root_child4 = createNode(config);
94+
root.addChildAt(root_child4, 4);
95+
96+
final YogaNode root_child5 = createNode(config);
97+
root.addChildAt(root_child5, 5);
98+
99+
final YogaNode root_child6 = createNode(config);
100+
root.addChildAt(root_child6, 6);
101+
102+
final YogaNode root_child7 = createNode(config);
103+
root.addChildAt(root_child7, 7);
104+
105+
final YogaNode root_child8 = createNode(config);
106+
root.addChildAt(root_child8, 8);
107+
root.setDirection(YogaDirection.LTR);
108+
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
109+
110+
assertEquals(0f, root.getLayoutX(), 0.0f);
111+
assertEquals(0f, root.getLayoutY(), 0.0f);
112+
assertEquals(200f, root.getLayoutWidth(), 0.0f);
113+
assertEquals(200f, root.getLayoutHeight(), 0.0f);
114+
115+
assertEquals(48f, root_child0.getLayoutX(), 0.0f);
116+
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
117+
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
118+
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
119+
120+
assertEquals(88f, root_child1.getLayoutX(), 0.0f);
121+
assertEquals(20f, root_child1.getLayoutY(), 0.0f);
122+
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
123+
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
124+
125+
assertEquals(128f, root_child2.getLayoutX(), 0.0f);
126+
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
127+
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
128+
assertEquals(40f, root_child2.getLayoutHeight(), 0.0f);
129+
130+
assertEquals(48f, root_child3.getLayoutX(), 0.0f);
131+
assertEquals(68f, root_child3.getLayoutY(), 0.0f);
132+
assertEquals(40f, root_child3.getLayoutWidth(), 0.0f);
133+
assertEquals(40f, root_child3.getLayoutHeight(), 0.0f);
134+
135+
assertEquals(88f, root_child4.getLayoutX(), 0.0f);
136+
assertEquals(68f, root_child4.getLayoutY(), 0.0f);
137+
assertEquals(40f, root_child4.getLayoutWidth(), 0.0f);
138+
assertEquals(40f, root_child4.getLayoutHeight(), 0.0f);
139+
140+
assertEquals(128f, root_child5.getLayoutX(), 0.0f);
141+
assertEquals(68f, root_child5.getLayoutY(), 0.0f);
142+
assertEquals(40f, root_child5.getLayoutWidth(), 0.0f);
143+
assertEquals(40f, root_child5.getLayoutHeight(), 0.0f);
144+
145+
assertEquals(48f, root_child6.getLayoutX(), 0.0f);
146+
assertEquals(116f, root_child6.getLayoutY(), 0.0f);
147+
assertEquals(40f, root_child6.getLayoutWidth(), 0.0f);
148+
assertEquals(40f, root_child6.getLayoutHeight(), 0.0f);
149+
150+
assertEquals(88f, root_child7.getLayoutX(), 0.0f);
151+
assertEquals(116f, root_child7.getLayoutY(), 0.0f);
152+
assertEquals(40f, root_child7.getLayoutWidth(), 0.0f);
153+
assertEquals(40f, root_child7.getLayoutHeight(), 0.0f);
154+
155+
assertEquals(128f, root_child8.getLayoutX(), 0.0f);
156+
assertEquals(116f, root_child8.getLayoutY(), 0.0f);
157+
assertEquals(40f, root_child8.getLayoutWidth(), 0.0f);
158+
assertEquals(40f, root_child8.getLayoutHeight(), 0.0f);
159+
160+
root.setDirection(YogaDirection.RTL);
161+
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
162+
163+
assertEquals(0f, root.getLayoutX(), 0.0f);
164+
assertEquals(0f, root.getLayoutY(), 0.0f);
165+
assertEquals(200f, root.getLayoutWidth(), 0.0f);
166+
assertEquals(200f, root.getLayoutHeight(), 0.0f);
167+
168+
assertEquals(136f, root_child0.getLayoutX(), 0.0f);
169+
assertEquals(20f, root_child0.getLayoutY(), 0.0f);
170+
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
171+
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
172+
173+
assertEquals(96f, root_child1.getLayoutX(), 0.0f);
174+
assertEquals(20f, root_child1.getLayoutY(), 0.0f);
175+
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
176+
assertEquals(40f, root_child1.getLayoutHeight(), 0.0f);
177+
178+
assertEquals(56f, root_child2.getLayoutX(), 0.0f);
179+
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
180+
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
181+
assertEquals(40f, root_child2.getLayoutHeight(), 0.0f);
182+
183+
assertEquals(136f, root_child3.getLayoutX(), 0.0f);
184+
assertEquals(68f, root_child3.getLayoutY(), 0.0f);
185+
assertEquals(40f, root_child3.getLayoutWidth(), 0.0f);
186+
assertEquals(40f, root_child3.getLayoutHeight(), 0.0f);
187+
188+
assertEquals(96f, root_child4.getLayoutX(), 0.0f);
189+
assertEquals(68f, root_child4.getLayoutY(), 0.0f);
190+
assertEquals(40f, root_child4.getLayoutWidth(), 0.0f);
191+
assertEquals(40f, root_child4.getLayoutHeight(), 0.0f);
192+
193+
assertEquals(56f, root_child5.getLayoutX(), 0.0f);
194+
assertEquals(68f, root_child5.getLayoutY(), 0.0f);
195+
assertEquals(40f, root_child5.getLayoutWidth(), 0.0f);
196+
assertEquals(40f, root_child5.getLayoutHeight(), 0.0f);
197+
198+
assertEquals(136f, root_child6.getLayoutX(), 0.0f);
199+
assertEquals(116f, root_child6.getLayoutY(), 0.0f);
200+
assertEquals(40f, root_child6.getLayoutWidth(), 0.0f);
201+
assertEquals(40f, root_child6.getLayoutHeight(), 0.0f);
202+
203+
assertEquals(96f, root_child7.getLayoutX(), 0.0f);
204+
assertEquals(116f, root_child7.getLayoutY(), 0.0f);
205+
assertEquals(40f, root_child7.getLayoutWidth(), 0.0f);
206+
assertEquals(40f, root_child7.getLayoutHeight(), 0.0f);
207+
208+
assertEquals(56f, root_child8.getLayoutX(), 0.0f);
209+
assertEquals(116f, root_child8.getLayoutY(), 0.0f);
210+
assertEquals(40f, root_child8.getLayoutWidth(), 0.0f);
211+
assertEquals(40f, root_child8.getLayoutHeight(), 0.0f);
212+
}
213+
214+
private YogaNode createNode(YogaConfig config) {
215+
return mNodeFactory.create(config);
216+
}
217+
}

0 commit comments

Comments
 (0)