Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1482 X-link: https://github.com/facebook/react-native/pull/41685 This is the final step (that I know of) to get the core features of static working. Here we turn on all of the tests and pass down the correct owner size for the call to `calculateLayoutInternal` that is in `layoutAbsoluteChild` Reviewed By: NickGerleman Differential Revision: D51293606 fbshipit-source-id: 972259e7ebecb19b55aef2ef866bd7cb57aaf0ca
2877 lines
112 KiB
TypeScript
2877 lines
112 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/YGStaticPositionTest.html
|
|
|
|
import Yoga from 'yoga-layout';
|
|
import {
|
|
Align,
|
|
Direction,
|
|
Display,
|
|
Edge,
|
|
Errata,
|
|
ExperimentalFeature,
|
|
FlexDirection,
|
|
Gutter,
|
|
Justify,
|
|
MeasureMode,
|
|
Overflow,
|
|
PositionType,
|
|
Unit,
|
|
Wrap,
|
|
} from 'yoga-layout';
|
|
|
|
test('static_position_insets_have_no_effect_left_top', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setPositionType(PositionType.Static);
|
|
root_child0.setPosition(Edge.Left, 50);
|
|
root_child0.setPosition(Edge.Top, 50);
|
|
root_child0.setWidth(100);
|
|
root_child0.setHeight(100);
|
|
root.insertChild(root_child0, 0);
|
|
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(100);
|
|
expect(root_child0.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(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_insets_have_no_effect_right_bottom', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setPositionType(PositionType.Static);
|
|
root_child0.setPosition(Edge.Right, 50);
|
|
root_child0.setPosition(Edge.Bottom, 50);
|
|
root_child0.setWidth(100);
|
|
root_child0.setHeight(100);
|
|
root.insertChild(root_child0, 0);
|
|
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(100);
|
|
expect(root_child0.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(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0.getComputedHeight()).toBe(100);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_insets_relative_to_positioned_ancestor', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setMargin(Edge.Left, 100);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setPosition(Edge.Left, 50);
|
|
root_child0_child0_child0.setPosition(Edge.Top, 50);
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(-50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(-50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_insets_relative_to_positioned_ancestor_deep', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setMargin(Edge.Left, 100);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setMargin(Edge.Left, 100);
|
|
root_child0_child0_child0.setWidth(100);
|
|
root_child0_child0_child0.setHeight(100);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0_child0.setMargin(Edge.Left, 100);
|
|
root_child0_child0_child0_child0.setWidth(100);
|
|
root_child0_child0_child0_child0.setHeight(100);
|
|
root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0_child0_child0.setMargin(Edge.Left, 100);
|
|
root_child0_child0_child0_child0_child0.setWidth(100);
|
|
root_child0_child0_child0_child0_child0.setHeight(100);
|
|
root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0_child0_child0_child0.setPosition(Edge.Left, 50);
|
|
root_child0_child0_child0_child0_child0_child0.setPosition(Edge.Top, 50);
|
|
root_child0_child0_child0_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0_child0_child0_child0.setHeight(50);
|
|
root_child0_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(-350);
|
|
expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(-50);
|
|
expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_width_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setWidth("50%");
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_width_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setWidth("50%");
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_width_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setWidth("50%");
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_height_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight("50%");
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_height_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight("50%");
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_height_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight("50%");
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_left_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setPosition(Edge.Left, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_left_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPosition(Edge.Left, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_left_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setPosition(Edge.Left, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_right_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setPosition(Edge.Right, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(-50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_right_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPosition(Edge.Right, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(-50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_right_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setPosition(Edge.Right, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_top_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setPosition(Edge.Top, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_top_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPosition(Edge.Top, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_top_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setPosition(Edge.Top, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_bottom_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setPosition(Edge.Bottom, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_bottom_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPosition(Edge.Bottom, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(-50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(-50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_bottom_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setPosition(Edge.Bottom, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_margin_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setMargin(Edge.Left, "50%");
|
|
root_child0_child0_child0.setMargin(Edge.Top, "50%");
|
|
root_child0_child0_child0.setMargin(Edge.Right, "50%");
|
|
root_child0_child0_child0.setMargin(Edge.Bottom, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(-50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_margin_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setMargin(Edge.Left, "50%");
|
|
root_child0_child0_child0.setMargin(Edge.Top, "50%");
|
|
root_child0_child0_child0.setMargin(Edge.Right, "50%");
|
|
root_child0_child0_child0.setMargin(Edge.Bottom, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_margin_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setMargin(Edge.Left, "50%");
|
|
root_child0_child0_child0.setMargin(Edge.Top, "50%");
|
|
root_child0_child0_child0.setMargin(Edge.Right, "50%");
|
|
root_child0_child0_child0.setMargin(Edge.Bottom, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_padding_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setPadding(Edge.Left, "50%");
|
|
root_child0_child0_child0.setPadding(Edge.Top, "50%");
|
|
root_child0_child0_child0.setPadding(Edge.Right, "50%");
|
|
root_child0_child0_child0.setPadding(Edge.Bottom, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(200);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(-100);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(200);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_padding_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPadding(Edge.Left, "50%");
|
|
root_child0_child0_child0.setPadding(Edge.Top, "50%");
|
|
root_child0_child0_child0.setPadding(Edge.Right, "50%");
|
|
root_child0_child0_child0.setPadding(Edge.Bottom, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_padding_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setPadding(Edge.Left, "50%");
|
|
root_child0_child0_child0.setPadding(Edge.Top, "50%");
|
|
root_child0_child0_child0.setPadding(Edge.Right, "50%");
|
|
root_child0_child0_child0.setPadding(Edge.Bottom, "50%");
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(100);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_border_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_border_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_border_percentage', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setWidth(200);
|
|
root_child0.setHeight(200);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setWidth(50);
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(200);
|
|
expect(root.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0.getComputedHeight()).toBe(200);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_absolute_child_containing_block_padding_box', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setPadding(Edge.Left, 100);
|
|
root_child0.setPadding(Edge.Top, 100);
|
|
root_child0.setPadding(Edge.Right, 100);
|
|
root_child0.setPadding(Edge.Bottom, 100);
|
|
root_child0.setWidth(400);
|
|
root_child0.setHeight(400);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0_child0.setWidth("50%");
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(200);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(-100);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_containing_block_padding_box', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setPadding(Edge.Left, 100);
|
|
root_child0.setPadding(Edge.Top, 100);
|
|
root_child0.setPadding(Edge.Right, 100);
|
|
root_child0.setPadding(Edge.Bottom, 100);
|
|
root_child0.setWidth(400);
|
|
root_child0.setHeight(400);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setWidth("50%");
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(200);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_containing_block_padding_box', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setPadding(Edge.Left, 100);
|
|
root_child0.setPadding(Edge.Top, 100);
|
|
root_child0.setPadding(Edge.Right, 100);
|
|
root_child0.setPadding(Edge.Bottom, 100);
|
|
root_child0.setWidth(400);
|
|
root_child0.setHeight(400);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth(100);
|
|
root_child0_child0.setHeight(100);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
|
|
const root_child0_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0_child0.setWidth("50%");
|
|
root_child0_child0_child0.setHeight(50);
|
|
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(200);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
|
|
|
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
|
|
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test.skip('static_position_absolute_child_containing_block_content_box', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setPadding(Edge.Left, 100);
|
|
root_child0.setPadding(Edge.Top, 100);
|
|
root_child0.setPadding(Edge.Right, 100);
|
|
root_child0.setPadding(Edge.Bottom, 100);
|
|
root_child0.setWidth(400);
|
|
root_child0.setHeight(400);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Absolute);
|
|
root_child0_child0.setWidth("50%");
|
|
root_child0_child0.setHeight(50);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(200);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_relative_child_containing_block_content_box', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setPadding(Edge.Left, 100);
|
|
root_child0.setPadding(Edge.Top, 100);
|
|
root_child0.setPadding(Edge.Right, 100);
|
|
root_child0.setPadding(Edge.Bottom, 100);
|
|
root_child0.setWidth(400);
|
|
root_child0.setHeight(400);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setWidth("50%");
|
|
root_child0_child0.setHeight(50);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(200);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|
|
test('static_position_static_child_containing_block_content_box', () => {
|
|
const config = Yoga.Config.create();
|
|
let root;
|
|
|
|
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
|
|
|
try {
|
|
root = Yoga.Node.create(config);
|
|
root.setPositionType(PositionType.Absolute);
|
|
|
|
const root_child0 = Yoga.Node.create(config);
|
|
root_child0.setPadding(Edge.Left, 100);
|
|
root_child0.setPadding(Edge.Top, 100);
|
|
root_child0.setPadding(Edge.Right, 100);
|
|
root_child0.setPadding(Edge.Bottom, 100);
|
|
root_child0.setWidth(400);
|
|
root_child0.setHeight(400);
|
|
root.insertChild(root_child0, 0);
|
|
|
|
const root_child0_child0 = Yoga.Node.create(config);
|
|
root_child0_child0.setPositionType(PositionType.Static);
|
|
root_child0_child0.setWidth("50%");
|
|
root_child0_child0.setHeight(50);
|
|
root_child0.insertChild(root_child0_child0, 0);
|
|
root.calculateLayout(undefined, undefined, Direction.LTR);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
|
|
root.calculateLayout(undefined, undefined, Direction.RTL);
|
|
|
|
expect(root.getComputedLeft()).toBe(0);
|
|
expect(root.getComputedTop()).toBe(0);
|
|
expect(root.getComputedWidth()).toBe(400);
|
|
expect(root.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0.getComputedLeft()).toBe(0);
|
|
expect(root_child0.getComputedTop()).toBe(0);
|
|
expect(root_child0.getComputedWidth()).toBe(400);
|
|
expect(root_child0.getComputedHeight()).toBe(400);
|
|
|
|
expect(root_child0_child0.getComputedLeft()).toBe(200);
|
|
expect(root_child0_child0.getComputedTop()).toBe(100);
|
|
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
|
expect(root_child0_child0.getComputedHeight()).toBe(50);
|
|
} finally {
|
|
if (typeof root !== 'undefined') {
|
|
root.freeRecursive();
|
|
}
|
|
|
|
config.free();
|
|
}
|
|
});
|