gentest support for position: static + initial test
Summary: I am about to embark on supporting `position: static` in Yoga. The enum exists already (and is the default position type, lol) but does not actually do anything and just behaves like `position: relative`. My approach here is to write a bunch of tests to test for the various behaviors of static positions and then develop on Yoga afterwards to get those tests passing. To do this, we need to make a few changes to the gentest files as there is not support for adding `position: static` at the moment: * Make it so that the gentest code can physically write `YGPositionTypeStatic` if it encounters `position: static` in the style * Make it so that gentest.js knows that Yoga's default is actually static. This way the code generated in the tests will actually label nodes for non default values * Explicitly label the position type even when it is not declared in the style prop (with the exception of the default) * Regenerate all the tests Additionally I added the first, basic test: making sure insets do nothing on a statically positioned element. Reviewed By: NickGerleman Differential Revision: D50437855 fbshipit-source-id: 0e8bbf1c224d477ea4592b7563d0b70d2ffa79c8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7e91004b90
commit
2ea4c043fd
@@ -34,18 +34,22 @@ test('justify_content_row_flex_start', () => {
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(FlexDirection.Row);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -109,18 +113,22 @@ test('justify_content_row_flex_end', () => {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(FlexDirection.Row);
|
||||
root.setJustifyContent(Justify.FlexEnd);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -184,18 +192,22 @@ test('justify_content_row_center', () => {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(FlexDirection.Row);
|
||||
root.setJustifyContent(Justify.Center);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -259,18 +271,22 @@ test('justify_content_row_space_between', () => {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(FlexDirection.Row);
|
||||
root.setJustifyContent(Justify.SpaceBetween);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -334,18 +350,22 @@ test('justify_content_row_space_around', () => {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(FlexDirection.Row);
|
||||
root.setJustifyContent(Justify.SpaceAround);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setWidth(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setWidth(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setWidth(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -407,18 +427,22 @@ test('justify_content_column_flex_start', () => {
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -481,18 +505,22 @@ test('justify_content_column_flex_end', () => {
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Justify.FlexEnd);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -555,18 +583,22 @@ test('justify_content_column_center', () => {
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Justify.Center);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -629,18 +661,22 @@ test('justify_content_column_space_between', () => {
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Justify.SpaceBetween);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -703,18 +739,22 @@ test('justify_content_column_space_around', () => {
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Justify.SpaceAround);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -778,10 +818,12 @@ test('justify_content_row_min_width_and_margin', () => {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(FlexDirection.Row);
|
||||
root.setJustifyContent(Justify.Center);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setMargin(Edge.Left, 100);
|
||||
root.setMinWidth(50);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setWidth(20);
|
||||
root_child0.setHeight(20);
|
||||
root.insertChild(root_child0, 0);
|
||||
@@ -826,11 +868,13 @@ test('justify_content_row_max_width_and_margin', () => {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(FlexDirection.Row);
|
||||
root.setJustifyContent(Justify.Center);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setMargin(Edge.Left, 100);
|
||||
root.setWidth(100);
|
||||
root.setMaxWidth(80);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setWidth(20);
|
||||
root_child0.setHeight(20);
|
||||
root.insertChild(root_child0, 0);
|
||||
@@ -874,10 +918,12 @@ test('justify_content_column_min_height_and_margin', () => {
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Justify.Center);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setMargin(Edge.Top, 100);
|
||||
root.setMinHeight(50);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setWidth(20);
|
||||
root_child0.setHeight(20);
|
||||
root.insertChild(root_child0, 0);
|
||||
@@ -921,11 +967,13 @@ test('justify_content_colunn_max_height_and_margin', () => {
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Justify.Center);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setMargin(Edge.Top, 100);
|
||||
root.setHeight(100);
|
||||
root.setMaxHeight(80);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setWidth(20);
|
||||
root_child0.setHeight(20);
|
||||
root.insertChild(root_child0, 0);
|
||||
@@ -969,18 +1017,22 @@ test('justify_content_column_space_evenly', () => {
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setJustifyContent(Justify.SpaceEvenly);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -1044,18 +1096,22 @@ test('justify_content_row_space_evenly', () => {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setFlexDirection(FlexDirection.Row);
|
||||
root.setJustifyContent(Justify.SpaceEvenly);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(102);
|
||||
root.setHeight(102);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setHeight(10);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child1 = Yoga.Node.create(config);
|
||||
root_child1.setPositionType(PositionType.Relative);
|
||||
root_child1.setHeight(10);
|
||||
root.insertChild(root_child1, 1);
|
||||
|
||||
const root_child2 = Yoga.Node.create(config);
|
||||
root_child2.setPositionType(PositionType.Relative);
|
||||
root_child2.setHeight(10);
|
||||
root.insertChild(root_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
@@ -1118,18 +1174,21 @@ test('justify_content_min_width_with_padding_child_width_greater_than_parent', (
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setAlignContent(Align.Stretch);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(1000);
|
||||
root.setHeight(1584);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexDirection(FlexDirection.Row);
|
||||
root_child0.setAlignContent(Align.Stretch);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setFlexDirection(FlexDirection.Row);
|
||||
root_child0_child0.setJustifyContent(Justify.Center);
|
||||
root_child0_child0.setAlignContent(Align.Stretch);
|
||||
root_child0_child0.setPositionType(PositionType.Relative);
|
||||
root_child0_child0.setPadding(Edge.Left, 100);
|
||||
root_child0_child0.setPadding(Edge.Right, 100);
|
||||
root_child0_child0.setMinWidth(400);
|
||||
@@ -1138,6 +1197,7 @@ test('justify_content_min_width_with_padding_child_width_greater_than_parent', (
|
||||
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0.setFlexDirection(FlexDirection.Row);
|
||||
root_child0_child0_child0.setAlignContent(Align.Stretch);
|
||||
root_child0_child0_child0.setPositionType(PositionType.Relative);
|
||||
root_child0_child0_child0.setWidth(300);
|
||||
root_child0_child0_child0.setHeight(100);
|
||||
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||
@@ -1201,18 +1261,21 @@ test('justify_content_min_width_with_padding_child_width_lower_than_parent', ()
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setAlignContent(Align.Stretch);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(1080);
|
||||
root.setHeight(1584);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexDirection(FlexDirection.Row);
|
||||
root_child0.setAlignContent(Align.Stretch);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setFlexDirection(FlexDirection.Row);
|
||||
root_child0_child0.setJustifyContent(Justify.Center);
|
||||
root_child0_child0.setAlignContent(Align.Stretch);
|
||||
root_child0_child0.setPositionType(PositionType.Relative);
|
||||
root_child0_child0.setPadding(Edge.Left, 100);
|
||||
root_child0_child0.setPadding(Edge.Right, 100);
|
||||
root_child0_child0.setMinWidth(400);
|
||||
@@ -1221,6 +1284,7 @@ test('justify_content_min_width_with_padding_child_width_lower_than_parent', ()
|
||||
const root_child0_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0_child0.setFlexDirection(FlexDirection.Row);
|
||||
root_child0_child0_child0.setAlignContent(Align.Stretch);
|
||||
root_child0_child0_child0.setPositionType(PositionType.Relative);
|
||||
root_child0_child0_child0.setWidth(199);
|
||||
root_child0_child0_child0.setHeight(100);
|
||||
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||
@@ -1284,20 +1348,24 @@ test('justify_content_space_between_indefinite_container_dim_with_free_space', (
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setAlignItems(Align.Center);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
root.setWidth(300);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setFlexDirection(FlexDirection.Row);
|
||||
root_child0.setJustifyContent(Justify.SpaceBetween);
|
||||
root_child0.setPositionType(PositionType.Relative);
|
||||
root_child0.setMinWidth(200);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setPositionType(PositionType.Relative);
|
||||
root_child0_child0.setWidth(50);
|
||||
root_child0_child0.setHeight(50);
|
||||
root_child0.insertChild(root_child0_child0, 0);
|
||||
|
||||
const root_child0_child1 = Yoga.Node.create(config);
|
||||
root_child0_child1.setPositionType(PositionType.Relative);
|
||||
root_child0_child1.setWidth(50);
|
||||
root_child0_child1.setHeight(50);
|
||||
root_child0.insertChild(root_child0_child1, 1);
|
||||
|
Reference in New Issue
Block a user