2022-12-28 01:27:12 -08:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
Consolidate JavaScript Flavors (#1433)
Summary:
Fixes https://github.com/facebook/yoga/issues/1417
This dramatically simplifies the matrix of Node vs web, ASM vs WASM, sync vs async compilation, or CommonJS vs ES Modules. We have one variant, using wasm, with ESModule top-level await to do async compilation. Web/node share the same binary, and we base64 encode the WASM into a wrapper JS file for compatibility with Node and bundlers.
This has some downsides, like requiring an environment with top level await, but also has upsides, like a consistent, sync looking API compatible with older Yoga, and mitigating TypeScript issues with package exports and typings resolution.
As part of this work I also removed `ts-node` from the toolchain (at the cost of a couple of config files needing to be vanilla JS).
Pull Request resolved: https://github.com/facebook/yoga/pull/1433
Test Plan:
1. `yarn test`
2. `yarn lint`
3. `yarn tsc`
4. `yarn benchmark`
5. `yarn build` website-next
6. `yarn lint` website-next
7. Locally test website-next
8. Examine package artifact created by GitHub
9. All Automation passes
Reviewed By: yungsters
Differential Revision: D50453324
Pulled By: NickGerleman
fbshipit-source-id: fe1192acc69e57fa69a1ff056dd7b5844d2198d5
2023-10-31 20:41:38 -07:00
|
|
|
import Yoga from 'yoga-layout';
|
2023-05-10 22:46:39 -07:00
|
|
|
import {
|
|
|
|
Align,
|
|
|
|
Direction,
|
|
|
|
Display,
|
|
|
|
Edge,
|
|
|
|
Errata,
|
|
|
|
ExperimentalFeature,
|
|
|
|
FlexDirection,
|
|
|
|
Gutter,
|
|
|
|
Justify,
|
|
|
|
MeasureMode,
|
|
|
|
Overflow,
|
|
|
|
PositionType,
|
|
|
|
Unit,
|
|
|
|
Wrap,
|
|
|
|
} from 'yoga-layout';
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_flex_basis_flex_grow_row_width_of_100', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.setFlexDirection(FlexDirection.Row);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_flex_basis_flex_grow_row_prime_number_width', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.setFlexDirection(FlexDirection.Row);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(113);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child2, 2);
|
|
|
|
|
|
|
|
const root_child3 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child3.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child3.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child3, 3);
|
|
|
|
|
|
|
|
const root_child4 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child4.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child4.setFlexGrow(1);
|
|
|
|
root.insertChild(root_child4, 4);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_flex_basis_flex_shrink_row', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.setFlexDirection(FlexDirection.Row);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(101);
|
|
|
|
root.setHeight(100);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexShrink(1);
|
|
|
|
root_child0.setFlexBasis(100);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexBasis(25);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexBasis(25);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_flex_basis_overrides_main_size', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(113);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setFlexBasis(50);
|
|
|
|
root_child0.setHeight(20);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root_child2.setHeight(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_total_fractial', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(87.4);
|
|
|
|
root.setHeight(113.4);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
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);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1.6);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1.1);
|
|
|
|
root_child2.setHeight(10.7);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_total_fractial_nested', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(87.4);
|
|
|
|
root.setHeight(113.4);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
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);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0_child0.setFlexGrow(1);
|
|
|
|
root_child0_child0.setFlexBasis(0.3);
|
2023-05-10 22:46:39 -07:00
|
|
|
root_child0_child0.setPosition(Edge.Bottom, 13.3);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0_child0.setHeight(9.9);
|
|
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
|
|
|
|
const root_child0_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0_child1.setFlexGrow(4);
|
|
|
|
root_child0_child1.setFlexBasis(0.3);
|
2023-05-10 22:46:39 -07:00
|
|
|
root_child0_child1.setPosition(Edge.Top, 13.3);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0_child1.setHeight(1.1);
|
|
|
|
root_child0.insertChild(root_child0_child1, 1);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1.6);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1.1);
|
|
|
|
root_child2.setHeight(10.7);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_fractial_input_1', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(113.4);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setFlexBasis(50);
|
|
|
|
root_child0.setHeight(20);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root_child2.setHeight(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_fractial_input_2', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(113.6);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setFlexBasis(50);
|
|
|
|
root_child0.setHeight(20);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root_child2.setHeight(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_fractial_input_3', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.setPosition(Edge.Top, 0.3);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(113.4);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setFlexBasis(50);
|
|
|
|
root_child0.setHeight(20);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root_child2.setHeight(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_fractial_input_4', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.setPosition(Edge.Top, 0.7);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(100);
|
|
|
|
root.setHeight(113.4);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setFlexBasis(50);
|
|
|
|
root_child0.setHeight(20);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root_child2.setHeight(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_inner_node_controversy_horizontal', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.setFlexDirection(FlexDirection.Row);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(320);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setHeight(10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root_child1.setHeight(10);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child1_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1_child0.setFlexGrow(1);
|
|
|
|
root_child1_child0.setHeight(10);
|
|
|
|
root_child1.insertChild(root_child1_child0, 0);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root_child2.setHeight(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_inner_node_controversy_vertical', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setHeight(320);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setWidth(10);
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root_child1.setWidth(10);
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child1_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1_child0.setFlexGrow(1);
|
|
|
|
root_child1_child0.setWidth(10);
|
|
|
|
root_child1.insertChild(root_child1_child0, 0);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root_child2.setWidth(10);
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|
2023-05-10 22:46:39 -07:00
|
|
|
test('rounding_inner_node_controversy_combined', () => {
|
2022-12-28 01:27:12 -08:00
|
|
|
const config = Yoga.Config.create();
|
|
|
|
let root;
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
2023-01-08 13:41:27 -08:00
|
|
|
|
2022-12-28 01:27:12 -08:00
|
|
|
try {
|
|
|
|
root = Yoga.Node.create(config);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.setFlexDirection(FlexDirection.Row);
|
2023-10-23 18:20:24 -07:00
|
|
|
root.setPositionType(PositionType.Absolute);
|
2022-12-28 01:27:12 -08:00
|
|
|
root.setWidth(640);
|
|
|
|
root.setHeight(320);
|
|
|
|
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child0.setFlexGrow(1);
|
|
|
|
root_child0.setHeight("100%");
|
|
|
|
root.insertChild(root_child0, 0);
|
|
|
|
|
|
|
|
const root_child1 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1.setFlexGrow(1);
|
|
|
|
root_child1.setHeight("100%");
|
|
|
|
root.insertChild(root_child1, 1);
|
|
|
|
|
|
|
|
const root_child1_child0 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
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);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1_child1.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
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);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1_child1_child0.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
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);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child1_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child1_child2.setFlexGrow(1);
|
|
|
|
root_child1_child2.setWidth("100%");
|
|
|
|
root_child1.insertChild(root_child1_child2, 2);
|
|
|
|
|
|
|
|
const root_child2 = Yoga.Node.create(config);
|
2023-10-23 18:20:24 -07:00
|
|
|
root_child2.setPositionType(PositionType.Relative);
|
2022-12-28 01:27:12 -08:00
|
|
|
root_child2.setFlexGrow(1);
|
|
|
|
root_child2.setHeight("100%");
|
|
|
|
root.insertChild(root_child2, 2);
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2023-05-10 22:46:39 -07:00
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
2022-12-28 01:27:12 -08:00
|
|
|
|
|
|
|
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 {
|
2023-05-10 22:46:39 -07:00
|
|
|
if (typeof root !== 'undefined') {
|
2022-12-28 01:27:12 -08:00
|
|
|
root.freeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
config.free();
|
|
|
|
}
|
|
|
|
});
|