Enable previously broken absolute positioning tests (#1488)
Summary: Pull Request resolved: https://github.com/facebook/yoga/pull/1488 These were disabled when they were written because they were broken. The recent changes made them pass now so lets enable them. I also added another test that is already passing Reviewed By: NickGerleman Differential Revision: D51404875 fbshipit-source-id: ed10004968b871c1d033640d75138f00afc15968
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bc5dc2d6bf
commit
1ea575684d
@@ -1356,7 +1356,7 @@ test('absolute_layout_percentage_height_based_on_padded_parent_and_align_items_c
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test.skip('absolute_layout_padding_left', () => {
|
||||
test('absolute_layout_padding_left', () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
@@ -1405,7 +1405,7 @@ test.skip('absolute_layout_padding_left', () => {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test.skip('absolute_layout_padding_right', () => {
|
||||
test('absolute_layout_padding_right', () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
@@ -1454,7 +1454,7 @@ test.skip('absolute_layout_padding_right', () => {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test.skip('absolute_layout_padding_top', () => {
|
||||
test('absolute_layout_padding_top', () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
|
@@ -2680,7 +2680,7 @@ test('static_position_static_child_containing_block_padding_box', () => {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test.skip('static_position_absolute_child_containing_block_content_box', () => {
|
||||
test('static_position_absolute_child_containing_block_content_box', () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
@@ -5765,3 +5765,67 @@ test('static_position_align_flex_end_amalgamation', () => {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test('static_position_static_root', () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setPositionType(PositionType.Static);
|
||||
root.setPadding(Edge.Left, 6);
|
||||
root.setPadding(Edge.Top, 1);
|
||||
root.setPadding(Edge.Right, 11);
|
||||
root.setPadding(Edge.Bottom, 4);
|
||||
root.setWidth(100);
|
||||
root.setHeight(200);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPositionType(PositionType.Absolute);
|
||||
root_child0.setMargin(Edge.Left, 12);
|
||||
root_child0.setMargin(Edge.Top, 11);
|
||||
root_child0.setMargin(Edge.Right, 15);
|
||||
root_child0.setMargin(Edge.Bottom, 1);
|
||||
root_child0.setPadding(Edge.Left, 3);
|
||||
root_child0.setPadding(Edge.Top, 7);
|
||||
root_child0.setPadding(Edge.Right, 5);
|
||||
root_child0.setPadding(Edge.Bottom, 4);
|
||||
root_child0.setBorder(Edge.Left, 4);
|
||||
root_child0.setBorder(Edge.Top, 3);
|
||||
root_child0.setBorder(Edge.Right, 2);
|
||||
root_child0.setBorder(Edge.Bottom, 1);
|
||||
root_child0.setWidth("50%");
|
||||
root_child0.setHeight("50%");
|
||||
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(200);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(18);
|
||||
expect(root_child0.getComputedTop()).toBe(12);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
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(200);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(24);
|
||||
expect(root_child0.getComputedTop()).toBe(12);
|
||||
expect(root_child0.getComputedWidth()).toBe(50);
|
||||
expect(root_child0.getComputedHeight()).toBe(100);
|
||||
} finally {
|
||||
if (typeof root !== 'undefined') {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user