Fix position on root node with RTL direction

Summary:
If the root node has a position and we have a RTL layout, that position must be like LTR direction. See #477.
Closes https://github.com/facebook/yoga/pull/502

Differential Revision: D4867144

Pulled By: emilsjolander

fbshipit-source-id: b5ad3d87e7054090da12d7665a3d1abe8496a548
This commit is contained in:
Lukas Wöhrl
2017-04-11 13:00:02 -07:00
committed by Facebook Github Bot
parent 3ea76f8a9b
commit e9927377b5
6 changed files with 125 additions and 12 deletions

View File

@@ -703,4 +703,29 @@ public class YGAbsolutePositionTest {
assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_position_root_with_rtl_should_position_withoutdirection() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setPosition(YogaEdge.LEFT, 72f);
root.setWidth(52f);
root.setHeight(52f);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(72f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(52f, root.getLayoutWidth(), 0.0f);
assertEquals(52f, root.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(72f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(52f, root.getLayoutWidth(), 0.0f);
assertEquals(52f, root.getLayoutHeight(), 0.0f);
}
}