Files
yoga/javascript/tests/generated/YGRoundingTest.test.ts
Joe Vilches 2ea4c043fd 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
2023-10-23 18:20:24 -07:00

1234 lines
44 KiB
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @generated by gentest/gentest.rb from gentest/fixtures/YGRoundingTest.html
import {Yoga} from "../tools/globals";
import {
Align,
Direction,
Display,
Edge,
Errata,
ExperimentalFeature,
FlexDirection,
Gutter,
Justify,
MeasureMode,
Overflow,
PositionType,
Unit,
Wrap,
} from 'yoga-layout';
test('rounding_flex_basis_flex_grow_row_width_of_100', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setFlexDirection(FlexDirection.Row);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(33);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(33);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(34);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(67);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(33);
expect(root_child2.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(67);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(33);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(33);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(34);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(33);
expect(root_child2.getComputedHeight()).toBe(100);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_flex_basis_flex_grow_row_prime_number_width', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setFlexDirection(FlexDirection.Row);
root.setPositionType(PositionType.Absolute);
root.setWidth(113);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root.insertChild(root_child2, 2);
const root_child3 = Yoga.Node.create(config);
root_child3.setPositionType(PositionType.Relative);
root_child3.setFlexGrow(1);
root.insertChild(root_child3, 3);
const root_child4 = Yoga.Node.create(config);
root_child4.setPositionType(PositionType.Relative);
root_child4.setFlexGrow(1);
root.insertChild(root_child4, 4);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(113);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(23);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(23);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(22);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(45);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(23);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(68);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(22);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(90);
expect(root_child4.getComputedTop()).toBe(0);
expect(root_child4.getComputedWidth()).toBe(23);
expect(root_child4.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(113);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(90);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(23);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(68);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(22);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(45);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(23);
expect(root_child2.getComputedHeight()).toBe(100);
expect(root_child3.getComputedLeft()).toBe(23);
expect(root_child3.getComputedTop()).toBe(0);
expect(root_child3.getComputedWidth()).toBe(22);
expect(root_child3.getComputedHeight()).toBe(100);
expect(root_child4.getComputedLeft()).toBe(0);
expect(root_child4.getComputedTop()).toBe(0);
expect(root_child4.getComputedWidth()).toBe(23);
expect(root_child4.getComputedHeight()).toBe(100);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_flex_basis_flex_shrink_row', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setFlexDirection(FlexDirection.Row);
root.setPositionType(PositionType.Absolute);
root.setWidth(101);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexShrink(1);
root_child0.setFlexBasis(100);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexBasis(25);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexBasis(25);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(101);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(51);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(51);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(25);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(76);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(25);
expect(root_child2.getComputedHeight()).toBe(100);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(101);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(50);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(51);
expect(root_child0.getComputedHeight()).toBe(100);
expect(root_child1.getComputedLeft()).toBe(25);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(25);
expect(root_child1.getComputedHeight()).toBe(100);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(25);
expect(root_child2.getComputedHeight()).toBe(100);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_flex_basis_overrides_main_size', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(113);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root_child0.setFlexBasis(50);
root_child0.setHeight(20);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root_child1.setHeight(10);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root_child2.setHeight(10);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(64);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(64);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(25);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(24);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(64);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(64);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(25);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(24);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_total_fractial', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(87.4);
root.setHeight(113.4);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(0.7);
root_child0.setFlexBasis(50.3);
root_child0.setHeight(20.3);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1.6);
root_child1.setHeight(10);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1.1);
root_child2.setHeight(10.7);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(87);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(87);
expect(root_child0.getComputedHeight()).toBe(59);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(59);
expect(root_child1.getComputedWidth()).toBe(87);
expect(root_child1.getComputedHeight()).toBe(30);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(87);
expect(root_child2.getComputedHeight()).toBe(24);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(87);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(87);
expect(root_child0.getComputedHeight()).toBe(59);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(59);
expect(root_child1.getComputedWidth()).toBe(87);
expect(root_child1.getComputedHeight()).toBe(30);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(87);
expect(root_child2.getComputedHeight()).toBe(24);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_total_fractial_nested', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(87.4);
root.setHeight(113.4);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(0.7);
root_child0.setFlexBasis(50.3);
root_child0.setHeight(20.3);
root.insertChild(root_child0, 0);
const root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setPositionType(PositionType.Relative);
root_child0_child0.setFlexGrow(1);
root_child0_child0.setFlexBasis(0.3);
root_child0_child0.setPosition(Edge.Bottom, 13.3);
root_child0_child0.setHeight(9.9);
root_child0.insertChild(root_child0_child0, 0);
const root_child0_child1 = Yoga.Node.create(config);
root_child0_child1.setPositionType(PositionType.Relative);
root_child0_child1.setFlexGrow(4);
root_child0_child1.setFlexBasis(0.3);
root_child0_child1.setPosition(Edge.Top, 13.3);
root_child0_child1.setHeight(1.1);
root_child0.insertChild(root_child0_child1, 1);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1.6);
root_child1.setHeight(10);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1.1);
root_child2.setHeight(10.7);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(87);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(87);
expect(root_child0.getComputedHeight()).toBe(59);
expect(root_child0_child0.getComputedLeft()).toBe(0);
expect(root_child0_child0.getComputedTop()).toBe(-13);
expect(root_child0_child0.getComputedWidth()).toBe(87);
expect(root_child0_child0.getComputedHeight()).toBe(12);
expect(root_child0_child1.getComputedLeft()).toBe(0);
expect(root_child0_child1.getComputedTop()).toBe(25);
expect(root_child0_child1.getComputedWidth()).toBe(87);
expect(root_child0_child1.getComputedHeight()).toBe(47);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(59);
expect(root_child1.getComputedWidth()).toBe(87);
expect(root_child1.getComputedHeight()).toBe(30);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(87);
expect(root_child2.getComputedHeight()).toBe(24);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(87);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(87);
expect(root_child0.getComputedHeight()).toBe(59);
expect(root_child0_child0.getComputedLeft()).toBe(0);
expect(root_child0_child0.getComputedTop()).toBe(-13);
expect(root_child0_child0.getComputedWidth()).toBe(87);
expect(root_child0_child0.getComputedHeight()).toBe(12);
expect(root_child0_child1.getComputedLeft()).toBe(0);
expect(root_child0_child1.getComputedTop()).toBe(25);
expect(root_child0_child1.getComputedWidth()).toBe(87);
expect(root_child0_child1.getComputedHeight()).toBe(47);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(59);
expect(root_child1.getComputedWidth()).toBe(87);
expect(root_child1.getComputedHeight()).toBe(30);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(87);
expect(root_child2.getComputedHeight()).toBe(24);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_fractial_input_1', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(113.4);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root_child0.setFlexBasis(50);
root_child0.setHeight(20);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root_child1.setHeight(10);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root_child2.setHeight(10);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(64);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(64);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(25);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(24);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(64);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(64);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(25);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(24);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_fractial_input_2', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(113.6);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root_child0.setFlexBasis(50);
root_child0.setHeight(20);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root_child1.setHeight(10);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root_child2.setHeight(10);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(114);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(65);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(65);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(24);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(25);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(114);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(65);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(65);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(24);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(25);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_fractial_input_3', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setPosition(Edge.Top, 0.3);
root.setWidth(100);
root.setHeight(113.4);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root_child0.setFlexBasis(50);
root_child0.setHeight(20);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root_child1.setHeight(10);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root_child2.setHeight(10);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(114);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(65);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(64);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(24);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(25);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(114);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(65);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(64);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(24);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(25);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_fractial_input_4', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setPosition(Edge.Top, 0.7);
root.setWidth(100);
root.setHeight(113.4);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root_child0.setFlexBasis(50);
root_child0.setHeight(20);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root_child1.setHeight(10);
root.insertChild(root_child1, 1);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root_child2.setHeight(10);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(1);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(64);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(64);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(25);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(24);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(1);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(113);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(100);
expect(root_child0.getComputedHeight()).toBe(64);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(64);
expect(root_child1.getComputedWidth()).toBe(100);
expect(root_child1.getComputedHeight()).toBe(25);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(89);
expect(root_child2.getComputedWidth()).toBe(100);
expect(root_child2.getComputedHeight()).toBe(24);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_inner_node_controversy_horizontal', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setFlexDirection(FlexDirection.Row);
root.setPositionType(PositionType.Absolute);
root.setWidth(320);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root_child0.setHeight(10);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root_child1.setHeight(10);
root.insertChild(root_child1, 1);
const root_child1_child0 = Yoga.Node.create(config);
root_child1_child0.setPositionType(PositionType.Relative);
root_child1_child0.setFlexGrow(1);
root_child1_child0.setHeight(10);
root_child1.insertChild(root_child1_child0, 0);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root_child2.setHeight(10);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(320);
expect(root.getComputedHeight()).toBe(10);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(107);
expect(root_child0.getComputedHeight()).toBe(10);
expect(root_child1.getComputedLeft()).toBe(107);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(106);
expect(root_child1.getComputedHeight()).toBe(10);
expect(root_child1_child0.getComputedLeft()).toBe(0);
expect(root_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child0.getComputedWidth()).toBe(106);
expect(root_child1_child0.getComputedHeight()).toBe(10);
expect(root_child2.getComputedLeft()).toBe(213);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(107);
expect(root_child2.getComputedHeight()).toBe(10);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(320);
expect(root.getComputedHeight()).toBe(10);
expect(root_child0.getComputedLeft()).toBe(213);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(107);
expect(root_child0.getComputedHeight()).toBe(10);
expect(root_child1.getComputedLeft()).toBe(107);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(106);
expect(root_child1.getComputedHeight()).toBe(10);
expect(root_child1_child0.getComputedLeft()).toBe(0);
expect(root_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child0.getComputedWidth()).toBe(106);
expect(root_child1_child0.getComputedHeight()).toBe(10);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(107);
expect(root_child2.getComputedHeight()).toBe(10);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_inner_node_controversy_vertical', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setHeight(320);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root_child0.setWidth(10);
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root_child1.setWidth(10);
root.insertChild(root_child1, 1);
const root_child1_child0 = Yoga.Node.create(config);
root_child1_child0.setPositionType(PositionType.Relative);
root_child1_child0.setFlexGrow(1);
root_child1_child0.setWidth(10);
root_child1.insertChild(root_child1_child0, 0);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root_child2.setWidth(10);
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(10);
expect(root.getComputedHeight()).toBe(320);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(107);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(107);
expect(root_child1.getComputedWidth()).toBe(10);
expect(root_child1.getComputedHeight()).toBe(106);
expect(root_child1_child0.getComputedLeft()).toBe(0);
expect(root_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child0.getComputedWidth()).toBe(10);
expect(root_child1_child0.getComputedHeight()).toBe(106);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(213);
expect(root_child2.getComputedWidth()).toBe(10);
expect(root_child2.getComputedHeight()).toBe(107);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(10);
expect(root.getComputedHeight()).toBe(320);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(107);
expect(root_child1.getComputedLeft()).toBe(0);
expect(root_child1.getComputedTop()).toBe(107);
expect(root_child1.getComputedWidth()).toBe(10);
expect(root_child1.getComputedHeight()).toBe(106);
expect(root_child1_child0.getComputedLeft()).toBe(0);
expect(root_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child0.getComputedWidth()).toBe(10);
expect(root_child1_child0.getComputedHeight()).toBe(106);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(213);
expect(root_child2.getComputedWidth()).toBe(10);
expect(root_child2.getComputedHeight()).toBe(107);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('rounding_inner_node_controversy_combined', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setFlexDirection(FlexDirection.Row);
root.setPositionType(PositionType.Absolute);
root.setWidth(640);
root.setHeight(320);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Relative);
root_child0.setFlexGrow(1);
root_child0.setHeight("100%");
root.insertChild(root_child0, 0);
const root_child1 = Yoga.Node.create(config);
root_child1.setPositionType(PositionType.Relative);
root_child1.setFlexGrow(1);
root_child1.setHeight("100%");
root.insertChild(root_child1, 1);
const root_child1_child0 = Yoga.Node.create(config);
root_child1_child0.setPositionType(PositionType.Relative);
root_child1_child0.setFlexGrow(1);
root_child1_child0.setWidth("100%");
root_child1.insertChild(root_child1_child0, 0);
const root_child1_child1 = Yoga.Node.create(config);
root_child1_child1.setPositionType(PositionType.Relative);
root_child1_child1.setFlexGrow(1);
root_child1_child1.setWidth("100%");
root_child1.insertChild(root_child1_child1, 1);
const root_child1_child1_child0 = Yoga.Node.create(config);
root_child1_child1_child0.setPositionType(PositionType.Relative);
root_child1_child1_child0.setFlexGrow(1);
root_child1_child1_child0.setWidth("100%");
root_child1_child1.insertChild(root_child1_child1_child0, 0);
const root_child1_child2 = Yoga.Node.create(config);
root_child1_child2.setPositionType(PositionType.Relative);
root_child1_child2.setFlexGrow(1);
root_child1_child2.setWidth("100%");
root_child1.insertChild(root_child1_child2, 2);
const root_child2 = Yoga.Node.create(config);
root_child2.setPositionType(PositionType.Relative);
root_child2.setFlexGrow(1);
root_child2.setHeight("100%");
root.insertChild(root_child2, 2);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(640);
expect(root.getComputedHeight()).toBe(320);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(213);
expect(root_child0.getComputedHeight()).toBe(320);
expect(root_child1.getComputedLeft()).toBe(213);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(214);
expect(root_child1.getComputedHeight()).toBe(320);
expect(root_child1_child0.getComputedLeft()).toBe(0);
expect(root_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child0.getComputedWidth()).toBe(214);
expect(root_child1_child0.getComputedHeight()).toBe(107);
expect(root_child1_child1.getComputedLeft()).toBe(0);
expect(root_child1_child1.getComputedTop()).toBe(107);
expect(root_child1_child1.getComputedWidth()).toBe(214);
expect(root_child1_child1.getComputedHeight()).toBe(106);
expect(root_child1_child1_child0.getComputedLeft()).toBe(0);
expect(root_child1_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child1_child0.getComputedWidth()).toBe(214);
expect(root_child1_child1_child0.getComputedHeight()).toBe(106);
expect(root_child1_child2.getComputedLeft()).toBe(0);
expect(root_child1_child2.getComputedTop()).toBe(213);
expect(root_child1_child2.getComputedWidth()).toBe(214);
expect(root_child1_child2.getComputedHeight()).toBe(107);
expect(root_child2.getComputedLeft()).toBe(427);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(213);
expect(root_child2.getComputedHeight()).toBe(320);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(640);
expect(root.getComputedHeight()).toBe(320);
expect(root_child0.getComputedLeft()).toBe(427);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(213);
expect(root_child0.getComputedHeight()).toBe(320);
expect(root_child1.getComputedLeft()).toBe(213);
expect(root_child1.getComputedTop()).toBe(0);
expect(root_child1.getComputedWidth()).toBe(214);
expect(root_child1.getComputedHeight()).toBe(320);
expect(root_child1_child0.getComputedLeft()).toBe(0);
expect(root_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child0.getComputedWidth()).toBe(214);
expect(root_child1_child0.getComputedHeight()).toBe(107);
expect(root_child1_child1.getComputedLeft()).toBe(0);
expect(root_child1_child1.getComputedTop()).toBe(107);
expect(root_child1_child1.getComputedWidth()).toBe(214);
expect(root_child1_child1.getComputedHeight()).toBe(106);
expect(root_child1_child1_child0.getComputedLeft()).toBe(0);
expect(root_child1_child1_child0.getComputedTop()).toBe(0);
expect(root_child1_child1_child0.getComputedWidth()).toBe(214);
expect(root_child1_child1_child0.getComputedHeight()).toBe(106);
expect(root_child1_child2.getComputedLeft()).toBe(0);
expect(root_child1_child2.getComputedTop()).toBe(213);
expect(root_child1_child2.getComputedWidth()).toBe(214);
expect(root_child1_child2.getComputedHeight()).toBe(107);
expect(root_child2.getComputedLeft()).toBe(0);
expect(root_child2.getComputedTop()).toBe(0);
expect(root_child2.getComputedWidth()).toBe(213);
expect(root_child2.getComputedHeight()).toBe(320);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});