|
4 | 4 | * This source code is licensed under the MIT license found in the |
5 | 5 | * LICENSE file in the root directory of this source tree. |
6 | 6 | * |
7 | | - * @generated SignedSource<<6616024018d06fa39cddd2e65b650169>> |
| 7 | + * @generated SignedSource<<bae6abb6bef83b07502b9c4ff2645118>> |
8 | 8 | * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGridTest.html |
9 | 9 | */ |
10 | 10 |
|
@@ -1503,6 +1503,177 @@ public void test_grid_asymmetric_layout() { |
1503 | 1503 | assertEquals(200f, root_child4.getLayoutHeight(), 0.0f); |
1504 | 1504 | } |
1505 | 1505 |
|
| 1506 | + @Test |
| 1507 | + public void test_grid_with_percentage_tracks() { |
| 1508 | + YogaConfig config = YogaConfigFactory.create(); |
| 1509 | + |
| 1510 | + final YogaNode root = createNode(config); |
| 1511 | + root.setPositionType(YogaPositionType.ABSOLUTE); |
| 1512 | + root.setDisplay(YogaDisplay.GRID); |
| 1513 | + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); |
| 1514 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1515 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1516 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1517 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1518 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1519 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1520 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1521 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1522 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1523 | + root.setGridTemplateColumns(rootGridTemplateColumns); |
| 1524 | + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); |
| 1525 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1526 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1527 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1528 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1529 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1530 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1531 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1532 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1533 | + root.setGridTemplateRows(rootGridTemplateRows); |
| 1534 | + |
| 1535 | + final YogaNode root_child0 = createNode(config); |
| 1536 | + root.addChildAt(root_child0, 0); |
| 1537 | + |
| 1538 | + final YogaNode root_child1 = createNode(config); |
| 1539 | + root.addChildAt(root_child1, 1); |
| 1540 | + root.setDirection(YogaDirection.LTR); |
| 1541 | + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); |
| 1542 | + |
| 1543 | + assertEquals(0f, root.getLayoutX(), 0.0f); |
| 1544 | + assertEquals(0f, root.getLayoutY(), 0.0f); |
| 1545 | + assertEquals(100f, root.getLayoutWidth(), 0.0f); |
| 1546 | + assertEquals(50f, root.getLayoutHeight(), 0.0f); |
| 1547 | + |
| 1548 | + assertEquals(0f, root_child0.getLayoutX(), 0.0f); |
| 1549 | + assertEquals(0f, root_child0.getLayoutY(), 0.0f); |
| 1550 | + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); |
| 1551 | + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); |
| 1552 | + |
| 1553 | + assertEquals(100f, root_child1.getLayoutX(), 0.0f); |
| 1554 | + assertEquals(0f, root_child1.getLayoutY(), 0.0f); |
| 1555 | + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); |
| 1556 | + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); |
| 1557 | + |
| 1558 | + root.setDirection(YogaDirection.RTL); |
| 1559 | + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); |
| 1560 | + |
| 1561 | + assertEquals(0f, root.getLayoutX(), 0.0f); |
| 1562 | + assertEquals(0f, root.getLayoutY(), 0.0f); |
| 1563 | + assertEquals(100f, root.getLayoutWidth(), 0.0f); |
| 1564 | + assertEquals(50f, root.getLayoutHeight(), 0.0f); |
| 1565 | + |
| 1566 | + assertEquals(0f, root_child0.getLayoutX(), 0.0f); |
| 1567 | + assertEquals(0f, root_child0.getLayoutY(), 0.0f); |
| 1568 | + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); |
| 1569 | + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); |
| 1570 | + |
| 1571 | + assertEquals(-20f, root_child1.getLayoutX(), 0.0f); |
| 1572 | + assertEquals(0f, root_child1.getLayoutY(), 0.0f); |
| 1573 | + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); |
| 1574 | + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); |
| 1575 | + } |
| 1576 | + |
| 1577 | + @Test |
| 1578 | + public void test_grid_percentage_tracks_with_definite_size() { |
| 1579 | + YogaConfig config = YogaConfigFactory.create(); |
| 1580 | + |
| 1581 | + final YogaNode root = createNode(config); |
| 1582 | + root.setPositionType(YogaPositionType.ABSOLUTE); |
| 1583 | + root.setWidth(300f); |
| 1584 | + root.setHeight(300f); |
| 1585 | + root.setGapPercent(YogaGutter.COLUMN, 10f); |
| 1586 | + root.setGapPercent(YogaGutter.ROW, 10f); |
| 1587 | + root.setDisplay(YogaDisplay.GRID); |
| 1588 | + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); |
| 1589 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1590 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1591 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1592 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1593 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1594 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1595 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1596 | + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); |
| 1597 | + root.setGridTemplateColumns(rootGridTemplateColumns); |
| 1598 | + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); |
| 1599 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1600 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1601 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1602 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1603 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1604 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1605 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1606 | + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); |
| 1607 | + root.setGridTemplateRows(rootGridTemplateRows); |
| 1608 | + |
| 1609 | + final YogaNode root_child0 = createNode(config); |
| 1610 | + root.addChildAt(root_child0, 0); |
| 1611 | + |
| 1612 | + final YogaNode root_child1 = createNode(config); |
| 1613 | + root.addChildAt(root_child1, 1); |
| 1614 | + |
| 1615 | + final YogaNode root_child2 = createNode(config); |
| 1616 | + root.addChildAt(root_child2, 2); |
| 1617 | + |
| 1618 | + final YogaNode root_child3 = createNode(config); |
| 1619 | + root.addChildAt(root_child3, 3); |
| 1620 | + root.setDirection(YogaDirection.LTR); |
| 1621 | + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); |
| 1622 | + |
| 1623 | + assertEquals(0f, root.getLayoutX(), 0.0f); |
| 1624 | + assertEquals(0f, root.getLayoutY(), 0.0f); |
| 1625 | + assertEquals(300f, root.getLayoutWidth(), 0.0f); |
| 1626 | + assertEquals(300f, root.getLayoutHeight(), 0.0f); |
| 1627 | + |
| 1628 | + assertEquals(0f, root_child0.getLayoutX(), 0.0f); |
| 1629 | + assertEquals(0f, root_child0.getLayoutY(), 0.0f); |
| 1630 | + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); |
| 1631 | + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); |
| 1632 | + |
| 1633 | + assertEquals(30f, root_child1.getLayoutX(), 0.0f); |
| 1634 | + assertEquals(0f, root_child1.getLayoutY(), 0.0f); |
| 1635 | + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); |
| 1636 | + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); |
| 1637 | + |
| 1638 | + assertEquals(0f, root_child2.getLayoutX(), 0.0f); |
| 1639 | + assertEquals(80f, root_child2.getLayoutY(), 0.0f); |
| 1640 | + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); |
| 1641 | + assertEquals(120f, root_child2.getLayoutHeight(), 0.0f); |
| 1642 | + |
| 1643 | + assertEquals(30f, root_child3.getLayoutX(), 0.0f); |
| 1644 | + assertEquals(80f, root_child3.getLayoutY(), 0.0f); |
| 1645 | + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); |
| 1646 | + assertEquals(120f, root_child3.getLayoutHeight(), 0.0f); |
| 1647 | + |
| 1648 | + root.setDirection(YogaDirection.RTL); |
| 1649 | + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); |
| 1650 | + |
| 1651 | + assertEquals(0f, root.getLayoutX(), 0.0f); |
| 1652 | + assertEquals(0f, root.getLayoutY(), 0.0f); |
| 1653 | + assertEquals(300f, root.getLayoutWidth(), 0.0f); |
| 1654 | + assertEquals(300f, root.getLayoutHeight(), 0.0f); |
| 1655 | + |
| 1656 | + assertEquals(300f, root_child0.getLayoutX(), 0.0f); |
| 1657 | + assertEquals(0f, root_child0.getLayoutY(), 0.0f); |
| 1658 | + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); |
| 1659 | + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); |
| 1660 | + |
| 1661 | + assertEquals(210f, root_child1.getLayoutX(), 0.0f); |
| 1662 | + assertEquals(0f, root_child1.getLayoutY(), 0.0f); |
| 1663 | + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); |
| 1664 | + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); |
| 1665 | + |
| 1666 | + assertEquals(300f, root_child2.getLayoutX(), 0.0f); |
| 1667 | + assertEquals(80f, root_child2.getLayoutY(), 0.0f); |
| 1668 | + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); |
| 1669 | + assertEquals(120f, root_child2.getLayoutHeight(), 0.0f); |
| 1670 | + |
| 1671 | + assertEquals(210f, root_child3.getLayoutX(), 0.0f); |
| 1672 | + assertEquals(80f, root_child3.getLayoutY(), 0.0f); |
| 1673 | + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); |
| 1674 | + assertEquals(120f, root_child3.getLayoutHeight(), 0.0f); |
| 1675 | + } |
| 1676 | + |
1506 | 1677 | private YogaNode createNode(YogaConfig config) { |
1507 | 1678 | return mNodeFactory.create(config); |
1508 | 1679 | } |
|
0 commit comments