diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 4df524b023..895f82f719 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -12,16 +12,16 @@ include(${YOGA_ROOT}/cmake/project-defaults.cmake) add_subdirectory(${YOGA_ROOT}/yoga ${CMAKE_CURRENT_BINARY_DIR}/yoga) -file(GLOB SOURCES_LEGACY CONFIGURE_DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/*.c) file(GLOB SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) add_executable(benchmark ${SOURCES}) -add_executable(benchmarklegacy ${SOURCES_LEGACY}) +add_executable(benchmarklegacy ${CMAKE_CURRENT_SOURCE_DIR}/YGBenchmark.c) +add_executable(benchmarkgrid ${CMAKE_CURRENT_SOURCE_DIR}/YGGridBenchmark.c) target_link_libraries(benchmark yogacore) target_link_libraries(benchmarklegacy yogacore) +target_link_libraries(benchmarkgrid yogacore) target_include_directories(benchmark PRIVATE $) diff --git a/benchmark/YGGridBenchmark.c b/benchmark/YGGridBenchmark.c new file mode 100644 index 0000000000..a40c0b7e88 --- /dev/null +++ b/benchmark/YGGridBenchmark.c @@ -0,0 +1,603 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include + +#include + +#define NUM_REPETITIONS 1000 + +#define YGBENCHMARKS(BLOCK) \ + int main(int argc, char const* argv[]) { \ + (void)argc; \ + (void)argv; \ + clock_t __start; \ + clock_t __endTimes[NUM_REPETITIONS]; \ + { \ + BLOCK \ + } \ + return 0; \ + } + +#define YGBENCHMARK(NAME, BLOCK) \ + __start = clock(); \ + for (uint32_t __i = 0; __i < NUM_REPETITIONS; __i++) { \ + {BLOCK} __endTimes[__i] = clock(); \ + } \ + __printBenchmarkResult(NAME, __start, __endTimes); + +static int __compareDoubles(const void* a, const void* b) { + double arg1 = *(const double*)a; + double arg2 = *(const double*)b; + + if (arg1 < arg2) { + return -1; + } + + if (arg1 > arg2) { + return 1; + } + + return 0; +} + +static void +__printBenchmarkResult(char* name, clock_t start, clock_t* endTimes) { + double timesInMs[NUM_REPETITIONS]; + double mean = 0; + clock_t lastEnd = start; + for (uint32_t i = 0; i < NUM_REPETITIONS; i++) { + timesInMs[i] = + ((double)(endTimes[i] - lastEnd)) / (double)CLOCKS_PER_SEC * 1000; + lastEnd = endTimes[i]; + mean += timesInMs[i]; + } + mean /= NUM_REPETITIONS; + + qsort(timesInMs, NUM_REPETITIONS, sizeof(double), __compareDoubles); + double median = timesInMs[NUM_REPETITIONS / 2]; + + double variance = 0; + for (uint32_t i = 0; i < NUM_REPETITIONS; i++) { + variance += pow(timesInMs[i] - mean, 2); + } + variance /= NUM_REPETITIONS; + double stddev = sqrt(variance); + + printf("%s: median: %lf ms, stddev: %lf ms\n", name, median, stddev); +} + +static YGSize _measure( + YGNodeConstRef node, + float width, + YGMeasureMode widthMode, + float height, + YGMeasureMode heightMode) { + (void)node; + return (YGSize){ + .width = widthMode == YGMeasureModeUndefined ? 10 : width, + .height = heightMode == YGMeasureModeUndefined ? 10 : height, + }; +} + +static YGSize _measureFixed( + YGNodeConstRef node, + float width, + YGMeasureMode widthMode, + float height, + YGMeasureMode heightMode) { + (void)node; + (void)width; + (void)widthMode; + (void)height; + (void)heightMode; + return (YGSize){ + .width = 50, + .height = 50, + }; +} + +static YGGridTrackListRef createFixed3x100Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGPoints(100)); + YGGridTrackListAddTrack(tracks, YGPoints(100)); + YGGridTrackListAddTrack(tracks, YGPoints(100)); + return tracks; +} + +static YGGridTrackListRef createAuto3Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGAuto()); + YGGridTrackListAddTrack(tracks, YGAuto()); + YGGridTrackListAddTrack(tracks, YGAuto()); + return tracks; +} + +static YGGridTrackListRef createFr3Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + return tracks; +} + +static YGGridTrackListRef createFr4Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + return tracks; +} + +static YGGridTrackListRef createFr5Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + return tracks; +} + +static YGGridTrackListRef createFr2Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + return tracks; +} + +static YGGridTrackListRef createFixed3x80Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGPoints(80)); + YGGridTrackListAddTrack(tracks, YGPoints(80)); + YGGridTrackListAddTrack(tracks, YGPoints(80)); + return tracks; +} + +static YGGridTrackListRef createAuto4Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGAuto()); + YGGridTrackListAddTrack(tracks, YGAuto()); + YGGridTrackListAddTrack(tracks, YGAuto()); + YGGridTrackListAddTrack(tracks, YGAuto()); + return tracks; +} + +static YGGridTrackListRef createAuto2Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGAuto()); + YGGridTrackListAddTrack(tracks, YGAuto()); + return tracks; +} + +static YGGridTrackListRef createPercent3Tracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGPercent(25)); + YGGridTrackListAddTrack(tracks, YGPercent(50)); + YGGridTrackListAddTrack(tracks, YGPercent(25)); + return tracks; +} + +static YGGridTrackListRef createPercent3RowTracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGPercent(33.33f)); + YGGridTrackListAddTrack(tracks, YGPercent(33.33f)); + YGGridTrackListAddTrack(tracks, YGPercent(33.33f)); + return tracks; +} + +static YGGridTrackListRef createMixedColumnTracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGPoints(200)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGPoints(200)); + return tracks; +} + +static YGGridTrackListRef createMixedRowTracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGPoints(60)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGPoints(40)); + return tracks; +} + +static YGGridTrackListRef createMinmaxColumnTracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGMinMax(YGPoints(100), YGFr(1))); + YGGridTrackListAddTrack(tracks, YGMinMax(YGPoints(100), YGFr(1))); + YGGridTrackListAddTrack(tracks, YGMinMax(YGPoints(100), YGFr(1))); + return tracks; +} + +static YGGridTrackListRef createMinmaxRowTracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + YGGridTrackListAddTrack(tracks, YGMinMax(YGPoints(50), YGAuto())); + YGGridTrackListAddTrack(tracks, YGMinMax(YGPoints(50), YGAuto())); + YGGridTrackListAddTrack(tracks, YGMinMax(YGPoints(50), YGAuto())); + return tracks; +} + +static YGGridTrackListRef createMixed20ColumnTracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + for (int i = 0; i < 5; i++) { + YGGridTrackListAddTrack(tracks, YGPoints(100)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGAuto()); + YGGridTrackListAddTrack(tracks, YGMinMax(YGPoints(50), YGFr(1))); + } + return tracks; +} + +static YGGridTrackListRef createMixed50RowTracks(void) { + YGGridTrackListRef tracks = YGGridTrackListCreate(); + for (int i = 0; i < 10; i++) { + YGGridTrackListAddTrack(tracks, YGPoints(40)); + YGGridTrackListAddTrack(tracks, YGFr(1)); + YGGridTrackListAddTrack(tracks, YGAuto()); + YGGridTrackListAddTrack(tracks, YGMinMax(YGPoints(30), YGAuto())); + YGGridTrackListAddTrack(tracks, YGFr(2)); + } + return tracks; +} + +YGBENCHMARKS({ + // Scenario 1: Basic fixed-size grid + YGBENCHMARK("Grid 3x3 fixed tracks", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetGridTemplateColumns(root, createFixed3x100Tracks()); + YGNodeStyleSetGridTemplateRows(root, createFixed3x100Tracks()); + + for (uint32_t i = 0; i < 9; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 2: Grid with auto-sized items + YGBENCHMARK("Grid 3x3 auto tracks", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetGridTemplateColumns(root, createAuto3Tracks()); + YGNodeStyleSetGridTemplateRows(root, createAuto3Tracks()); + + for (uint32_t i = 0; i < 9; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeSetMeasureFunc(child, _measureFixed); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 3: Grid with fr units + YGBENCHMARK("Grid 3x3 fr tracks", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetGridTemplateColumns(root, createFr3Tracks()); + YGNodeStyleSetGridTemplateRows(root, createFr3Tracks()); + + for (uint32_t i = 0; i < 9; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 4: Grid with gaps + YGBENCHMARK("Grid 4x4 with gaps", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetGap(root, YGGutterAll, 10); + YGNodeStyleSetGridTemplateColumns(root, createFr4Tracks()); + YGNodeStyleSetGridTemplateRows(root, createFr4Tracks()); + + for (uint32_t i = 0; i < 16; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 5: Mixed fixed and flexible tracks + YGBENCHMARK("Grid mixed tracks (fixed + fr)", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 800); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetGridTemplateColumns(root, createMixedColumnTracks()); + YGNodeStyleSetGridTemplateRows(root, createMixedRowTracks()); + + for (uint32_t i = 0; i < 9; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 6: Grid with spanning items + YGBENCHMARK("Grid with spanning items", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetGap(root, YGGutterAll, 8); + YGNodeStyleSetGridTemplateColumns(root, createFr4Tracks()); + YGNodeStyleSetGridTemplateRows(root, createFr4Tracks()); + + const YGNodeRef child1 = YGNodeNew(); + YGNodeStyleSetGridColumnStart(child1, 1); + YGNodeStyleSetGridColumnEndSpan(child1, 2); + YGNodeInsertChild(root, child1, 0); + + const YGNodeRef child2 = YGNodeNew(); + YGNodeStyleSetGridRowStart(child2, 1); + YGNodeStyleSetGridRowEndSpan(child2, 2); + YGNodeInsertChild(root, child2, 1); + + const YGNodeRef child3 = YGNodeNew(); + YGNodeStyleSetGridColumnStart(child3, 3); + YGNodeStyleSetGridColumnEndSpan(child3, 2); + YGNodeStyleSetGridRowStart(child3, 3); + YGNodeStyleSetGridRowEndSpan(child3, 2); + YGNodeInsertChild(root, child3, 2); + + for (uint32_t i = 0; i < 8; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeInsertChild(root, child, 3 + i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 7: Auto-placement + YGBENCHMARK("Grid auto-placement 5x5", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetGridTemplateColumns(root, createFr5Tracks()); + YGNodeStyleSetGridTemplateRows(root, createFr5Tracks()); + + for (uint32_t i = 0; i < 25; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 8: Nested grids + YGBENCHMARK("Nested grids 3x3 with 2x2 children", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetGap(root, YGGutterAll, 10); + YGNodeStyleSetGridTemplateColumns(root, createFr3Tracks()); + YGNodeStyleSetGridTemplateRows(root, createFr3Tracks()); + + for (uint32_t i = 0; i < 9; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeStyleSetDisplay(child, YGDisplayGrid); + YGNodeStyleSetGap(child, YGGutterAll, 4); + YGNodeStyleSetGridTemplateColumns(child, createFr2Tracks()); + YGNodeStyleSetGridTemplateRows(child, createFr2Tracks()); + YGNodeInsertChild(root, child, i); + + for (uint32_t j = 0; j < 4; j++) { + const YGNodeRef grandChild = YGNodeNew(); + YGNodeInsertChild(child, grandChild, j); + } + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 9: Grid with alignment + YGBENCHMARK("Grid with alignment", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetJustifyContent(root, YGJustifyCenter); + YGNodeStyleSetAlignContent(root, YGAlignCenter); + YGNodeStyleSetGap(root, YGGutterAll, 10); + YGNodeStyleSetGridTemplateColumns(root, createFixed3x80Tracks()); + YGNodeStyleSetGridTemplateRows(root, createFixed3x80Tracks()); + + for (uint32_t i = 0; i < 9; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeStyleSetAlignSelf(child, YGAlignCenter); + YGNodeStyleSetWidth(child, 60); + YGNodeStyleSetHeight(child, 60); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 10: Grid with intrinsic sizing and measure functions + YGBENCHMARK("Grid auto tracks with measure", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetGridTemplateColumns(root, createAuto4Tracks()); + YGNodeStyleSetGridTemplateRows(root, createAuto4Tracks()); + + for (uint32_t i = 0; i < 16; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeSetMeasureFunc(child, _measure); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 11: minmax tracks + YGBENCHMARK("Grid minmax tracks", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetGap(root, YGGutterAll, 10); + YGNodeStyleSetGridTemplateColumns(root, createMinmaxColumnTracks()); + YGNodeStyleSetGridTemplateRows(root, createMinmaxRowTracks()); + + for (uint32_t i = 0; i < 9; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeSetMeasureFunc(child, _measureFixed); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 12: Indefinite container size + YGBENCHMARK("Grid indefinite container", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetGridTemplateColumns(root, createAuto3Tracks()); + YGNodeStyleSetGridTemplateRows(root, createAuto2Tracks()); + + for (uint32_t i = 0; i < 6; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeStyleSetWidth(child, 80); + YGNodeStyleSetHeight(child, 60); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 13: Grid with percentage tracks + YGBENCHMARK("Grid percentage tracks", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetGridTemplateColumns(root, createPercent3Tracks()); + YGNodeStyleSetGridTemplateRows(root, createPercent3RowTracks()); + + for (uint32_t i = 0; i < 9; i++) { + const YGNodeRef child = YGNodeNew(); + YGNodeInsertChild(root, child, i); + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); + + // Scenario 14: Stress test - 1000 items with mixed tracks and spanning + YGBENCHMARK("Stress test 1000 items mixed", { + const YGNodeRef root = YGNodeNew(); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 2000); + YGNodeStyleSetHeight(root, 5000); + YGNodeStyleSetGap(root, YGGutterColumn, 8); + YGNodeStyleSetGap(root, YGGutterRow, 4); + YGNodeStyleSetGridTemplateColumns(root, createMixed20ColumnTracks()); + YGNodeStyleSetGridTemplateRows(root, createMixed50RowTracks()); + + uint32_t childIndex = 0; + + for (uint32_t row = 1; row <= 50; row++) { + for (uint32_t col = 1; col <= 20; col++) { + const YGNodeRef child = YGNodeNew(); + + if (childIndex % 30 == 0 && col <= 17) { + YGNodeStyleSetGridColumnStart(child, (int)col); + YGNodeStyleSetGridColumnEndSpan(child, 3); + YGNodeStyleSetGridRowStart(child, (int)row); + } + else if (childIndex % 40 == 0 && col <= 16) { + YGNodeStyleSetGridColumnStart(child, (int)col); + YGNodeStyleSetGridColumnEndSpan(child, 4); + YGNodeStyleSetGridRowStart(child, (int)row); + } + else if (childIndex % 50 == 0 && row <= 48) { + YGNodeStyleSetGridColumnStart(child, (int)col); + YGNodeStyleSetGridRowStart(child, (int)row); + YGNodeStyleSetGridRowEndSpan(child, 2); + } + else if (childIndex % 70 == 0 && row <= 47) { + YGNodeStyleSetGridColumnStart(child, (int)col); + YGNodeStyleSetGridRowStart(child, (int)row); + YGNodeStyleSetGridRowEndSpan(child, 3); + } + else if (childIndex % 100 == 0 && col <= 18 && row <= 48) { + YGNodeStyleSetGridColumnStart(child, (int)col); + YGNodeStyleSetGridColumnEndSpan(child, 2); + YGNodeStyleSetGridRowStart(child, (int)row); + YGNodeStyleSetGridRowEndSpan(child, 2); + } + else if (childIndex % 150 == 0 && col <= 17 && row <= 48) { + YGNodeStyleSetGridColumnStart(child, (int)col); + YGNodeStyleSetGridColumnEndSpan(child, 3); + YGNodeStyleSetGridRowStart(child, (int)row); + YGNodeStyleSetGridRowEndSpan(child, 2); + } + else if (childIndex % 200 == 0 && col <= 18 && row <= 47) { + YGNodeStyleSetGridColumnStart(child, (int)col); + YGNodeStyleSetGridColumnEndSpan(child, 2); + YGNodeStyleSetGridRowStart(child, (int)row); + YGNodeStyleSetGridRowEndSpan(child, 3); + } + else if (childIndex % 300 == 0 && col <= 16 && row <= 47) { + YGNodeStyleSetGridColumnStart(child, (int)col); + YGNodeStyleSetGridColumnEndSpan(child, 4); + YGNodeStyleSetGridRowStart(child, (int)row); + YGNodeStyleSetGridRowEndSpan(child, 3); + } + else if (childIndex % 500 == 0 && col <= 15 && row <= 46) { + YGNodeStyleSetGridColumnStart(child, (int)col); + YGNodeStyleSetGridColumnEndSpan(child, 5); + YGNodeStyleSetGridRowStart(child, (int)row); + YGNodeStyleSetGridRowEndSpan(child, 4); + } + + YGNodeInsertChild(root, child, childIndex); + childIndex++; + + if (childIndex >= 1000) break; + } + if (childIndex >= 1000) break; + } + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + YGNodeFreeRecursive(root); + }); +}); diff --git a/benchmark/benchmarkgrid b/benchmark/benchmarkgrid new file mode 100755 index 0000000000..7bc73b4c7b --- /dev/null +++ b/benchmark/benchmarkgrid @@ -0,0 +1,10 @@ +#!/bin/sh +# 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. +cd "$(dirname "$0")" || exit + +cmake -B build -S . -D CMAKE_BUILD_TYPE=Release +cmake --build build --target benchmarkgrid +build/benchmarkgrid diff --git a/enums.py b/enums.py index 5511f49d46..79c9b7e24c 100755 --- a/enums.py +++ b/enums.py @@ -19,12 +19,16 @@ ], "FlexDirection": ["Column", "ColumnReverse", "Row", "RowReverse"], "Justify": [ + "Auto", "FlexStart", "Center", "FlexEnd", "SpaceBetween", "SpaceAround", "SpaceEvenly", + "Stretch", + "Start", + "End", ], "Overflow": ["Visible", "Hidden", "Scroll"], "Align": [ @@ -37,9 +41,11 @@ "SpaceBetween", "SpaceAround", "SpaceEvenly", + "Start", + "End", ], "PositionType": ["Static", "Relative", "Absolute"], - "Display": ["Flex", "None", "Contents"], + "Display": ["Flex", "None", "Contents", "Grid"], "Wrap": ["NoWrap", "Wrap", "WrapReverse"], "BoxSizing": ["BorderBox", "ContentBox"], "MeasureMode": ["Undefined", "Exactly", "AtMost"], @@ -62,6 +68,7 @@ "WebFlexBasis", ], "Gutter": ["Column", "Row", "All"], + "GridTrackType": ["Auto", "Points", "Percent", "Fr", "Minmax"], # Known incorrect behavior which can be enabled for compatibility "Errata": [ # Default: Standards conformant mode diff --git a/gentest/fixtures/grid/YGGridTest.html b/gentest/fixtures/grid/YGGridTest.html new file mode 100644 index 0000000000..8f961ab592 --- /dev/null +++ b/gentest/fixtures/grid/YGGridTest.html @@ -0,0 +1,1490 @@ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ + + +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
diff --git a/gentest/fixtures/grid/YGGridTestFlows.html b/gentest/fixtures/grid/YGGridTestFlows.html new file mode 100644 index 0000000000..23a670ab67 --- /dev/null +++ b/gentest/fixtures/grid/YGGridTestFlows.html @@ -0,0 +1,1468 @@ + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+ + + + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+ + +
+ +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + +
+
+
+
+
+ + + + + +
+
+
+
+
+ + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
Lorem ipsum dolor sit amet, consectetur
+
+
+ +
+
Lorem ipsum dolor sit amet, consectetur
+
+
+ +
+
+ Lorem ipsum dolor sit amet, consectetur +
+
+
diff --git a/gentest/fixtures/grid/grid_aspect_ratio_height_to_width.html b/gentest/fixtures/grid/grid_aspect_ratio_height_to_width.html new file mode 100644 index 0000000000..7cb87d53de --- /dev/null +++ b/gentest/fixtures/grid/grid_aspect_ratio_height_to_width.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/grid_aspect_ratio_min_max_constraints.html b/gentest/fixtures/grid/grid_aspect_ratio_min_max_constraints.html new file mode 100644 index 0000000000..e97262ff0b --- /dev/null +++ b/gentest/fixtures/grid/grid_aspect_ratio_min_max_constraints.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/grid_aspect_ratio_percentage_auto_margin.html b/gentest/fixtures/grid/grid_aspect_ratio_percentage_auto_margin.html new file mode 100644 index 0000000000..5b066e0120 --- /dev/null +++ b/gentest/fixtures/grid/grid_aspect_ratio_percentage_auto_margin.html @@ -0,0 +1,5 @@ +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/grid_aspect_ratio_reresolution_auto_rows.html b/gentest/fixtures/grid/grid_aspect_ratio_reresolution_auto_rows.html new file mode 100644 index 0000000000..d935dbf01d --- /dev/null +++ b/gentest/fixtures/grid/grid_aspect_ratio_reresolution_auto_rows.html @@ -0,0 +1,4 @@ +
+
+
+
diff --git a/gentest/fixtures/grid/grid_aspect_ratio_spanning_items.html b/gentest/fixtures/grid/grid_aspect_ratio_spanning_items.html new file mode 100644 index 0000000000..ff0e259e3a --- /dev/null +++ b/gentest/fixtures/grid/grid_aspect_ratio_spanning_items.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/grid_aspect_ratio_spanning_with_content_distribution.html b/gentest/fixtures/grid/grid_aspect_ratio_spanning_with_content_distribution.html new file mode 100644 index 0000000000..30971b33e4 --- /dev/null +++ b/gentest/fixtures/grid/grid_aspect_ratio_spanning_with_content_distribution.html @@ -0,0 +1,5 @@ +
+
+
+
+
diff --git a/gentest/fixtures/grid/grid_aspect_ratio_triggers_reresolution.html b/gentest/fixtures/grid/grid_aspect_ratio_triggers_reresolution.html new file mode 100644 index 0000000000..e524b03d35 --- /dev/null +++ b/gentest/fixtures/grid/grid_aspect_ratio_triggers_reresolution.html @@ -0,0 +1,3 @@ +
+
+
diff --git a/gentest/fixtures/grid/grid_aspect_ratio_width_to_height.html b/gentest/fixtures/grid/grid_aspect_ratio_width_to_height.html new file mode 100644 index 0000000000..14249bfa83 --- /dev/null +++ b/gentest/fixtures/grid/grid_aspect_ratio_width_to_height.html @@ -0,0 +1,5 @@ + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/grid_auto_margin_overflow_block.html b/gentest/fixtures/grid/grid_auto_margin_overflow_block.html new file mode 100644 index 0000000000..f7f4f72b17 --- /dev/null +++ b/gentest/fixtures/grid/grid_auto_margin_overflow_block.html @@ -0,0 +1,11 @@ +
+
+
diff --git a/gentest/fixtures/grid/grid_auto_margin_overflow_inline.html b/gentest/fixtures/grid/grid_auto_margin_overflow_inline.html new file mode 100644 index 0000000000..b8adfe4ceb --- /dev/null +++ b/gentest/fixtures/grid/grid_auto_margin_overflow_inline.html @@ -0,0 +1,11 @@ +
+
+
diff --git a/gentest/fixtures/grid/grid_complex_mixed_spanning_alignment.html b/gentest/fixtures/grid/grid_complex_mixed_spanning_alignment.html new file mode 100644 index 0000000000..f4026cc2d9 --- /dev/null +++ b/gentest/fixtures/grid/grid_complex_mixed_spanning_alignment.html @@ -0,0 +1,29 @@ +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/grid_distribute_space_flex_auto.html b/gentest/fixtures/grid/grid_distribute_space_flex_auto.html new file mode 100644 index 0000000000..b55bc9137d --- /dev/null +++ b/gentest/fixtures/grid/grid_distribute_space_flex_auto.html @@ -0,0 +1,14 @@ +
+
+
+
+
+
diff --git a/gentest/fixtures/grid/grid_expand_flexible_indefinite_free_space.html b/gentest/fixtures/grid/grid_expand_flexible_indefinite_free_space.html new file mode 100644 index 0000000000..9426db2acf --- /dev/null +++ b/gentest/fixtures/grid/grid_expand_flexible_indefinite_free_space.html @@ -0,0 +1,9 @@ + + +
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/absolute_correct_cross_child_size_with_percentage.html b/gentest/fixtures/grid/taffy/absolute_correct_cross_child_size_with_percentage.html new file mode 100644 index 0000000000..b1f4d00f8c --- /dev/null +++ b/gentest/fixtures/grid/taffy/absolute_correct_cross_child_size_with_percentage.html @@ -0,0 +1,11 @@ + + +
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/chrome_issue_325928327.html b/gentest/fixtures/grid/taffy/chrome_issue_325928327.html new file mode 100644 index 0000000000..9300a77f6c --- /dev/null +++ b/gentest/fixtures/grid/taffy/chrome_issue_325928327.html @@ -0,0 +1,9 @@ + + +
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_align_self_sized_all.html b/gentest/fixtures/grid/taffy/grid_absolute_align_self_sized_all.html new file mode 100644 index 0000000000..e28a8d3507 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_align_self_sized_all.html @@ -0,0 +1,12 @@ + + +
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_bottom_left.html b/gentest/fixtures/grid/taffy/grid_absolute_container_bottom_left.html new file mode 100644 index 0000000000..966d50f15b --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_bottom_left.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_bottom_left_margin.html b/gentest/fixtures/grid/taffy/grid_absolute_container_bottom_left_margin.html new file mode 100644 index 0000000000..7e8b0b65a1 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_bottom_left_margin.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_left_overrides_right.html b/gentest/fixtures/grid/taffy/grid_absolute_container_left_overrides_right.html new file mode 100644 index 0000000000..4875bfa8f4 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_left_overrides_right.html @@ -0,0 +1,20 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_left_right.html b/gentest/fixtures/grid/taffy/grid_absolute_container_left_right.html new file mode 100644 index 0000000000..a3eaf9d193 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_left_right.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_left_right_margin.html b/gentest/fixtures/grid/taffy/grid_absolute_container_left_right_margin.html new file mode 100644 index 0000000000..d764bfab43 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_left_right_margin.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_negative_position.html b/gentest/fixtures/grid/taffy/grid_absolute_container_negative_position.html new file mode 100644 index 0000000000..aafd58f069 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_negative_position.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_negative_position_margin.html b/gentest/fixtures/grid/taffy/grid_absolute_container_negative_position_margin.html new file mode 100644 index 0000000000..641e35001d --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_negative_position_margin.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_top_bottom.html b/gentest/fixtures/grid/taffy/grid_absolute_container_top_bottom.html new file mode 100644 index 0000000000..575ea943d4 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_top_bottom.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_top_bottom_margin.html b/gentest/fixtures/grid/taffy/grid_absolute_container_top_bottom_margin.html new file mode 100644 index 0000000000..f635fec3dd --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_top_bottom_margin.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_top_right.html b/gentest/fixtures/grid/taffy/grid_absolute_container_top_right.html new file mode 100644 index 0000000000..846cd84e25 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_top_right.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_container_top_right_margin.html b/gentest/fixtures/grid/taffy/grid_absolute_container_top_right_margin.html new file mode 100644 index 0000000000..558f7355bf --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_container_top_right_margin.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_justify_self_sized_all.html b/gentest/fixtures/grid/taffy/grid_absolute_justify_self_sized_all.html new file mode 100644 index 0000000000..5b68035787 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_justify_self_sized_all.html @@ -0,0 +1,12 @@ + + +
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_layout_within_border.html b/gentest/fixtures/grid/taffy/grid_absolute_layout_within_border.html new file mode 100644 index 0000000000..9373e22bd3 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_layout_within_border.html @@ -0,0 +1,8 @@ + + +
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_layout_within_border_static.html b/gentest/fixtures/grid/taffy/grid_absolute_layout_within_border_static.html new file mode 100644 index 0000000000..918535fe40 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_layout_within_border_static.html @@ -0,0 +1,8 @@ + + +
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_resolved_insets.html b/gentest/fixtures/grid/taffy/grid_absolute_resolved_insets.html new file mode 100644 index 0000000000..9befcb5282 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_resolved_insets.html @@ -0,0 +1,33 @@ + + +
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_top_overrides_bottom.html b/gentest/fixtures/grid/taffy/grid_absolute_top_overrides_bottom.html new file mode 100644 index 0000000000..a50ad21bde --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_top_overrides_bottom.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_with_padding.html b/gentest/fixtures/grid/taffy/grid_absolute_with_padding.html new file mode 100644 index 0000000000..294b1f23a1 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_with_padding.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_absolute_with_padding_and_margin.html b/gentest/fixtures/grid/taffy/grid_absolute_with_padding_and_margin.html new file mode 100644 index 0000000000..eb8b82586b --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_absolute_with_padding_and_margin.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_align_content_center.html b/gentest/fixtures/grid/taffy/grid_align_content_center.html new file mode 100644 index 0000000000..69cc3692cd --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_center.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_align_content_center_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_align_content_center_negative_space_gap.html new file mode 100644 index 0000000000..60476ce1b2 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_center_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_end.html b/gentest/fixtures/grid/taffy/grid_align_content_end.html new file mode 100644 index 0000000000..bce99e0442 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_end.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_end_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_align_content_end_negative_space_gap.html new file mode 100644 index 0000000000..a70841eed3 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_end_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_end_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_align_content_end_with_padding_border.html new file mode 100644 index 0000000000..d72c337df2 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_end_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_align_content_space_around.html b/gentest/fixtures/grid/taffy/grid_align_content_space_around.html new file mode 100644 index 0000000000..103cd64c96 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_space_around.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_space_around_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_align_content_space_around_negative_space_gap.html new file mode 100644 index 0000000000..c9a7e9cb13 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_space_around_negative_space_gap.html @@ -0,0 +1,13 @@ +
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_align_content_space_around_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_align_content_space_around_with_padding_border.html new file mode 100644 index 0000000000..eea8d163a9 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_space_around_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_space_between.html b/gentest/fixtures/grid/taffy/grid_align_content_space_between.html new file mode 100644 index 0000000000..1c35679b31 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_space_between.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_space_between_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_align_content_space_between_negative_space_gap.html new file mode 100644 index 0000000000..0039ac49c3 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_space_between_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_space_between_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_align_content_space_between_with_padding_border.html new file mode 100644 index 0000000000..d3c882b25c --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_space_between_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_space_evenly.html b/gentest/fixtures/grid/taffy/grid_align_content_space_evenly.html new file mode 100644 index 0000000000..0a191bea89 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_space_evenly.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_space_evenly_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_align_content_space_evenly_negative_space_gap.html new file mode 100644 index 0000000000..64645eb7a8 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_space_evenly_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_space_evenly_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_align_content_space_evenly_with_padding_border.html new file mode 100644 index 0000000000..0ed3122e33 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_space_evenly_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_start.html b/gentest/fixtures/grid/taffy/grid_align_content_start.html new file mode 100644 index 0000000000..fd37831ad2 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_start.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_start_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_align_content_start_negative_space_gap.html new file mode 100644 index 0000000000..3a85388f01 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_start_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_content_start_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_align_content_start_with_padding_border.html new file mode 100644 index 0000000000..eec57719c3 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_content_start_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline.html new file mode 100644 index 0000000000..5b743d81e7 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_child.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child.html new file mode 100644 index 0000000000..a364e00337 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child.html @@ -0,0 +1,8 @@ + + +
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_margin.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_margin.html new file mode 100644 index 0000000000..9afc07fe3f --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_margin.html @@ -0,0 +1,8 @@ + + +
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_margin_percent.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_margin_percent.html new file mode 100644 index 0000000000..5e1d19c5bb --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_margin_percent.html @@ -0,0 +1,8 @@ + + +
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_multiline.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_multiline.html new file mode 100644 index 0000000000..3dbaa1e252 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_multiline.html @@ -0,0 +1,11 @@ + + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_multiline_no_override_on_secondline.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_multiline_no_override_on_secondline.html new file mode 100644 index 0000000000..95fb9257da --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_multiline_no_override_on_secondline.html @@ -0,0 +1,11 @@ + + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_multiline_override.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_multiline_override.html new file mode 100644 index 0000000000..cc8b268d9e --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_multiline_override.html @@ -0,0 +1,11 @@ + + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_padding.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_padding.html new file mode 100644 index 0000000000..1cebd6a69f --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_padding.html @@ -0,0 +1,8 @@ + + +
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_top.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_top.html new file mode 100644 index 0000000000..18b4bf0a3f --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_top.html @@ -0,0 +1,8 @@ + + +
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_top2.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_top2.html new file mode 100644 index 0000000000..3bb31435f2 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_child_top2.html @@ -0,0 +1,8 @@ + + +
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_complex.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_complex.html new file mode 100644 index 0000000000..8d672caf42 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_complex.html @@ -0,0 +1,21 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_double_nested_child.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_double_nested_child.html new file mode 100644 index 0000000000..df0e657bab --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_double_nested_child.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_multiline.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_multiline.html new file mode 100644 index 0000000000..00580fcc2c --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_multiline.html @@ -0,0 +1,12 @@ + + +
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_multiline_column.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_multiline_column.html new file mode 100644 index 0000000000..1bb22db1aa --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_multiline_column.html @@ -0,0 +1,12 @@ + + +
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_multiline_row_and_column.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_multiline_row_and_column.html new file mode 100644 index 0000000000..b10e77617b --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_multiline_row_and_column.html @@ -0,0 +1,12 @@ + + +
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_align_items_baseline_nested_column.html b/gentest/fixtures/grid/taffy/grid_align_items_baseline_nested_column.html new file mode 100644 index 0000000000..88bd681073 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_baseline_nested_column.html @@ -0,0 +1,11 @@ + + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_sized_center.html b/gentest/fixtures/grid/taffy/grid_align_items_sized_center.html new file mode 100644 index 0000000000..e5d71ae50a --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_sized_center.html @@ -0,0 +1,6 @@ + + +
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_align_items_sized_end.html b/gentest/fixtures/grid/taffy/grid_align_items_sized_end.html new file mode 100644 index 0000000000..a24e11d95e --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_sized_end.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_sized_start.html b/gentest/fixtures/grid/taffy/grid_align_items_sized_start.html new file mode 100644 index 0000000000..aa921184cf --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_sized_start.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_align_items_sized_stretch.html b/gentest/fixtures/grid/taffy/grid_align_items_sized_stretch.html new file mode 100644 index 0000000000..2e96af64cb --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_items_sized_stretch.html @@ -0,0 +1,6 @@ + + +
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_align_self_sized_all.html b/gentest/fixtures/grid/taffy/grid_align_self_sized_all.html new file mode 100644 index 0000000000..2858cc265e --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_align_self_sized_all.html @@ -0,0 +1,12 @@ + + +
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_absolute_width_overrides_inset.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_absolute_width_overrides_inset.html new file mode 100644 index 0000000000..041795962f --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_absolute_width_overrides_inset.html @@ -0,0 +1,5 @@ + + +
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_child_fill_content_height.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_child_fill_content_height.html new file mode 100644 index 0000000000..841a34f7fd --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_child_fill_content_height.html @@ -0,0 +1,6 @@ + + +
+
HHHH
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_child_fill_content_width.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_child_fill_content_width.html new file mode 100644 index 0000000000..c710602b42 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_child_fill_content_width.html @@ -0,0 +1,6 @@ + + +
+
HHHH
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_height.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_height.html new file mode 100644 index 0000000000..fe593db76b --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_height.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_max_height.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_max_height.html new file mode 100644 index 0000000000..f92531874f --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_max_height.html @@ -0,0 +1,5 @@ + + +
+
HH​HH​HH​HH​HH​HH
+
diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_max_width.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_max_width.html new file mode 100644 index 0000000000..8347274df4 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_max_width.html @@ -0,0 +1,5 @@ + + +
+
HH HH HH HH
+
diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_min_height.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_min_height.html new file mode 100644 index 0000000000..4321f4224e --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_min_height.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_width.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_width.html new file mode 100644 index 0000000000..0ee91c4768 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_fill_child_width.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_overridden_by_explicit_sizes.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_overridden_by_explicit_sizes.html new file mode 100644 index 0000000000..a504fbc3e0 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_overridden_by_explicit_sizes.html @@ -0,0 +1,5 @@ + + +
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_aspect_ratio_overridden_by_explicit_sizes_flex.html b/gentest/fixtures/grid/taffy/grid_aspect_ratio_overridden_by_explicit_sizes_flex.html new file mode 100644 index 0000000000..c6ad4d17ce --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_aspect_ratio_overridden_by_explicit_sizes_flex.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_auto_rows.html b/gentest/fixtures/grid/taffy/grid_auto_rows.html new file mode 100644 index 0000000000..99f52e04f2 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_auto_rows.html @@ -0,0 +1,12 @@ + + +
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_auto_single_item.html b/gentest/fixtures/grid/taffy/grid_auto_single_item.html new file mode 100644 index 0000000000..9660c2e66a --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_auto_single_item.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_auto_single_item_fixed_width.html b/gentest/fixtures/grid/taffy/grid_auto_single_item_fixed_width.html new file mode 100644 index 0000000000..52d4c20a47 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_auto_single_item_fixed_width.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_auto_single_item_fixed_width_with_definite_width.html b/gentest/fixtures/grid/taffy/grid_auto_single_item_fixed_width_with_definite_width.html new file mode 100644 index 0000000000..955931b00e --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_auto_single_item_fixed_width_with_definite_width.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_auto_takes_precedence_over_fr.html b/gentest/fixtures/grid/taffy/grid_auto_takes_precedence_over_fr.html new file mode 100644 index 0000000000..57aaffa2eb --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_auto_takes_precedence_over_fr.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_available_space_greater_than_max_content.html b/gentest/fixtures/grid/taffy/grid_available_space_greater_than_max_content.html new file mode 100644 index 0000000000..df7ffce36c --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_available_space_greater_than_max_content.html @@ -0,0 +1,8 @@ + + +
+
+
HH HH HH HH
+
HH HH HH HH
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_basic.html b/gentest/fixtures/grid/taffy/grid_basic.html new file mode 100644 index 0000000000..55dd67456c --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_basic.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_basic_implicit_tracks.html b/gentest/fixtures/grid/taffy/grid_basic_implicit_tracks.html new file mode 100644 index 0000000000..0e94800282 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_basic_implicit_tracks.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_basic_with_overflow.html b/gentest/fixtures/grid/taffy/grid_basic_with_overflow.html new file mode 100644 index 0000000000..7472ef90ab --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_basic_with_overflow.html @@ -0,0 +1,14 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_basic_with_padding.html b/gentest/fixtures/grid/taffy/grid_basic_with_padding.html new file mode 100644 index 0000000000..8dd84ba654 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_basic_with_padding.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_display_none_fixed_size.html b/gentest/fixtures/grid/taffy/grid_display_none_fixed_size.html new file mode 100644 index 0000000000..e84d90472c --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_display_none_fixed_size.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_fr_fixed_size_no_content_proportions.html b/gentest/fixtures/grid/taffy/grid_fr_fixed_size_no_content_proportions.html new file mode 100644 index 0000000000..56740abe60 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_fixed_size_no_content_proportions.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_fr_fixed_size_no_content_proportions_sub_1_sum.html b/gentest/fixtures/grid/taffy/grid_fr_fixed_size_no_content_proportions_sub_1_sum.html new file mode 100644 index 0000000000..a1f6841d4a --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_fixed_size_no_content_proportions_sub_1_sum.html @@ -0,0 +1,6 @@ + + +
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_fr_fixed_size_single_item.html b/gentest/fixtures/grid/taffy/grid_fr_fixed_size_single_item.html new file mode 100644 index 0000000000..461fdfe133 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_fixed_size_single_item.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_fr_no_sized_items_indefinite.html b/gentest/fixtures/grid/taffy/grid_fr_no_sized_items_indefinite.html new file mode 100644 index 0000000000..0c923ea96e --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_no_sized_items_indefinite.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_fr_single_item_indefinite.html b/gentest/fixtures/grid/taffy/grid_fr_single_item_indefinite.html new file mode 100644 index 0000000000..dd637e6023 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_single_item_indefinite.html @@ -0,0 +1,16 @@ + + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion.html b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion.html new file mode 100644 index 0000000000..459de07fd3 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion.html @@ -0,0 +1,8 @@ + + + +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_sub_1_sum.html b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_sub_1_sum.html new file mode 100644 index 0000000000..5e4848e598 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_sub_1_sum.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_with_non_spanned_track.html b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_with_non_spanned_track.html new file mode 100644 index 0000000000..84ba566348 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_with_non_spanned_track.html @@ -0,0 +1,12 @@ + + + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_zero_sum.html b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_zero_sum.html new file mode 100644 index 0000000000..b8a2c6d246 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_zero_sum.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.html b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.html new file mode 100644 index 0000000000..c25994ad78 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.html @@ -0,0 +1,9 @@ + + +
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_gap.html b/gentest/fixtures/grid/taffy/grid_gap.html new file mode 100644 index 0000000000..13f2f9453d --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_gap.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_hidden.html b/gentest/fixtures/grid/taffy/grid_hidden.html new file mode 100644 index 0000000000..fa2eb873f9 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_hidden.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_center.html b/gentest/fixtures/grid/taffy/grid_justify_content_center.html new file mode 100644 index 0000000000..6f049fc6d6 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_center.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_center_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_justify_content_center_negative_space_gap.html new file mode 100644 index 0000000000..a43ba7378b --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_center_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_center_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_justify_content_center_with_padding_border.html new file mode 100644 index 0000000000..5e548adc55 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_center_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_end.html b/gentest/fixtures/grid/taffy/grid_justify_content_end.html new file mode 100644 index 0000000000..f9272b0129 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_end.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_end_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_justify_content_end_negative_space_gap.html new file mode 100644 index 0000000000..417c8648d0 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_end_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_end_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_justify_content_end_with_padding_border.html new file mode 100644 index 0000000000..3c9d5dfc9c --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_end_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_space_around.html b/gentest/fixtures/grid/taffy/grid_justify_content_space_around.html new file mode 100644 index 0000000000..4eed358a71 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_space_around.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_space_around_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_justify_content_space_around_negative_space_gap.html new file mode 100644 index 0000000000..d260aecaff --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_space_around_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_space_around_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_justify_content_space_around_with_padding_border.html new file mode 100644 index 0000000000..55696ebac2 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_space_around_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_space_between.html b/gentest/fixtures/grid/taffy/grid_justify_content_space_between.html new file mode 100644 index 0000000000..3fc4b17011 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_space_between.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_space_between_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_justify_content_space_between_negative_space_gap.html new file mode 100644 index 0000000000..dc612db6cb --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_space_between_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_space_between_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_justify_content_space_between_with_padding_border.html new file mode 100644 index 0000000000..470e711b27 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_space_between_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_space_evenly.html b/gentest/fixtures/grid/taffy/grid_justify_content_space_evenly.html new file mode 100644 index 0000000000..00bc9ec840 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_space_evenly.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_space_evenly_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_justify_content_space_evenly_negative_space_gap.html new file mode 100644 index 0000000000..83d5ce7ab6 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_space_evenly_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_space_evenly_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_justify_content_space_evenly_with_padding_border.html new file mode 100644 index 0000000000..78b158064f --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_space_evenly_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_start.html b/gentest/fixtures/grid/taffy/grid_justify_content_start.html new file mode 100644 index 0000000000..e5ceea6d05 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_start.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_start_negative_space_gap.html b/gentest/fixtures/grid/taffy/grid_justify_content_start_negative_space_gap.html new file mode 100644 index 0000000000..e5cd905516 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_start_negative_space_gap.html @@ -0,0 +1,15 @@ + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_content_start_with_padding_border.html b/gentest/fixtures/grid/taffy/grid_justify_content_start_with_padding_border.html new file mode 100644 index 0000000000..1dd655c2d0 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_content_start_with_padding_border.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_items_sized_center.html b/gentest/fixtures/grid/taffy/grid_justify_items_sized_center.html new file mode 100644 index 0000000000..a6b71448d1 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_items_sized_center.html @@ -0,0 +1,6 @@ + + +
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_justify_items_sized_end.html b/gentest/fixtures/grid/taffy/grid_justify_items_sized_end.html new file mode 100644 index 0000000000..7b6dc5e229 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_items_sized_end.html @@ -0,0 +1,6 @@ + + +
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_justify_items_sized_start.html b/gentest/fixtures/grid/taffy/grid_justify_items_sized_start.html new file mode 100644 index 0000000000..b1894bc11a --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_items_sized_start.html @@ -0,0 +1,6 @@ + + +
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_justify_items_sized_stretch.html b/gentest/fixtures/grid/taffy/grid_justify_items_sized_stretch.html new file mode 100644 index 0000000000..4743bf3301 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_items_sized_stretch.html @@ -0,0 +1,6 @@ + + +
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_justify_self_sized_all.html b/gentest/fixtures/grid/taffy/grid_justify_self_sized_all.html new file mode 100644 index 0000000000..c50985fcbb --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_justify_self_sized_all.html @@ -0,0 +1,12 @@ + + +
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_margins_auto_margins.html b/gentest/fixtures/grid/taffy/grid_margins_auto_margins.html new file mode 100644 index 0000000000..42530b41bd --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_auto_margins.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_margins_auto_margins_override_stretch.html b/gentest/fixtures/grid/taffy/grid_margins_auto_margins_override_stretch.html new file mode 100644 index 0000000000..b41b83f8a2 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_auto_margins_override_stretch.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
HH​HH
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_margins_fixed_center.html b/gentest/fixtures/grid/taffy/grid_margins_fixed_center.html new file mode 100644 index 0000000000..108e162d97 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_fixed_center.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_margins_fixed_end.html b/gentest/fixtures/grid/taffy/grid_margins_fixed_end.html new file mode 100644 index 0000000000..b6469b6575 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_fixed_end.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_margins_fixed_start.html b/gentest/fixtures/grid/taffy/grid_margins_fixed_start.html new file mode 100644 index 0000000000..5c0ca70192 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_fixed_start.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_margins_fixed_stretch.html b/gentest/fixtures/grid/taffy/grid_margins_fixed_stretch.html new file mode 100644 index 0000000000..8de5a334e7 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_fixed_stretch.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_margins_percent_center.html b/gentest/fixtures/grid/taffy/grid_margins_percent_center.html new file mode 100644 index 0000000000..b3df1d9241 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_percent_center.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_margins_percent_end.html b/gentest/fixtures/grid/taffy/grid_margins_percent_end.html new file mode 100644 index 0000000000..8bc74730d4 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_percent_end.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_margins_percent_start.html b/gentest/fixtures/grid/taffy/grid_margins_percent_start.html new file mode 100644 index 0000000000..fb93c207d9 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_percent_start.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_margins_percent_stretch.html b/gentest/fixtures/grid/taffy/grid_margins_percent_stretch.html new file mode 100644 index 0000000000..0424c35673 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_margins_percent_stretch.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_minmax_auto_fixed_10px.html b/gentest/fixtures/grid/taffy/grid_minmax_auto_fixed_10px.html new file mode 100644 index 0000000000..ff2bc2fbcb --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_minmax_auto_fixed_10px.html @@ -0,0 +1,5 @@ + + +
+
HH​HH
+
diff --git a/gentest/fixtures/grid/taffy/grid_minmax_auto_percent_definite.html b/gentest/fixtures/grid/taffy/grid_minmax_auto_percent_definite.html new file mode 100644 index 0000000000..c436d7ebc1 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_minmax_auto_percent_definite.html @@ -0,0 +1,5 @@ + + +
+
HH​HH
+
diff --git a/gentest/fixtures/grid/taffy/grid_minmax_auto_percent_indefinite.html b/gentest/fixtures/grid/taffy/grid_minmax_auto_percent_indefinite.html new file mode 100644 index 0000000000..f4986c56df --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_minmax_auto_percent_indefinite.html @@ -0,0 +1,8 @@ + + + +
+
+
HH HH
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_minmax_column_fixed_width_above_range.html b/gentest/fixtures/grid/taffy/grid_minmax_column_fixed_width_above_range.html new file mode 100644 index 0000000000..75bd362fec --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_minmax_column_fixed_width_above_range.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_minmax_column_fixed_width_below_range.html b/gentest/fixtures/grid/taffy/grid_minmax_column_fixed_width_below_range.html new file mode 100644 index 0000000000..81c3fb8368 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_minmax_column_fixed_width_below_range.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_minmax_column_fixed_width_within_range.html b/gentest/fixtures/grid/taffy/grid_minmax_column_fixed_width_within_range.html new file mode 100644 index 0000000000..860bcece46 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_minmax_column_fixed_width_within_range.html @@ -0,0 +1,13 @@ + + +
+
+
+
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_minmax_column_indefinite.html b/gentest/fixtures/grid/taffy/grid_minmax_column_indefinite.html new file mode 100644 index 0000000000..52a328c8a0 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_minmax_column_indefinite.html @@ -0,0 +1,16 @@ + + + +
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_minmax_column_with_auto_fixed.html b/gentest/fixtures/grid/taffy/grid_minmax_column_with_auto_fixed.html new file mode 100644 index 0000000000..dea60d2cb2 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_minmax_column_with_auto_fixed.html @@ -0,0 +1,6 @@ + + +
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_minmax_column_with_fr_fixed.html b/gentest/fixtures/grid/taffy/grid_minmax_column_with_fr_fixed.html new file mode 100644 index 0000000000..d7d9677393 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_minmax_column_with_fr_fixed.html @@ -0,0 +1,6 @@ + + +
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_overflow_inline_axis_hidden.html b/gentest/fixtures/grid/taffy/grid_overflow_inline_axis_hidden.html new file mode 100644 index 0000000000..6f4e42222e --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_overflow_inline_axis_hidden.html @@ -0,0 +1,5 @@ + + +
+
HHHHHHHHHH
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_overflow_inline_axis_scroll.html b/gentest/fixtures/grid/taffy/grid_overflow_inline_axis_scroll.html new file mode 100644 index 0000000000..8692efb2e7 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_overflow_inline_axis_scroll.html @@ -0,0 +1,5 @@ + + +
+
HHHHHHHHHH
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_overflow_inline_axis_visible.html b/gentest/fixtures/grid/taffy/grid_overflow_inline_axis_visible.html new file mode 100644 index 0000000000..576a870022 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_overflow_inline_axis_visible.html @@ -0,0 +1,5 @@ + + +
+
HHHHHHHHHH
+
diff --git a/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_overridden_by_available_space.html b/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_overridden_by_available_space.html new file mode 100644 index 0000000000..56340332e2 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_overridden_by_available_space.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_overridden_by_max_size.html b/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_overridden_by_max_size.html new file mode 100644 index 0000000000..4c9f4bcae9 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_overridden_by_max_size.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_overridden_by_size.html b/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_overridden_by_size.html new file mode 100644 index 0000000000..2644d7907f --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_overridden_by_size.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_take_up_space_both_axis.html b/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_take_up_space_both_axis.html new file mode 100644 index 0000000000..12fc2a81fd --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_overflow_scrollbars_take_up_space_both_axis.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_padding_border_overrides_container_max_size.html b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_container_max_size.html new file mode 100644 index 0000000000..49962f53e3 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_container_max_size.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_padding_border_overrides_container_size.html b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_container_size.html new file mode 100644 index 0000000000..76c5c14e12 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_container_size.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_padding_border_overrides_max_size.html b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_max_size.html new file mode 100644 index 0000000000..e40be1b6db --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_max_size.html @@ -0,0 +1,5 @@ + + +
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_padding_border_overrides_min_size.html b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_min_size.html new file mode 100644 index 0000000000..abb32ef44c --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_min_size.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_padding_border_overrides_size.html b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_size.html new file mode 100644 index 0000000000..e4eca5dc3d --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_padding_border_overrides_size.html @@ -0,0 +1,5 @@ + + +
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_percent_item_inside_stretch_item.html b/gentest/fixtures/grid/taffy/grid_percent_item_inside_stretch_item.html new file mode 100644 index 0000000000..ca9e40728d --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_item_inside_stretch_item.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_percent_items_nested_inside_stretch_alignment.html b/gentest/fixtures/grid/taffy/grid_percent_items_nested_inside_stretch_alignment.html new file mode 100644 index 0000000000..64a8d459bf --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_items_nested_inside_stretch_alignment.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_percent_items_nested_moderate.html b/gentest/fixtures/grid/taffy/grid_percent_items_nested_moderate.html new file mode 100644 index 0000000000..ec804f2c60 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_items_nested_moderate.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_percent_items_nested_with_margin.html b/gentest/fixtures/grid/taffy/grid_percent_items_nested_with_margin.html new file mode 100644 index 0000000000..d8654dbce5 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_items_nested_with_margin.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_percent_items_nested_with_padding_margin.html b/gentest/fixtures/grid/taffy/grid_percent_items_nested_with_padding_margin.html new file mode 100644 index 0000000000..7f72225601 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_items_nested_with_padding_margin.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_percent_items_width_and_margin.html b/gentest/fixtures/grid/taffy/grid_percent_items_width_and_margin.html new file mode 100644 index 0000000000..27b3c93cf1 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_items_width_and_margin.html @@ -0,0 +1,4 @@ + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_percent_items_width_and_padding.html b/gentest/fixtures/grid/taffy/grid_percent_items_width_and_padding.html new file mode 100644 index 0000000000..2f20c64f7a --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_items_width_and_padding.html @@ -0,0 +1,5 @@ + + +
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_percent_tracks_definite_overflow.html b/gentest/fixtures/grid/taffy/grid_percent_tracks_definite_overflow.html new file mode 100644 index 0000000000..e01132e4f5 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_tracks_definite_overflow.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_percent_tracks_definite_underflow.html b/gentest/fixtures/grid/taffy/grid_percent_tracks_definite_underflow.html new file mode 100644 index 0000000000..1a46838f8e --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_tracks_definite_underflow.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_percent_tracks_indefinite_only.html b/gentest/fixtures/grid/taffy/grid_percent_tracks_indefinite_only.html new file mode 100644 index 0000000000..442c7fa0bd --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_tracks_indefinite_only.html @@ -0,0 +1,10 @@ + + +
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_percent_tracks_indefinite_with_content_overflow.html b/gentest/fixtures/grid/taffy/grid_percent_tracks_indefinite_with_content_overflow.html new file mode 100644 index 0000000000..4f45275e77 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_tracks_indefinite_with_content_overflow.html @@ -0,0 +1,11 @@ + + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_percent_tracks_indefinite_with_content_underflow.html b/gentest/fixtures/grid/taffy/grid_percent_tracks_indefinite_with_content_underflow.html new file mode 100644 index 0000000000..df89a068e5 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_percent_tracks_indefinite_with_content_underflow.html @@ -0,0 +1,11 @@ + + +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_placement_auto_negative.html b/gentest/fixtures/grid/taffy/grid_placement_auto_negative.html new file mode 100644 index 0000000000..33b195e97e --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_placement_auto_negative.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.html b/gentest/fixtures/grid/taffy/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.html new file mode 100644 index 0000000000..c07f30250d --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_placement_definite_primary.html b/gentest/fixtures/grid/taffy/grid_placement_definite_primary.html new file mode 100644 index 0000000000..5130ed5d6f --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_placement_definite_primary.html @@ -0,0 +1,9 @@ + + +
+
+
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/grid_relative_all_sides.html b/gentest/fixtures/grid/taffy/grid_relative_all_sides.html new file mode 100644 index 0000000000..232ddb6a52 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_relative_all_sides.html @@ -0,0 +1,5 @@ + + +
+
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_size_child_fixed_tracks.html b/gentest/fixtures/grid/taffy/grid_size_child_fixed_tracks.html new file mode 100644 index 0000000000..60429de2b6 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_size_child_fixed_tracks.html @@ -0,0 +1,9 @@ + + +
+
HH HH HH HH
+
HHH HHH
+
HH HHHH
+
HH HH HH HH
+
HH HH HH HH
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/grid_taffy_issue_624.html b/gentest/fixtures/grid/taffy/grid_taffy_issue_624.html new file mode 100644 index 0000000000..1fd2a3e315 --- /dev/null +++ b/gentest/fixtures/grid/taffy/grid_taffy_issue_624.html @@ -0,0 +1,7 @@ + + +
+
+
+
+
diff --git a/gentest/fixtures/grid/taffy/xgrid_aspect_ratio_fill_child_min_width.html b/gentest/fixtures/grid/taffy/xgrid_aspect_ratio_fill_child_min_width.html new file mode 100644 index 0000000000..e98de6792b --- /dev/null +++ b/gentest/fixtures/grid/taffy/xgrid_aspect_ratio_fill_child_min_width.html @@ -0,0 +1,7 @@ + + +
+
+ +
+
\ No newline at end of file diff --git a/gentest/fixtures/grid/taffy/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.html b/gentest/fixtures/grid/taffy/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.html new file mode 100644 index 0000000000..4fc2539d09 --- /dev/null +++ b/gentest/fixtures/grid/taffy/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.html @@ -0,0 +1,12 @@ + + + +
+
+
+
+
+
+
+
+
diff --git a/gentest/gentest-cpp.js b/gentest/gentest-cpp.js index d063080491..78c0027f3b 100644 --- a/gentest/gentest-cpp.js +++ b/gentest/gentest-cpp.js @@ -125,6 +125,8 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { YGAlignSpaceAround: {value: 'YGAlignSpaceAround'}, YGAlignSpaceEvenly: {value: 'YGAlignSpaceEvenly'}, YGAlignBaseline: {value: 'YGAlignBaseline'}, + YGAlignStart: {value: 'YGAlignStart'}, + YGAlignEnd: {value: 'YGAlignEnd'}, YGDirectionInherit: {value: 'YGDirectionInherit'}, YGDirectionLTR: {value: 'YGDirectionLTR'}, @@ -152,6 +154,10 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { YGJustifySpaceAround: {value: 'YGJustifySpaceAround'}, YGJustifySpaceBetween: {value: 'YGJustifySpaceBetween'}, YGJustifySpaceEvenly: {value: 'YGJustifySpaceEvenly'}, + YGJustifyStretch: {value: 'YGJustifyStretch'}, + YGJustifyStart: {value: 'YGJustifyStart'}, + YGJustifyEnd: {value: 'YGJustifyEnd'}, + YGJustifyAuto: {value: 'YGJustifyAuto'}, YGOverflowHidden: {value: 'YGOverflowHidden'}, YGOverflowVisible: {value: 'YGOverflowVisible'}, @@ -179,6 +185,8 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { YGFitContent: {value: 'FitContent'}, YGStretch: {value: 'Stretch'}, + YGDisplayGrid: {value: 'YGDisplayGrid'}, + YGNodeCalculateLayout: { value: function (node, dir, _experiments) { this.push( @@ -363,6 +371,30 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { }, }, + YGNodeStyleSetJustifyItems: { + value: function (nodeName, value) { + this.push( + 'YGNodeStyleSetJustifyItems(' + + nodeName + + ', ' + + toValueCpp(value) + + ');', + ); + }, + }, + + YGNodeStyleSetJustifySelf: { + value: function (nodeName, value) { + this.push( + 'YGNodeStyleSetJustifySelf(' + + nodeName + + ', ' + + toValueCpp(value) + + ');', + ); + }, + }, + YGNodeStyleSetMargin: { value: function (nodeName, edge, value) { let valueStr = toValueCpp(value); @@ -509,4 +541,267 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, { ); }, }, + + YGNodeStyleSetGridTemplateRows: { + value: function (nodeName, value) { + if (!value) { + return; + } + + const tracks = parseGridTrackList(this, value); + if (!tracks || tracks.length === 0) { + return; + } + + this.push(`auto ${nodeName}_gridTemplateRows = YGGridTrackListCreate();`); + + for (const track of tracks) { + if (track.type === 'minmax') { + const minVal = this.formatGridTrackValue(track.min); + const maxVal = this.formatGridTrackValue(track.max); + this.push( + `YGGridTrackListAddTrack(${nodeName}_gridTemplateRows, YGMinMax(${minVal}, ${maxVal}));`, + ); + } else { + const val = this.formatGridTrackValue(track); + this.push( + `YGGridTrackListAddTrack(${nodeName}_gridTemplateRows, ${val});`, + ); + } + } + + this.push( + `YGNodeStyleSetGridTemplateRows(${nodeName}, ${nodeName}_gridTemplateRows);`, + ); + this.push(`YGGridTrackListFree(${nodeName}_gridTemplateRows);`); + }, + }, + + YGNodeStyleSetGridTemplateColumns: { + value: function (nodeName, value) { + if (!value) { + return; + } + + const tracks = parseGridTrackList(this, value); + if (!tracks || tracks.length === 0) { + return; + } + + this.push( + `auto ${nodeName}_gridTemplateColumns = YGGridTrackListCreate();`, + ); + + for (const track of tracks) { + if (track.type === 'minmax') { + const minVal = this.formatGridTrackValue(track.min); + const maxVal = this.formatGridTrackValue(track.max); + this.push( + `YGGridTrackListAddTrack(${nodeName}_gridTemplateColumns, YGMinMax(${minVal}, ${maxVal}));`, + ); + } else { + const val = this.formatGridTrackValue(track); + this.push( + `YGGridTrackListAddTrack(${nodeName}_gridTemplateColumns, ${val});`, + ); + } + } + + this.push( + `YGNodeStyleSetGridTemplateColumns(${nodeName}, ${nodeName}_gridTemplateColumns);`, + ); + this.push(`YGGridTrackListFree(${nodeName}_gridTemplateColumns);`); + }, + }, + + YGNodeStyleSetGridColumnStart: { + value: function (nodeName, value) { + this.push(`YGNodeStyleSetGridColumnStart(${nodeName}, ${value});`); + }, + }, + + YGNodeStyleSetGridColumnStartSpan: { + value: function (nodeName, value) { + this.push(`YGNodeStyleSetGridColumnStartSpan(${nodeName}, ${value});`); + }, + }, + + YGNodeStyleSetGridColumnEnd: { + value: function (nodeName, value) { + this.push(`YGNodeStyleSetGridColumnEnd(${nodeName}, ${value});`); + }, + }, + + YGNodeStyleSetGridColumnEndSpan: { + value: function (nodeName, value) { + this.push(`YGNodeStyleSetGridColumnEndSpan(${nodeName}, ${value});`); + }, + }, + + YGNodeStyleSetGridRowStart: { + value: function (nodeName, value) { + this.push(`YGNodeStyleSetGridRowStart(${nodeName}, ${value});`); + }, + }, + + YGNodeStyleSetGridRowStartSpan: { + value: function (nodeName, value) { + this.push(`YGNodeStyleSetGridRowStartSpan(${nodeName}, ${value});`); + }, + }, + + YGNodeStyleSetGridRowEnd: { + value: function (nodeName, value) { + this.push(`YGNodeStyleSetGridRowEnd(${nodeName}, ${value});`); + }, + }, + + YGNodeStyleSetGridRowEndSpan: { + value: function (nodeName, value) { + this.push(`YGNodeStyleSetGridRowEndSpan(${nodeName}, ${value});`); + }, + }, + + YGNodeStyleSetGridAutoColumns: { + value: function (nodeName, value) { + if (!value) { + return; + } + + const tracks = parseGridTrackList(this, value); + if (!tracks || tracks.length === 0) { + return; + } + + this.push(`auto ${nodeName}_gridAutoColumns = YGGridTrackListCreate();`); + + for (const track of tracks) { + if (track.type === 'minmax') { + const minVal = this.formatGridTrackValue(track.min); + const maxVal = this.formatGridTrackValue(track.max); + this.push( + `YGGridTrackListAddTrack(${nodeName}_gridAutoColumns, YGMinMax(${minVal}, ${maxVal}));`, + ); + } else { + const val = this.formatGridTrackValue(track); + this.push( + `YGGridTrackListAddTrack(${nodeName}_gridAutoColumns, ${val});`, + ); + } + } + + this.push( + `YGNodeStyleSetGridAutoColumns(${nodeName}, ${nodeName}_gridAutoColumns);`, + ); + this.push(`YGGridTrackListFree(${nodeName}_gridAutoColumns);`); + }, + }, + + YGNodeStyleSetGridAutoRows: { + value: function (nodeName, value) { + if (!value) { + return; + } + + const tracks = parseGridTrackList(this, value); + if (!tracks || tracks.length === 0) { + return; + } + + this.push(`auto ${nodeName}_gridAutoRows = YGGridTrackListCreate();`); + + for (const track of tracks) { + if (track.type === 'minmax') { + const minVal = this.formatGridTrackValue(track.min); + const maxVal = this.formatGridTrackValue(track.max); + this.push( + `YGGridTrackListAddTrack(${nodeName}_gridAutoRows, YGMinMax(${minVal}, ${maxVal}));`, + ); + } else { + const val = this.formatGridTrackValue(track); + this.push( + `YGGridTrackListAddTrack(${nodeName}_gridAutoRows, ${val});`, + ); + } + } + + this.push( + `YGNodeStyleSetGridAutoRows(${nodeName}, ${nodeName}_gridAutoRows);`, + ); + this.push(`YGGridTrackListFree(${nodeName}_gridAutoRows);`); + }, + }, + + formatGridTrackValue: { + value: function (track) { + switch (track.type) { + case 'auto': + return 'YGAuto()'; + case 'points': + return `YGPoints(${toValueCpp(track.value)})`; + case 'percent': + return `YGPercent(${toValueCpp(track.value)})`; + case 'fr': + return `YGFr(${toValueCpp(track.value)})`; + default: + return 'YGAuto()'; + } + }, + }, }); + +function parseGridTrackList(e, value) { + if (!value || value === 'none') { + return null; + } + + // Parse space-separated track values + // Examples: "100px 100px 100px", "100px 100% minmax(100px, 200px) auto" + const tracks = []; + const parts = value.trim().split(/\s+/); + + let i = 0; + while (i < parts.length) { + const part = parts[i]; + + if (part.startsWith('minmax(')) { + // Handle minmax function - may span multiple parts if there are spaces + let minmaxStr = part; + while (!minmaxStr.includes(')') && i < parts.length - 1) { + i++; + minmaxStr += ' ' + parts[i]; + } + + // Extract min and max values from minmax(min, max) + const match = minmaxStr.match(/minmax\(([^,]+),\s*([^)]+)\)/); + if (match) { + const min = match[1].trim(); + const max = match[2].trim(); + tracks.push({ + type: 'minmax', + min: parseGridTrackValue(e, min), + max: parseGridTrackValue(e, max), + }); + } + } else { + // Simple track value + tracks.push(parseGridTrackValue(e, part)); + } + i++; + } + + return tracks; +} + +function parseGridTrackValue(e, value) { + if (value === 'auto') { + return {type: 'auto'}; + } else if (value.endsWith('px')) { + return {type: 'points', value: parseFloat(value)}; + } else if (value.endsWith('%')) { + return {type: 'percent', value: parseFloat(value)}; + } else if (value.endsWith('fr')) { + return {type: 'fr', value: parseFloat(value)}; + } + return {type: 'auto'}; +} diff --git a/gentest/gentest-driver.ts b/gentest/gentest-driver.ts index a0acd6e642..be8033ab17 100644 --- a/gentest/gentest-driver.ts +++ b/gentest/gentest-driver.ts @@ -9,7 +9,7 @@ import * as fs from 'node:fs/promises'; import {format} from 'node:util'; -import {parse, dirname} from 'path'; +import {parse, dirname, join, relative} from 'path'; import * as process from 'node:process'; import {Builder, logging} from 'selenium-webdriver'; import {Options} from 'selenium-webdriver/chrome.js'; @@ -19,6 +19,22 @@ import minimist from 'minimist'; import readline from 'node:readline/promises'; import signedsource from 'signedsource'; +async function findHtmlFixtures(dir: string): Promise { + const entries = await fs.readdir(dir, {withFileTypes: true}); + const files = await Promise.all( + entries.map(entry => { + const fullPath = join(dir, entry.name); + if (entry.isDirectory()) { + return findHtmlFixtures(fullPath); + } else if (entry.name.endsWith('.html')) { + return [fullPath]; + } + return []; + }), + ); + return files.flat(); +} + function addSignatureToSourceCode(sourceCode: string): string { const codeWithToken = sourceCode.replace( 'MAGIC_PLACEHOLDER', @@ -35,18 +51,23 @@ const headless = argv.h || argv.headless; const gentestDir = dirname(fileURLToPath(import.meta.url)); const yogaDir = dirname(gentestDir); +const fixturesDir = `${gentestDir}/fixtures`; -let fixtures = await fs.readdir(`${gentestDir}/fixtures`); +let fixtures: string[]; try { if (specificFixture != null) { - await fs.access(`fixtures/${specificFixture}.html`, fs.constants.F_OK); - fixtures = [specificFixture + '.html']; + const fixturePath = `${fixturesDir}/${specificFixture}.html`; + await fs.access(fixturePath, fs.constants.F_OK); + fixtures = [fixturePath]; + } else { + fixtures = await findHtmlFixtures(fixturesDir); } } catch (e) { const errorMessage = e instanceof Error ? e.message : ''; console.log( `Trying to access ${specificFixture}.html threw an exception. Executing against all fixtures. ${errorMessage}`, ); + fixtures = await findHtmlFixtures(fixturesDir); } const options = new Options(); @@ -65,25 +86,37 @@ const driver = await new Builder() .setChromeOptions(options) .build(); -for (const fileName of fixtures) { - const fixture = await fs.readFile( - `${gentestDir}/fixtures/${fileName}`, - 'utf8', - ); - const fileNameNoExtension = parse(fileName).name; +for (const fixturePath of fixtures) { + const fixture = await fs.readFile(fixturePath, 'utf8'); + const relativePath = relative(fixturesDir, fixturePath); + const fileNameNoExtension = parse(relativePath).name; console.log('Generate', fileNameNoExtension); // TODO: replace this with something more robust than just blindly replacing // start/end in the entire fixture const ltrFixture = fixture - .replaceAll('start', 'left') - .replaceAll('end', 'right') + // prevent replacing in grid properties and alignment properties (justify/align-*) + .replaceAll( + /(? { - map[key] = - node.style[key] || getComputedStyle(node, null).getPropertyValue(key); + // For grid template properties, only use inline styles to avoid capturing + // computed implicit grid tracks + if (gridTemplateProperties.has(key)) { + map[key] = node.style[key] || ''; + } else { + map[key] = + node.style[key] || getComputedStyle(node, null).getPropertyValue(key); + } return map; }, {}); } diff --git a/java/com/facebook/yoga/YogaAlign.java b/java/com/facebook/yoga/YogaAlign.java index 00535154fc..6f1c456581 100644 --- a/java/com/facebook/yoga/YogaAlign.java +++ b/java/com/facebook/yoga/YogaAlign.java @@ -18,7 +18,9 @@ public enum YogaAlign { BASELINE(5), SPACE_BETWEEN(6), SPACE_AROUND(7), - SPACE_EVENLY(8); + SPACE_EVENLY(8), + START(9), + END(10); private final int mIntValue; @@ -41,6 +43,8 @@ public static YogaAlign fromInt(int value) { case 6: return SPACE_BETWEEN; case 7: return SPACE_AROUND; case 8: return SPACE_EVENLY; + case 9: return START; + case 10: return END; default: throw new IllegalArgumentException("Unknown enum value: " + value); } } diff --git a/java/com/facebook/yoga/YogaDisplay.java b/java/com/facebook/yoga/YogaDisplay.java index 4dae871936..8e7e0f83cd 100644 --- a/java/com/facebook/yoga/YogaDisplay.java +++ b/java/com/facebook/yoga/YogaDisplay.java @@ -12,7 +12,8 @@ public enum YogaDisplay { FLEX(0), NONE(1), - CONTENTS(2); + CONTENTS(2), + GRID(3); private final int mIntValue; @@ -29,6 +30,7 @@ public static YogaDisplay fromInt(int value) { case 0: return FLEX; case 1: return NONE; case 2: return CONTENTS; + case 3: return GRID; default: throw new IllegalArgumentException("Unknown enum value: " + value); } } diff --git a/java/com/facebook/yoga/YogaGridTrackList.java b/java/com/facebook/yoga/YogaGridTrackList.java new file mode 100644 index 0000000000..33c46a6dd3 --- /dev/null +++ b/java/com/facebook/yoga/YogaGridTrackList.java @@ -0,0 +1,38 @@ +/* + * 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. + */ + +package com.facebook.yoga; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a list of grid tracks for use with grid-template-rows/columns. + */ +public class YogaGridTrackList { + private final List tracks; + + public YogaGridTrackList() { + this.tracks = new ArrayList<>(); + } + + public void addTrack(YogaGridTrackValue track) { + tracks.add(track); + } + + public List getTracks() { + return tracks; + } + + public int size() { + return tracks.size(); + } + + public YogaGridTrackValue get(int index) { + return tracks.get(index); + } +} diff --git a/java/com/facebook/yoga/YogaGridTrackType.java b/java/com/facebook/yoga/YogaGridTrackType.java new file mode 100644 index 0000000000..e3d22d25be --- /dev/null +++ b/java/com/facebook/yoga/YogaGridTrackType.java @@ -0,0 +1,39 @@ +/* + * 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 enums.py + +package com.facebook.yoga; + +public enum YogaGridTrackType { + AUTO(0), + POINTS(1), + PERCENT(2), + FR(3), + MINMAX(4); + + private final int mIntValue; + + YogaGridTrackType(int intValue) { + mIntValue = intValue; + } + + public int intValue() { + return mIntValue; + } + + public static YogaGridTrackType fromInt(int value) { + switch (value) { + case 0: return AUTO; + case 1: return POINTS; + case 2: return PERCENT; + case 3: return FR; + case 4: return MINMAX; + default: throw new IllegalArgumentException("Unknown enum value: " + value); + } + } +} diff --git a/java/com/facebook/yoga/YogaGridTrackValue.java b/java/com/facebook/yoga/YogaGridTrackValue.java new file mode 100644 index 0000000000..b5285e54c2 --- /dev/null +++ b/java/com/facebook/yoga/YogaGridTrackValue.java @@ -0,0 +1,76 @@ +/* + * 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. + */ + +package com.facebook.yoga; + +/** + * Represents a grid track value for use with grid-template-rows/columns. + */ +public class YogaGridTrackValue { + public enum Type { + AUTO, + POINTS, + PERCENT, + FR, + MINMAX + } + + private final Type type; + private final float value; + private final YogaGridTrackValue minValue; + private final YogaGridTrackValue maxValue; + + private YogaGridTrackValue(Type type, float value) { + this.type = type; + this.value = value; + this.minValue = null; + this.maxValue = null; + } + + private YogaGridTrackValue(YogaGridTrackValue min, YogaGridTrackValue max) { + this.type = Type.MINMAX; + this.value = 0; + this.minValue = min; + this.maxValue = max; + } + + public static YogaGridTrackValue auto() { + return new YogaGridTrackValue(Type.AUTO, 0); + } + + public static YogaGridTrackValue points(float points) { + return new YogaGridTrackValue(Type.POINTS, points); + } + + public static YogaGridTrackValue percent(float percent) { + return new YogaGridTrackValue(Type.PERCENT, percent); + } + + public static YogaGridTrackValue fr(float fr) { + return new YogaGridTrackValue(Type.FR, fr); + } + + public static YogaGridTrackValue minMax(YogaGridTrackValue min, YogaGridTrackValue max) { + return new YogaGridTrackValue(min, max); + } + + public Type getType() { + return type; + } + + public float getValue() { + return value; + } + + public YogaGridTrackValue getMinValue() { + return minValue; + } + + public YogaGridTrackValue getMaxValue() { + return maxValue; + } +} diff --git a/java/com/facebook/yoga/YogaJustify.java b/java/com/facebook/yoga/YogaJustify.java index 4be1ed71d3..778238ec66 100644 --- a/java/com/facebook/yoga/YogaJustify.java +++ b/java/com/facebook/yoga/YogaJustify.java @@ -10,12 +10,16 @@ package com.facebook.yoga; public enum YogaJustify { - FLEX_START(0), - CENTER(1), - FLEX_END(2), - SPACE_BETWEEN(3), - SPACE_AROUND(4), - SPACE_EVENLY(5); + AUTO(0), + FLEX_START(1), + CENTER(2), + FLEX_END(3), + SPACE_BETWEEN(4), + SPACE_AROUND(5), + SPACE_EVENLY(6), + STRETCH(7), + START(8), + END(9); private final int mIntValue; @@ -29,12 +33,16 @@ public int intValue() { public static YogaJustify fromInt(int value) { switch (value) { - case 0: return FLEX_START; - case 1: return CENTER; - case 2: return FLEX_END; - case 3: return SPACE_BETWEEN; - case 4: return SPACE_AROUND; - case 5: return SPACE_EVENLY; + case 0: return AUTO; + case 1: return FLEX_START; + case 2: return CENTER; + case 3: return FLEX_END; + case 4: return SPACE_BETWEEN; + case 5: return SPACE_AROUND; + case 6: return SPACE_EVENLY; + case 7: return STRETCH; + case 8: return START; + case 9: return END; default: throw new IllegalArgumentException("Unknown enum value: " + value); } } diff --git a/java/com/facebook/yoga/YogaNative.kt b/java/com/facebook/yoga/YogaNative.kt index 95bf553647..3f60962ef7 100644 --- a/java/com/facebook/yoga/YogaNative.kt +++ b/java/com/facebook/yoga/YogaNative.kt @@ -328,4 +328,72 @@ public object YogaNative { nativePointer: Long, alwaysFormContainingBlock: Boolean, ) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridTemplateColumnsJNI( + nativePointer: Long, + types: IntArray, + values: FloatArray, + minTypes: IntArray, + minValues: FloatArray, + maxTypes: IntArray, + maxValues: FloatArray, + ) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridTemplateRowsJNI( + nativePointer: Long, + types: IntArray, + values: FloatArray, + minTypes: IntArray, + minValues: FloatArray, + maxTypes: IntArray, + maxValues: FloatArray, + ) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridAutoColumnsJNI( + nativePointer: Long, + types: IntArray, + values: FloatArray, + minTypes: IntArray, + minValues: FloatArray, + maxTypes: IntArray, + maxValues: FloatArray, + ) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridAutoRowsJNI( + nativePointer: Long, + types: IntArray, + values: FloatArray, + minTypes: IntArray, + minValues: FloatArray, + maxTypes: IntArray, + maxValues: FloatArray, + ) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridColumnStartJNI(nativePointer: Long, value: Int) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridColumnStartSpanJNI(nativePointer: Long, span: Int) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridColumnEndJNI(nativePointer: Long, value: Int) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridColumnEndSpanJNI(nativePointer: Long, span: Int) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridRowStartJNI(nativePointer: Long, value: Int) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridRowStartSpanJNI(nativePointer: Long, span: Int) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridRowEndJNI(nativePointer: Long, value: Int) + + @JvmStatic + public external fun jni_YGNodeStyleSetGridRowEndSpanJNI(nativePointer: Long, span: Int) } diff --git a/java/com/facebook/yoga/YogaNode.java b/java/com/facebook/yoga/YogaNode.java index 18f2914aeb..8865622536 100644 --- a/java/com/facebook/yoga/YogaNode.java +++ b/java/com/facebook/yoga/YogaNode.java @@ -242,6 +242,30 @@ public interface Inputs { public abstract void setGapPercent(YogaGutter gutter, float gapLength); + public abstract void setGridTemplateColumns(YogaGridTrackList trackList); + + public abstract void setGridTemplateRows(YogaGridTrackList trackList); + + public abstract void setGridAutoColumns(YogaGridTrackList trackList); + + public abstract void setGridAutoRows(YogaGridTrackList trackList); + + public abstract void setGridColumnStart(int value); + + public abstract void setGridColumnStartSpan(int span); + + public abstract void setGridColumnEnd(int value); + + public abstract void setGridColumnEndSpan(int span); + + public abstract void setGridRowStart(int value); + + public abstract void setGridRowStartSpan(int span); + + public abstract void setGridRowEnd(int value); + + public abstract void setGridRowEndSpan(int span); + public abstract float getLayoutX(); public abstract float getLayoutY(); diff --git a/java/com/facebook/yoga/YogaNodeJNIBase.java b/java/com/facebook/yoga/YogaNodeJNIBase.java index 38c2f93a31..d85f4404c5 100644 --- a/java/com/facebook/yoga/YogaNodeJNIBase.java +++ b/java/com/facebook/yoga/YogaNodeJNIBase.java @@ -824,4 +824,140 @@ public void setGap(YogaGutter gutter, float gapLength) { public void setGapPercent(YogaGutter gutter, float gapLength) { YogaNative.jni_YGNodeStyleSetGapPercentJNI(mNativePointer, gutter.intValue(), gapLength); } + + @Override + public void setGridTemplateColumns(YogaGridTrackList trackList) { + int[] types = new int[trackList.size()]; + float[] values = new float[trackList.size()]; + int[] minTypes = new int[trackList.size()]; + float[] minValues = new float[trackList.size()]; + int[] maxTypes = new int[trackList.size()]; + float[] maxValues = new float[trackList.size()]; + + for (int i = 0; i < trackList.size(); i++) { + YogaGridTrackValue track = trackList.get(i); + types[i] = track.getType().ordinal(); + values[i] = track.getValue(); + if (track.getType() == YogaGridTrackValue.Type.MINMAX) { + minTypes[i] = track.getMinValue().getType().ordinal(); + minValues[i] = track.getMinValue().getValue(); + maxTypes[i] = track.getMaxValue().getType().ordinal(); + maxValues[i] = track.getMaxValue().getValue(); + } + } + YogaNative.jni_YGNodeStyleSetGridTemplateColumnsJNI( + mNativePointer, types, values, minTypes, minValues, maxTypes, maxValues); + } + + @Override + public void setGridTemplateRows(YogaGridTrackList trackList) { + int[] types = new int[trackList.size()]; + float[] values = new float[trackList.size()]; + int[] minTypes = new int[trackList.size()]; + float[] minValues = new float[trackList.size()]; + int[] maxTypes = new int[trackList.size()]; + float[] maxValues = new float[trackList.size()]; + + for (int i = 0; i < trackList.size(); i++) { + YogaGridTrackValue track = trackList.get(i); + types[i] = track.getType().ordinal(); + values[i] = track.getValue(); + if (track.getType() == YogaGridTrackValue.Type.MINMAX) { + minTypes[i] = track.getMinValue().getType().ordinal(); + minValues[i] = track.getMinValue().getValue(); + maxTypes[i] = track.getMaxValue().getType().ordinal(); + maxValues[i] = track.getMaxValue().getValue(); + } + } + YogaNative.jni_YGNodeStyleSetGridTemplateRowsJNI( + mNativePointer, types, values, minTypes, minValues, maxTypes, maxValues); + } + + @Override + public void setGridAutoColumns(YogaGridTrackList trackList) { + int[] types = new int[trackList.size()]; + float[] values = new float[trackList.size()]; + int[] minTypes = new int[trackList.size()]; + float[] minValues = new float[trackList.size()]; + int[] maxTypes = new int[trackList.size()]; + float[] maxValues = new float[trackList.size()]; + + for (int i = 0; i < trackList.size(); i++) { + YogaGridTrackValue track = trackList.get(i); + types[i] = track.getType().ordinal(); + values[i] = track.getValue(); + if (track.getType() == YogaGridTrackValue.Type.MINMAX) { + minTypes[i] = track.getMinValue().getType().ordinal(); + minValues[i] = track.getMinValue().getValue(); + maxTypes[i] = track.getMaxValue().getType().ordinal(); + maxValues[i] = track.getMaxValue().getValue(); + } + } + YogaNative.jni_YGNodeStyleSetGridAutoColumnsJNI( + mNativePointer, types, values, minTypes, minValues, maxTypes, maxValues); + } + + @Override + public void setGridAutoRows(YogaGridTrackList trackList) { + int[] types = new int[trackList.size()]; + float[] values = new float[trackList.size()]; + int[] minTypes = new int[trackList.size()]; + float[] minValues = new float[trackList.size()]; + int[] maxTypes = new int[trackList.size()]; + float[] maxValues = new float[trackList.size()]; + + for (int i = 0; i < trackList.size(); i++) { + YogaGridTrackValue track = trackList.get(i); + types[i] = track.getType().ordinal(); + values[i] = track.getValue(); + if (track.getType() == YogaGridTrackValue.Type.MINMAX) { + minTypes[i] = track.getMinValue().getType().ordinal(); + minValues[i] = track.getMinValue().getValue(); + maxTypes[i] = track.getMaxValue().getType().ordinal(); + maxValues[i] = track.getMaxValue().getValue(); + } + } + YogaNative.jni_YGNodeStyleSetGridAutoRowsJNI( + mNativePointer, types, values, minTypes, minValues, maxTypes, maxValues); + } + + @Override + public void setGridColumnStart(int value) { + YogaNative.jni_YGNodeStyleSetGridColumnStartJNI(mNativePointer, value); + } + + @Override + public void setGridColumnStartSpan(int span) { + YogaNative.jni_YGNodeStyleSetGridColumnStartSpanJNI(mNativePointer, span); + } + + @Override + public void setGridColumnEnd(int value) { + YogaNative.jni_YGNodeStyleSetGridColumnEndJNI(mNativePointer, value); + } + + @Override + public void setGridColumnEndSpan(int span) { + YogaNative.jni_YGNodeStyleSetGridColumnEndSpanJNI(mNativePointer, span); + } + + @Override + public void setGridRowStart(int value) { + YogaNative.jni_YGNodeStyleSetGridRowStartJNI(mNativePointer, value); + } + + @Override + public void setGridRowStartSpan(int span) { + YogaNative.jni_YGNodeStyleSetGridRowStartSpanJNI(mNativePointer, span); + } + + @Override + public void setGridRowEnd(int value) { + YogaNative.jni_YGNodeStyleSetGridRowEndJNI(mNativePointer, value); + } + + @Override + public void setGridRowEndSpan(int span) { + YogaNative.jni_YGNodeStyleSetGridRowEndSpanJNI(mNativePointer, span); + } } diff --git a/java/jni/YGJNIVanilla.cpp b/java/jni/YGJNIVanilla.cpp index c5fdd8c791..e8dee22dd8 100644 --- a/java/jni/YGJNIVanilla.cpp +++ b/java/jni/YGJNIVanilla.cpp @@ -12,6 +12,7 @@ #include #include "LayoutContext.h" #include "YGJNI.h" +#include #include "YGJTypesVanilla.h" #include "YogaJniException.h" #include "common.h" @@ -762,6 +763,269 @@ static void jni_YGNodeStyleSetGapPercentJNI( // Yoga specific properties, not compatible with flexbox specification YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio); +enum GridTrackType { + GRID_TRACK_AUTO = 0, + GRID_TRACK_POINTS = 1, + GRID_TRACK_PERCENT = 2, + GRID_TRACK_FR = 3, + GRID_TRACK_MINMAX = 4 +}; + +static YGGridTrackValueRef createTrackValue(int type, float value) { + switch (type) { + case GRID_TRACK_AUTO: + return YGAuto(); + case GRID_TRACK_POINTS: + return YGPoints(value); + case GRID_TRACK_PERCENT: + return YGPercent(value); + case GRID_TRACK_FR: + return YGFr(value); + default: + return YGAuto(); + } +} + +static void jni_YGNodeStyleSetGridTemplateColumnsJNI( + JNIEnv* env, + jobject /*obj*/, + jlong nativePointer, + jintArray types, + jfloatArray values, + jintArray minTypes, + jfloatArray minValues, + jintArray maxTypes, + jfloatArray maxValues) { + YGNodeRef node = _jlong2YGNodeRef(nativePointer); + YGGridTrackListRef trackList = YGGridTrackListCreate(); + + jint* typesArr = env->GetIntArrayElements(types, nullptr); + jfloat* valuesArr = env->GetFloatArrayElements(values, nullptr); + jint* minTypesArr = env->GetIntArrayElements(minTypes, nullptr); + jfloat* minValuesArr = env->GetFloatArrayElements(minValues, nullptr); + jint* maxTypesArr = env->GetIntArrayElements(maxTypes, nullptr); + jfloat* maxValuesArr = env->GetFloatArrayElements(maxValues, nullptr); + jsize length = env->GetArrayLength(types); + + for (jsize i = 0; i < length; i++) { + YGGridTrackValueRef trackValue; + if (typesArr[i] == GRID_TRACK_MINMAX) { + YGGridTrackValueRef minVal = createTrackValue(minTypesArr[i], minValuesArr[i]); + YGGridTrackValueRef maxVal = createTrackValue(maxTypesArr[i], maxValuesArr[i]); + trackValue = YGMinMax(minVal, maxVal); + } else { + trackValue = createTrackValue(typesArr[i], valuesArr[i]); + } + YGGridTrackListAddTrack(trackList, trackValue); + } + + env->ReleaseIntArrayElements(types, typesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(values, valuesArr, JNI_ABORT); + env->ReleaseIntArrayElements(minTypes, minTypesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(minValues, minValuesArr, JNI_ABORT); + env->ReleaseIntArrayElements(maxTypes, maxTypesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(maxValues, maxValuesArr, JNI_ABORT); + + YGNodeStyleSetGridTemplateColumns(node, trackList); + YGGridTrackListFree(trackList); +} + +static void jni_YGNodeStyleSetGridTemplateRowsJNI( + JNIEnv* env, + jobject /*obj*/, + jlong nativePointer, + jintArray types, + jfloatArray values, + jintArray minTypes, + jfloatArray minValues, + jintArray maxTypes, + jfloatArray maxValues) { + YGNodeRef node = _jlong2YGNodeRef(nativePointer); + YGGridTrackListRef trackList = YGGridTrackListCreate(); + + jint* typesArr = env->GetIntArrayElements(types, nullptr); + jfloat* valuesArr = env->GetFloatArrayElements(values, nullptr); + jint* minTypesArr = env->GetIntArrayElements(minTypes, nullptr); + jfloat* minValuesArr = env->GetFloatArrayElements(minValues, nullptr); + jint* maxTypesArr = env->GetIntArrayElements(maxTypes, nullptr); + jfloat* maxValuesArr = env->GetFloatArrayElements(maxValues, nullptr); + jsize length = env->GetArrayLength(types); + + for (jsize i = 0; i < length; i++) { + YGGridTrackValueRef trackValue; + if (typesArr[i] == GRID_TRACK_MINMAX) { + YGGridTrackValueRef minVal = createTrackValue(minTypesArr[i], minValuesArr[i]); + YGGridTrackValueRef maxVal = createTrackValue(maxTypesArr[i], maxValuesArr[i]); + trackValue = YGMinMax(minVal, maxVal); + } else { + trackValue = createTrackValue(typesArr[i], valuesArr[i]); + } + YGGridTrackListAddTrack(trackList, trackValue); + } + + env->ReleaseIntArrayElements(types, typesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(values, valuesArr, JNI_ABORT); + env->ReleaseIntArrayElements(minTypes, minTypesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(minValues, minValuesArr, JNI_ABORT); + env->ReleaseIntArrayElements(maxTypes, maxTypesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(maxValues, maxValuesArr, JNI_ABORT); + + YGNodeStyleSetGridTemplateRows(node, trackList); + YGGridTrackListFree(trackList); +} + +static void jni_YGNodeStyleSetGridAutoColumnsJNI( + JNIEnv* env, + jobject /*obj*/, + jlong nativePointer, + jintArray types, + jfloatArray values, + jintArray minTypes, + jfloatArray minValues, + jintArray maxTypes, + jfloatArray maxValues) { + YGNodeRef node = _jlong2YGNodeRef(nativePointer); + YGGridTrackListRef trackList = YGGridTrackListCreate(); + + jint* typesArr = env->GetIntArrayElements(types, nullptr); + jfloat* valuesArr = env->GetFloatArrayElements(values, nullptr); + jint* minTypesArr = env->GetIntArrayElements(minTypes, nullptr); + jfloat* minValuesArr = env->GetFloatArrayElements(minValues, nullptr); + jint* maxTypesArr = env->GetIntArrayElements(maxTypes, nullptr); + jfloat* maxValuesArr = env->GetFloatArrayElements(maxValues, nullptr); + jsize length = env->GetArrayLength(types); + + for (jsize i = 0; i < length; i++) { + YGGridTrackValueRef trackValue; + if (typesArr[i] == GRID_TRACK_MINMAX) { + YGGridTrackValueRef minVal = createTrackValue(minTypesArr[i], minValuesArr[i]); + YGGridTrackValueRef maxVal = createTrackValue(maxTypesArr[i], maxValuesArr[i]); + trackValue = YGMinMax(minVal, maxVal); + } else { + trackValue = createTrackValue(typesArr[i], valuesArr[i]); + } + YGGridTrackListAddTrack(trackList, trackValue); + } + + env->ReleaseIntArrayElements(types, typesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(values, valuesArr, JNI_ABORT); + env->ReleaseIntArrayElements(minTypes, minTypesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(minValues, minValuesArr, JNI_ABORT); + env->ReleaseIntArrayElements(maxTypes, maxTypesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(maxValues, maxValuesArr, JNI_ABORT); + + YGNodeStyleSetGridAutoColumns(node, trackList); + YGGridTrackListFree(trackList); +} + +static void jni_YGNodeStyleSetGridAutoRowsJNI( + JNIEnv* env, + jobject /*obj*/, + jlong nativePointer, + jintArray types, + jfloatArray values, + jintArray minTypes, + jfloatArray minValues, + jintArray maxTypes, + jfloatArray maxValues) { + YGNodeRef node = _jlong2YGNodeRef(nativePointer); + YGGridTrackListRef trackList = YGGridTrackListCreate(); + + jint* typesArr = env->GetIntArrayElements(types, nullptr); + jfloat* valuesArr = env->GetFloatArrayElements(values, nullptr); + jint* minTypesArr = env->GetIntArrayElements(minTypes, nullptr); + jfloat* minValuesArr = env->GetFloatArrayElements(minValues, nullptr); + jint* maxTypesArr = env->GetIntArrayElements(maxTypes, nullptr); + jfloat* maxValuesArr = env->GetFloatArrayElements(maxValues, nullptr); + jsize length = env->GetArrayLength(types); + + for (jsize i = 0; i < length; i++) { + YGGridTrackValueRef trackValue; + if (typesArr[i] == GRID_TRACK_MINMAX) { + YGGridTrackValueRef minVal = createTrackValue(minTypesArr[i], minValuesArr[i]); + YGGridTrackValueRef maxVal = createTrackValue(maxTypesArr[i], maxValuesArr[i]); + trackValue = YGMinMax(minVal, maxVal); + } else { + trackValue = createTrackValue(typesArr[i], valuesArr[i]); + } + YGGridTrackListAddTrack(trackList, trackValue); + } + + env->ReleaseIntArrayElements(types, typesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(values, valuesArr, JNI_ABORT); + env->ReleaseIntArrayElements(minTypes, minTypesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(minValues, minValuesArr, JNI_ABORT); + env->ReleaseIntArrayElements(maxTypes, maxTypesArr, JNI_ABORT); + env->ReleaseFloatArrayElements(maxValues, maxValuesArr, JNI_ABORT); + + YGNodeStyleSetGridAutoRows(node, trackList); + YGGridTrackListFree(trackList); +} + +static void jni_YGNodeStyleSetGridColumnStartJNI( + JNIEnv* /*env*/, + jobject /*obj*/, + jlong nativePointer, + jint value) { + YGNodeStyleSetGridColumnStart(_jlong2YGNodeRef(nativePointer), value); +} + +static void jni_YGNodeStyleSetGridColumnStartSpanJNI( + JNIEnv* /*env*/, + jobject /*obj*/, + jlong nativePointer, + jint span) { + YGNodeStyleSetGridColumnStartSpan(_jlong2YGNodeRef(nativePointer), span); +} + +static void jni_YGNodeStyleSetGridColumnEndJNI( + JNIEnv* /*env*/, + jobject /*obj*/, + jlong nativePointer, + jint value) { + YGNodeStyleSetGridColumnEnd(_jlong2YGNodeRef(nativePointer), value); +} + +static void jni_YGNodeStyleSetGridColumnEndSpanJNI( + JNIEnv* /*env*/, + jobject /*obj*/, + jlong nativePointer, + jint span) { + YGNodeStyleSetGridColumnEndSpan(_jlong2YGNodeRef(nativePointer), span); +} + +static void jni_YGNodeStyleSetGridRowStartJNI( + JNIEnv* /*env*/, + jobject /*obj*/, + jlong nativePointer, + jint value) { + YGNodeStyleSetGridRowStart(_jlong2YGNodeRef(nativePointer), value); +} + +static void jni_YGNodeStyleSetGridRowStartSpanJNI( + JNIEnv* /*env*/, + jobject /*obj*/, + jlong nativePointer, + jint span) { + YGNodeStyleSetGridRowStartSpan(_jlong2YGNodeRef(nativePointer), span); +} + +static void jni_YGNodeStyleSetGridRowEndJNI( + JNIEnv* /*env*/, + jobject /*obj*/, + jlong nativePointer, + jint value) { + YGNodeStyleSetGridRowEnd(_jlong2YGNodeRef(nativePointer), value); +} + +static void jni_YGNodeStyleSetGridRowEndSpanJNI( + JNIEnv* /*env*/, + jobject /*obj*/, + jlong nativePointer, + jint span) { + YGNodeStyleSetGridRowEndSpan(_jlong2YGNodeRef(nativePointer), span); +} + static JNINativeMethod methods[] = { {"jni_YGConfigNewJNI", "()J", (void*)jni_YGConfigNewJNI}, {"jni_YGConfigFreeJNI", "(J)V", (void*)jni_YGConfigFreeJNI}, @@ -1070,6 +1334,42 @@ static JNINativeMethod methods[] = { "(JZ)V", (void*)jni_YGNodeSetAlwaysFormsContainingBlockJNI}, {"jni_YGNodeCloneJNI", "(J)J", (void*)jni_YGNodeCloneJNI}, + {"jni_YGNodeStyleSetGridTemplateColumnsJNI", + "(J[I[F[I[F[I[F)V", + (void*)jni_YGNodeStyleSetGridTemplateColumnsJNI}, + {"jni_YGNodeStyleSetGridTemplateRowsJNI", + "(J[I[F[I[F[I[F)V", + (void*)jni_YGNodeStyleSetGridTemplateRowsJNI}, + {"jni_YGNodeStyleSetGridAutoColumnsJNI", + "(J[I[F[I[F[I[F)V", + (void*)jni_YGNodeStyleSetGridAutoColumnsJNI}, + {"jni_YGNodeStyleSetGridAutoRowsJNI", + "(J[I[F[I[F[I[F)V", + (void*)jni_YGNodeStyleSetGridAutoRowsJNI}, + {"jni_YGNodeStyleSetGridColumnStartJNI", + "(JI)V", + (void*)jni_YGNodeStyleSetGridColumnStartJNI}, + {"jni_YGNodeStyleSetGridColumnStartSpanJNI", + "(JI)V", + (void*)jni_YGNodeStyleSetGridColumnStartSpanJNI}, + {"jni_YGNodeStyleSetGridColumnEndJNI", + "(JI)V", + (void*)jni_YGNodeStyleSetGridColumnEndJNI}, + {"jni_YGNodeStyleSetGridColumnEndSpanJNI", + "(JI)V", + (void*)jni_YGNodeStyleSetGridColumnEndSpanJNI}, + {"jni_YGNodeStyleSetGridRowStartJNI", + "(JI)V", + (void*)jni_YGNodeStyleSetGridRowStartJNI}, + {"jni_YGNodeStyleSetGridRowStartSpanJNI", + "(JI)V", + (void*)jni_YGNodeStyleSetGridRowStartSpanJNI}, + {"jni_YGNodeStyleSetGridRowEndJNI", + "(JI)V", + (void*)jni_YGNodeStyleSetGridRowEndJNI}, + {"jni_YGNodeStyleSetGridRowEndSpanJNI", + "(JI)V", + (void*)jni_YGNodeStyleSetGridRowEndSpanJNI}, }; void YGJNIVanilla::registerNatives(JNIEnv* env) { diff --git a/java/tests/generated/com/facebook/yoga/YGGridTest.java b/java/tests/generated/com/facebook/yoga/YGGridTest.java new file mode 100644 index 0000000000..67ce0c9efd --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/YGGridTest.java @@ -0,0 +1,4707 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGridTest.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class YGGridTest { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_all_properties() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + YogaGridTrackList rootGridAutoColumns = new YogaGridTrackList(); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridAutoColumns(rootGridAutoColumns); + YogaGridTrackList rootGridAutoRows = new YogaGridTrackList(); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + root.setGridAutoRows(rootGridAutoRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(5); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(100f); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(4); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_auto_tracks() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.STRETCH); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(220f); + root.setHeight(160f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPadding(YogaEdge.LEFT, 10); + root_child0.setPadding(YogaEdge.TOP, 10); + root_child0.setPadding(YogaEdge.RIGHT, 10); + root_child0.setPadding(YogaEdge.BOTTOM, 10); + root_child0.setHeight(50f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(220f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(220f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_auto_tracks_with_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 15f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(120f); + root_child0.setHeight(40f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(120f); + root_child1.setHeight(40f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setPadding(YogaEdge.LEFT, 40); + root_child2.setPadding(YogaEdge.TOP, 40); + root_child2.setPadding(YogaEdge.RIGHT, 40); + root_child2.setPadding(YogaEdge.BOTTOM, 40); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(250f, root.getLayoutWidth(), 0.0f); + assertEquals(135f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(55f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(250f, root.getLayoutWidth(), 0.0f); + assertEquals(135f, root.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child2.getLayoutX(), 0.0f); + assertEquals(55f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_auto_tracks_with_margins() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 15f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMargin(YogaEdge.TOP, 10f); + root_child0.setWidth(120f); + root_child0.setHeight(40f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setMargin(YogaEdge.TOP, 10f); + root_child1.setWidth(120f); + root_child1.setHeight(40f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setPadding(YogaEdge.LEFT, 40); + root_child2.setPadding(YogaEdge.TOP, 40); + root_child2.setPadding(YogaEdge.RIGHT, 40); + root_child2.setPadding(YogaEdge.BOTTOM, 40); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(250f, root.getLayoutWidth(), 0.0f); + assertEquals(415f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(215f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(250f, root.getLayoutWidth(), 0.0f); + assertEquals(415f, root.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child2.getLayoutX(), 0.0f); + assertEquals(215f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_spanning_items() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(6); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPadding(YogaEdge.LEFT, 40); + root_child1.setPadding(YogaEdge.TOP, 40); + root_child1.setPadding(YogaEdge.RIGHT, 40); + root_child1.setPadding(YogaEdge.BOTTOM, 40); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(210f, root.getLayoutWidth(), 0.0f); + assertEquals(320f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(210f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(210f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(220f, root_child1.getLayoutY(), 0.0f); + assertEquals(80f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child2.getLayoutX(), 0.0f); + assertEquals(220f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(210f, root.getLayoutWidth(), 0.0f); + assertEquals(320f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(210f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(210f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child1.getLayoutX(), 0.0f); + assertEquals(220f, root_child1.getLayoutY(), 0.0f); + assertEquals(80f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(220f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_holy_grail() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeight(80f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(200f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(200f); + root_child3.setHeightPercent(100f); + root_child3.setGridColumnStart(3); + root_child3.setGridColumnEnd(4); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidthPercent(100f); + root_child4.setHeight(60f); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(4); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(500f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(260f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(260f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(200f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(260f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(340f, root_child4.getLayoutY(), 0.0f); + assertEquals(500f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(500f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(260f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(260f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(200f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(260f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(340f, root_child4.getLayoutY(), 0.0f); + assertEquals(500f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child4.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_sidebar_layout() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(250f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(500f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(500f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(500f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(500f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_header_content_footer() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(600f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeight(80f); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(3); + root_child2.setGridRowEnd(4); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(400f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(400f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(420f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(520f, root_child2.getLayoutY(), 0.0f); + assertEquals(400f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(400f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(400f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(420f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(520f, root_child2.getLayoutY(), 0.0f); + assertEquals(400f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_card_layout() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(500f); + root.setGap(YogaGutter.COLUMN, 20f); + root.setGap(YogaGutter.ROW, 20f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(200f); + root_child0.setHeight(250f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(200f); + root_child1.setHeight(250f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(200f); + root_child2.setHeight(250f); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(200f); + root_child3.setHeight(250f); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(2); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(200f); + root_child4.setHeight(250f); + root_child4.setGridColumnStart(2); + root_child4.setGridColumnEnd(3); + root_child4.setGridRowStart(2); + root_child4.setGridRowEnd(3); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setWidth(200f); + root_child5.setHeight(250f); + root_child5.setGridColumnStart(3); + root_child5.setGridColumnEnd(4); + root_child5.setGridRowStart(2); + root_child5.setGridRowEnd(3); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(220f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(440f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(270f, root_child3.getLayoutY(), 0.0f); + assertEquals(200f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(220f, root_child4.getLayoutX(), 0.0f); + assertEquals(270f, root_child4.getLayoutY(), 0.0f); + assertEquals(200f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(440f, root_child5.getLayoutX(), 0.0f); + assertEquals(270f, root_child5.getLayoutY(), 0.0f); + assertEquals(200f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(-40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child3.getLayoutX(), 0.0f); + assertEquals(270f, root_child3.getLayoutY(), 0.0f); + assertEquals(200f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child4.getLayoutX(), 0.0f); + assertEquals(270f, root_child4.getLayoutY(), 0.0f); + assertEquals(200f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(-40f, root_child5.getLayoutX(), 0.0f); + assertEquals(270f, root_child5.getLayoutY(), 0.0f); + assertEquals(200f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(250f, root_child5.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_dashboard_layout() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(600f); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeight(70f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(220f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(4); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidthPercent(100f); + root_child3.setHeightPercent(100f); + root_child3.setGridColumnStart(3); + root_child3.setGridColumnEnd(4); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidthPercent(100f); + root_child4.setHeightPercent(100f); + root_child4.setGridColumnStart(2); + root_child4.setGridColumnEnd(4); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(500f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(70f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(220f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(520f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(230f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(130f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(255f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(370f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(130f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(255f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(230f, root_child4.getLayoutX(), 0.0f); + assertEquals(345f, root_child4.getLayoutY(), 0.0f); + assertEquals(270f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(255f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(500f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(70f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(280f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(220f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(520f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(130f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(255f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(130f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(255f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(345f, root_child4.getLayoutY(), 0.0f); + assertEquals(270f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(255f, root_child4.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_magazine_layout() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(900f); + root.setHeight(700f); + root.setGap(YogaGutter.COLUMN, 15f); + root.setGap(YogaGutter.ROW, 15f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeight(300f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeight(200f); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidthPercent(100f); + root_child3.setHeight(200f); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(3); + root_child3.setGridRowEnd(4); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(900f, root.getLayoutWidth(), 0.0f); + assertEquals(700f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(590f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(515f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(605f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(295f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(300f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(605f, root_child2.getLayoutX(), 0.0f); + assertEquals(315f, root_child2.getLayoutY(), 0.0f); + assertEquals(295f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(530f, root_child3.getLayoutY(), 0.0f); + assertEquals(900f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(900f, root.getLayoutWidth(), 0.0f); + assertEquals(700f, root.getLayoutHeight(), 0.0f); + + assertEquals(310f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(590f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(515f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(295f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(300f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(315f, root_child2.getLayoutY(), 0.0f); + assertEquals(295f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(530f, root_child3.getLayoutY(), 0.0f); + assertEquals(900f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_app_layout() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(600f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(60f); + root_child0.setHeight(60f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeight(60f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(60f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidthPercent(100f); + root_child3.setHeightPercent(100f); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidthPercent(100f); + root_child4.setHeight(50f); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(3); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(340f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(60f, root_child2.getLayoutY(), 0.0f); + assertEquals(60f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(490f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child3.getLayoutX(), 0.0f); + assertEquals(60f, root_child3.getLayoutY(), 0.0f); + assertEquals(340f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(490f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(550f, root_child4.getLayoutY(), 0.0f); + assertEquals(400f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(340f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(340f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(340f, root_child2.getLayoutX(), 0.0f); + assertEquals(60f, root_child2.getLayoutY(), 0.0f); + assertEquals(60f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(490f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(60f, root_child3.getLayoutY(), 0.0f); + assertEquals(340f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(490f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(550f, root_child4.getLayoutY(), 0.0f); + assertEquals(400f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child4.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_asymmetric_layout() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(600f); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeight(200f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(3); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(4); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidthPercent(100f); + root_child3.setHeight(200f); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidthPercent(100f); + root_child4.setHeight(200f); + root_child4.setGridColumnStart(2); + root_child4.setGridColumnEnd(4); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(397f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(407f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(193f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(410f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(210f, root_child2.getLayoutY(), 0.0f); + assertEquals(193f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(410f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(203f, root_child3.getLayoutX(), 0.0f); + assertEquals(210f, root_child3.getLayoutY(), 0.0f); + assertEquals(194f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(203f, root_child4.getLayoutX(), 0.0f); + assertEquals(420f, root_child4.getLayoutY(), 0.0f); + assertEquals(397f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(203f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(397f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(193f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(410f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(407f, root_child2.getLayoutX(), 0.0f); + assertEquals(210f, root_child2.getLayoutY(), 0.0f); + assertEquals(193f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(410f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(203f, root_child3.getLayoutX(), 0.0f); + assertEquals(210f, root_child3.getLayoutY(), 0.0f); + assertEquals(194f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(420f, root_child4.getLayoutY(), 0.0f); + assertEquals(397f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child4.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_with_percentage_tracks() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_percentage_tracks_with_definite_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(300f); + root.setHeight(300f); + root.setGapPercent(YogaGutter.COLUMN, 10f); + root.setGapPercent(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(210f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(210f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_spanning_items_with_span() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setGridColumnStartSpan(2); + root_child0.setGridRowStartSpan(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(220f, root.getLayoutWidth(), 0.0f); + assertEquals(420f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(110f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(310f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(110f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(320f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(220f, root.getLayoutWidth(), 0.0f); + assertEquals(420f, root.getLayoutHeight(), 0.0f); + + assertEquals(110f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(110f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(310f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(110f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(320f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_mixed_units() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(400f); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(80f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeight(80f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(80f); + root_child2.setGridColumnStart(4); + root_child2.setGridColumnEnd(5); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidthPercent(100f); + root_child3.setHeightPercent(100f); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidthPercent(100f); + root_child4.setHeightPercent(100f); + root_child4.setGridColumnStart(3); + root_child4.setGridColumnEnd(5); + root_child4.setGridRowStart(2); + root_child4.setGridRowEnd(3); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setWidthPercent(100f); + root_child5.setHeight(80f); + root_child5.setGridColumnStart(1); + root_child5.setGridColumnEnd(5); + root_child5.setGridRowStart(3); + root_child5.setGridRowEnd(4); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(110f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(380f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(90f, root_child3.getLayoutY(), 0.0f); + assertEquals(233f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(220f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(243f, root_child4.getLayoutX(), 0.0f); + assertEquals(90f, root_child4.getLayoutY(), 0.0f); + assertEquals(357f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(220f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(320f, root_child5.getLayoutY(), 0.0f); + assertEquals(600f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(110f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(380f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(367f, root_child3.getLayoutX(), 0.0f); + assertEquals(90f, root_child3.getLayoutY(), 0.0f); + assertEquals(233f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(220f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(90f, root_child4.getLayoutY(), 0.0f); + assertEquals(357f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(220f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(320f, root_child5.getLayoutY(), 0.0f); + assertEquals(600f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child5.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_overlapping_items() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(300f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(4); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_implicit_rows() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + YogaGridTrackList rootGridAutoRows = new YogaGridTrackList(); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + root.setGridAutoRows(rootGridAutoRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(100f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(80f); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(100f); + root_child3.setHeight(80f); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(100f); + root_child4.setHeight(80f); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(2); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(260f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(180f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(260f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child4.getLayoutX(), 0.0f); + assertEquals(180f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child4.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_implicit_columns() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + YogaGridTrackList rootGridAutoColumns = new YogaGridTrackList(); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + rootGridAutoColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridAutoColumns(rootGridAutoColumns); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(100f); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(80f); + root_child2.setHeight(100f); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(80f); + root_child3.setHeight(100f); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(80f); + root_child4.setHeight(100f); + root_child4.setGridColumnStart(3); + root_child4.setGridColumnEnd(4); + root_child4.setGridRowStart(1); + root_child4.setGridRowEnd(2); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(260f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(80f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(80f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(80f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(260f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(80f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(80f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(80f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_complex_spanning() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(400f); + root.setGap(YogaGutter.COLUMN, 5f); + root.setGap(YogaGutter.ROW, 5f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeight(100f); + root_child1.setGridColumnStart(3); + root_child1.setGridColumnEnd(5); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(4); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(100f); + root_child3.setHeight(100f); + root_child3.setGridColumnStart(4); + root_child3.setGridColumnEnd(5); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(100f); + root_child4.setHeightPercent(100f); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(2); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(5); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setWidth(100f); + root_child5.setHeight(100f); + root_child5.setGridColumnStart(2); + root_child5.setGridColumnEnd(3); + root_child5.setGridRowStart(3); + root_child5.setGridRowEnd(4); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setWidthPercent(100f); + root_child6.setHeight(100f); + root_child6.setGridColumnStart(2); + root_child6.setGridColumnEnd(5); + root_child6.setGridRowStart(4); + root_child6.setGridRowEnd(5); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root_child7.setWidth(100f); + root_child7.setHeight(100f); + root_child7.setGridColumnStart(4); + root_child7.setGridColumnEnd(5); + root_child7.setGridRowStart(3); + root_child7.setGridRowEnd(4); + root.addChildAt(root_child7, 7); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(205f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(205f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(210f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(205f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(210f, root_child2.getLayoutX(), 0.0f); + assertEquals(105f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(205f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(315f, root_child3.getLayoutX(), 0.0f); + assertEquals(105f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(210f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(205f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(105f, root_child5.getLayoutX(), 0.0f); + assertEquals(210f, root_child5.getLayoutY(), 0.0f); + assertEquals(100f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(105f, root_child6.getLayoutX(), 0.0f); + assertEquals(315f, root_child6.getLayoutY(), 0.0f); + assertEquals(310f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(315f, root_child7.getLayoutX(), 0.0f); + assertEquals(210f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child7.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(195f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(205f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(205f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-15f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(205f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child2.getLayoutX(), 0.0f); + assertEquals(105f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(205f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(-15f, root_child3.getLayoutX(), 0.0f); + assertEquals(105f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child4.getLayoutX(), 0.0f); + assertEquals(210f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(205f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(195f, root_child5.getLayoutX(), 0.0f); + assertEquals(210f, root_child5.getLayoutY(), 0.0f); + assertEquals(100f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(-15f, root_child6.getLayoutX(), 0.0f); + assertEquals(315f, root_child6.getLayoutY(), 0.0f); + assertEquals(310f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(-15f, root_child7.getLayoutX(), 0.0f); + assertEquals(210f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child7.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_sparse_placement() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(100f); + root_child1.setGridColumnStart(3); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(100f); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(3); + root_child2.setGridRowEnd(4); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(100f); + root_child3.setHeight(100f); + root_child3.setGridColumnStart(4); + root_child3.setGridColumnEnd(5); + root_child3.setGridRowStart(1); + root_child3.setGridRowEnd(2); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(200f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child2.getLayoutX(), 0.0f); + assertEquals(200f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_negative_line_numbers() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(300f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(-1); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeight(100f); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(-2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(-2); + root_child2.setGridColumnEnd(-1); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(-1); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(100f); + root_child3.setHeight(100f); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(2); + root_child3.setGridRowStart(-2); + root_child3.setGridRowEnd(-1); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(200f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child3.getLayoutX(), 0.0f); + assertEquals(200f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_all_fractional_units() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(600f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(4); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidthPercent(100f); + root_child3.setHeightPercent(100f); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidthPercent(100f); + root_child4.setHeightPercent(100f); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(2); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setWidthPercent(100f); + root_child5.setHeightPercent(100f); + root_child5.setGridColumnStart(2); + root_child5.setGridColumnEnd(3); + root_child5.setGridRowStart(3); + root_child5.setGridRowEnd(4); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(600f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(300f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(300f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(400f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child5.getLayoutX(), 0.0f); + assertEquals(400f, root_child5.getLayoutY(), 0.0f); + assertEquals(200f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(600f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(300f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(300f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child4.getLayoutX(), 0.0f); + assertEquals(400f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child5.getLayoutX(), 0.0f); + assertEquals(400f, root_child5.getLayoutY(), 0.0f); + assertEquals(200f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child5.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_uniform_cells() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidthPercent(100f); + root_child3.setHeightPercent(100f); + root_child3.setGridColumnStart(4); + root_child3.setGridColumnEnd(5); + root_child3.setGridRowStart(1); + root_child3.setGridRowEnd(2); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidthPercent(100f); + root_child4.setHeightPercent(100f); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(2); + root_child4.setGridRowStart(2); + root_child4.setGridRowEnd(3); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setWidthPercent(100f); + root_child5.setHeightPercent(100f); + root_child5.setGridColumnStart(2); + root_child5.setGridColumnEnd(3); + root_child5.setGridRowStart(2); + root_child5.setGridRowEnd(3); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setWidthPercent(100f); + root_child6.setHeightPercent(100f); + root_child6.setGridColumnStart(3); + root_child6.setGridColumnEnd(4); + root_child6.setGridRowStart(2); + root_child6.setGridRowEnd(3); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root_child7.setWidthPercent(100f); + root_child7.setHeightPercent(100f); + root_child7.setGridColumnStart(4); + root_child7.setGridColumnEnd(5); + root_child7.setGridRowStart(2); + root_child7.setGridRowEnd(3); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root_child8.setWidthPercent(100f); + root_child8.setHeightPercent(100f); + root_child8.setGridColumnStart(1); + root_child8.setGridColumnEnd(2); + root_child8.setGridRowStart(3); + root_child8.setGridRowEnd(4); + root.addChildAt(root_child8, 8); + + final YogaNode root_child9 = createNode(config); + root_child9.setWidthPercent(100f); + root_child9.setHeightPercent(100f); + root_child9.setGridColumnStart(2); + root_child9.setGridColumnEnd(3); + root_child9.setGridRowStart(3); + root_child9.setGridRowEnd(4); + root.addChildAt(root_child9, 9); + + final YogaNode root_child10 = createNode(config); + root_child10.setWidthPercent(100f); + root_child10.setHeightPercent(100f); + root_child10.setGridColumnStart(3); + root_child10.setGridColumnEnd(4); + root_child10.setGridRowStart(3); + root_child10.setGridRowEnd(4); + root.addChildAt(root_child10, 10); + + final YogaNode root_child11 = createNode(config); + root_child11.setWidthPercent(100f); + root_child11.setHeightPercent(100f); + root_child11.setGridColumnStart(4); + root_child11.setGridColumnEnd(5); + root_child11.setGridRowStart(3); + root_child11.setGridRowEnd(4); + root.addChildAt(root_child11, 11); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(100f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child5.getLayoutX(), 0.0f); + assertEquals(100f, root_child5.getLayoutY(), 0.0f); + assertEquals(100f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child6.getLayoutY(), 0.0f); + assertEquals(100f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(200f, root_child8.getLayoutY(), 0.0f); + assertEquals(100f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child8.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child9.getLayoutX(), 0.0f); + assertEquals(200f, root_child9.getLayoutY(), 0.0f); + assertEquals(100f, root_child9.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child9.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child10.getLayoutX(), 0.0f); + assertEquals(200f, root_child10.getLayoutY(), 0.0f); + assertEquals(100f, root_child10.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child10.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child11.getLayoutX(), 0.0f); + assertEquals(200f, root_child11.getLayoutY(), 0.0f); + assertEquals(100f, root_child11.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child11.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child4.getLayoutX(), 0.0f); + assertEquals(100f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child5.getLayoutX(), 0.0f); + assertEquals(100f, root_child5.getLayoutY(), 0.0f); + assertEquals(100f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child6.getLayoutY(), 0.0f); + assertEquals(100f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child8.getLayoutX(), 0.0f); + assertEquals(200f, root_child8.getLayoutY(), 0.0f); + assertEquals(100f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child8.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child9.getLayoutX(), 0.0f); + assertEquals(200f, root_child9.getLayoutY(), 0.0f); + assertEquals(100f, root_child9.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child9.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child10.getLayoutX(), 0.0f); + assertEquals(200f, root_child10.getLayoutY(), 0.0f); + assertEquals(100f, root_child10.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child10.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child11.getLayoutX(), 0.0f); + assertEquals(200f, root_child11.getLayoutY(), 0.0f); + assertEquals(100f, root_child11.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child11.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_auto_placement_row() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(300f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(100f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(100f); + root_child3.setHeight(100f); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_large_spans() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(250f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeight(50f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(6); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(5); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(6); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(5); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(250f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(150f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(250f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(150f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_unequal_fractions() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(3); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidthPercent(100f); + root_child3.setHeightPercent(100f); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(300f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(300f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(200f, root_child3.getLayoutY(), 0.0f); + assertEquals(400f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(300f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(300f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child3.getLayoutX(), 0.0f); + assertEquals(200f, root_child3.getLayoutY(), 0.0f); + assertEquals(400f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_single_cell() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(300f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(300f); + root_child0.setHeight(200f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_single_column() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(470f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(200f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(200f); + root_child1.setHeight(150f); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(200f); + root_child2.setHeight(100f); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(3); + root_child2.setGridRowEnd(4); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(200f); + root_child3.setHeight(120f); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(2); + root_child3.setGridRowStart(4); + root_child3.setGridRowEnd(5); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(470f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(250f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(350f, root_child3.getLayoutY(), 0.0f); + assertEquals(200f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(470f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(250f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(350f, root_child3.getLayoutY(), 0.0f); + assertEquals(200f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_single_row() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(470f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(200f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(150f); + root_child1.setHeight(200f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(200f); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(120f); + root_child3.setHeight(200f); + root_child3.setGridColumnStart(4); + root_child3.setGridColumnEnd(5); + root_child3.setGridRowStart(1); + root_child3.setGridRowEnd(2); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(470f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(350f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(120f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(470f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(370f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(220f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(120f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_tall_narrow() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(5); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(50f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(50f); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(100f); + root_child3.setHeight(50f); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(3); + root_child3.setGridRowEnd(4); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(100f); + root_child4.setHeight(50f); + root_child4.setGridColumnStart(2); + root_child4.setGridColumnEnd(3); + root_child4.setGridRowStart(4); + root_child4.setGridRowEnd(5); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setWidthPercent(100f); + root_child5.setHeightPercent(100f); + root_child5.setGridColumnStart(1); + root_child5.setGridColumnEnd(3); + root_child5.setGridRowStart(5); + root_child5.setGridRowEnd(9); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child4.getLayoutX(), 0.0f); + assertEquals(150f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(200f, root_child5.getLayoutY(), 0.0f); + assertEquals(200f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(150f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(200f, root_child5.getLayoutY(), 0.0f); + assertEquals(200f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child5.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_wide_short() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(5); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeightPercent(100f); + root_child1.setGridColumnStart(5); + root_child1.setGridColumnEnd(6); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(50f); + root_child2.setHeight(100f); + root_child2.setGridColumnStart(6); + root_child2.setGridColumnEnd(7); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(50f); + root_child3.setHeight(100f); + root_child3.setGridColumnStart(7); + root_child3.setGridColumnEnd(8); + root_child3.setGridRowStart(1); + root_child3.setGridRowEnd(2); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(50f); + root_child4.setHeight(100f); + root_child4.setGridColumnStart(8); + root_child4.setGridColumnEnd(9); + root_child4.setGridRowStart(1); + root_child4.setGridRowEnd(2); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setWidthPercent(100f); + root_child5.setHeight(100f); + root_child5.setGridColumnStart(1); + root_child5.setGridColumnEnd(5); + root_child5.setGridRowStart(2); + root_child5.setGridRowEnd(3); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setWidthPercent(100f); + root_child6.setHeight(100f); + root_child6.setGridColumnStart(6); + root_child6.setGridColumnEnd(9); + root_child6.setGridRowStart(2); + root_child6.setGridRowEnd(3); + root.addChildAt(root_child6, 6); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(350f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(100f, root_child5.getLayoutY(), 0.0f); + assertEquals(200f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child6.getLayoutY(), 0.0f); + assertEquals(150f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child6.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(50f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child5.getLayoutX(), 0.0f); + assertEquals(100f, root_child5.getLayoutY(), 0.0f); + assertEquals(200f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child6.getLayoutY(), 0.0f); + assertEquals(150f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child6.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_gap_percentage_definite_size_2() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 1f); + root.setBorder(YogaEdge.TOP, 1f); + root.setBorder(YogaEdge.RIGHT, 1f); + root.setBorder(YogaEdge.BOTTOM, 1f); + root.setGapPercent(YogaGutter.COLUMN, 70f); + root.setGapPercent(YogaGutter.ROW, 40f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPadding(YogaEdge.LEFT, 20); + root_child0.setPadding(YogaEdge.TOP, 20); + root_child0.setPadding(YogaEdge.RIGHT, 20); + root_child0.setPadding(YogaEdge.BOTTOM, 20); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPadding(YogaEdge.LEFT, 20); + root_child1.setPadding(YogaEdge.TOP, 20); + root_child1.setPadding(YogaEdge.RIGHT, 20); + root_child1.setPadding(YogaEdge.BOTTOM, 20); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setPadding(YogaEdge.LEFT, 20); + root_child2.setPadding(YogaEdge.TOP, 20); + root_child2.setPadding(YogaEdge.RIGHT, 20); + root_child2.setPadding(YogaEdge.BOTTOM, 20); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(5); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(82f, root.getLayoutWidth(), 0.0f); + assertEquals(82f, root.getLayoutHeight(), 0.0f); + + assertEquals(1f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(128f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(185f, root_child1.getLayoutX(), 0.0f); + assertEquals(1f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(57f, root_child2.getLayoutX(), 0.0f); + assertEquals(73f, root_child2.getLayoutY(), 0.0f); + assertEquals(136f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(82f, root.getLayoutWidth(), 0.0f); + assertEquals(82f, root.getLayoutHeight(), 0.0f); + + assertEquals(-47f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(128f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-143f, root_child1.getLayoutX(), 0.0f); + assertEquals(1f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(-111f, root_child2.getLayoutX(), 0.0f); + assertEquals(73f, root_child2.getLayoutY(), 0.0f); + assertEquals(136f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/YGGridTestFlows.java b/java/tests/generated/com/facebook/yoga/YGGridTestFlows.java new file mode 100644 index 0000000000..cd7c988c8a --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/YGGridTestFlows.java @@ -0,0 +1,8090 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGridTestFlows.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class YGGridTestFlows { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_indefinite_container_size_percentage_tracks() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setPadding(YogaEdge.LEFT, 30); + root_child2.setPadding(YogaEdge.TOP, 30); + root_child2.setPadding(YogaEdge.RIGHT, 30); + root_child2.setPadding(YogaEdge.BOTTOM, 30); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setMinWidth(40f); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setBorder(YogaEdge.LEFT, 10f); + root_child4.setBorder(YogaEdge.TOP, 10f); + root_child4.setBorder(YogaEdge.RIGHT, 10f); + root_child4.setBorder(YogaEdge.BOTTOM, 10f); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(260f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(104f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(234f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(260f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(104f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(104f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(130f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(260f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(-234f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(260f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(156f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(104f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(26f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(130f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child4.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_definite_container_size_percentage_tracks() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(300f); + root.setHeight(300f); + root.setGapPercent(YogaGutter.COLUMN, 20f); + root.setGapPercent(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMinWidth(40f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setPadding(YogaEdge.LEFT, 40); + root_child2.setPadding(YogaEdge.TOP, 40); + root_child2.setPadding(YogaEdge.RIGHT, 40); + root_child2.setPadding(YogaEdge.BOTTOM, 40); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setMarginPercent(YogaEdge.LEFT, 10f); + root_child3.setMarginPercent(YogaEdge.TOP, 10f); + root_child3.setMarginPercent(YogaEdge.RIGHT, 10f); + root_child3.setMarginPercent(YogaEdge.BOTTOM, 10f); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(390f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(300f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(12f, root_child3.getLayoutX(), 0.0f); + assertEquals(122f, root_child3.getLayoutY(), 0.0f); + assertEquals(96f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(216f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-30f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(-390f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(300f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(192f, root_child3.getLayoutX(), 0.0f); + assertEquals(122f, root_child3.getLayoutY(), 0.0f); + assertEquals(96f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(216f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_init_track_fixed_sizing() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(150f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(150f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_init_track_intrinsic_sizing() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(150f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(120f); + root_child2.setHeight(70f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(70f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(70f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_init_track_flexible_sizing() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_init_track_mixed_sizing() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(80f); + root_child1.setHeight(60f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(80f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(140f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(420f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(80f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(280f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(140f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_resolve_intrinsic_single_span() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(120f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(140f); + root_child2.setHeight(70f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(110f); + root_child3.setHeight(85f); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(130f); + root_child4.setHeight(95f); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(390f, root.getLayoutWidth(), 0.0f); + assertEquals(185f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(140f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(70f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(90f, root_child3.getLayoutY(), 0.0f); + assertEquals(110f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(90f, root_child4.getLayoutY(), 0.0f); + assertEquals(130f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(95f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(390f, root.getLayoutWidth(), 0.0f); + assertEquals(185f, root.getLayoutHeight(), 0.0f); + + assertEquals(270f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(170f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(140f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(70f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(280f, root_child3.getLayoutX(), 0.0f); + assertEquals(90f, root_child3.getLayoutY(), 0.0f); + assertEquals(110f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child4.getLayoutX(), 0.0f); + assertEquals(90f, root_child4.getLayoutY(), 0.0f); + assertEquals(130f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(95f, root_child4.getLayoutHeight(), 0.0f); + } + + @Test + public void test_resolve_intrinsic_multi_span() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(250f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(80f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(110f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(300f); + root_child3.setHeight(120f); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(4); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(220f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(320f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(80f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(110f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(300f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(220f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(80f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(110f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(100f, root_child3.getLayoutY(), 0.0f); + assertEquals(300f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_resolve_intrinsic_flexible_tracks() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(300f); + root_child0.setHeight(80f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(120f); + root_child2.setHeight(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(190f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(90f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(190f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(280f, root_child2.getLayoutX(), 0.0f); + assertEquals(90f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_resolve_intrinsic_progressive_spans() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(110f); + root_child1.setHeight(85f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(90f); + root_child2.setHeight(75f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(105f); + root_child3.setHeight(82f); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(250f); + root_child4.setHeight(90f); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(3); + root_child4.setGridRowStart(2); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setWidth(230f); + root_child5.setHeight(95f); + root_child5.setGridColumnStart(3); + root_child5.setGridColumnEnd(5); + root_child5.setGridRowStart(2); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setWidth(380f); + root_child6.setHeight(100f); + root_child6.setGridColumnStart(1); + root_child6.setGridColumnEnd(4); + root_child6.setGridRowStart(3); + root.addChildAt(root_child6, 6); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(508f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(131f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(110f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(272f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(90f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(390f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(105f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(82f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(95f, root_child4.getLayoutY(), 0.0f); + assertEquals(250f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(272f, root_child5.getLayoutX(), 0.0f); + assertEquals(95f, root_child5.getLayoutY(), 0.0f); + assertEquals(230f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(95f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(200f, root_child6.getLayoutY(), 0.0f); + assertEquals(380f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child6.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(508f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(408f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(267f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(110f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(146f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(90f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(13f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(105f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(82f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(258f, root_child4.getLayoutX(), 0.0f); + assertEquals(95f, root_child4.getLayoutY(), 0.0f); + assertEquals(250f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(6f, root_child5.getLayoutX(), 0.0f); + assertEquals(95f, root_child5.getLayoutY(), 0.0f); + assertEquals(230f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(95f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child6.getLayoutX(), 0.0f); + assertEquals(200f, root_child6.getLayoutY(), 0.0f); + assertEquals(380f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child6.getLayoutHeight(), 0.0f); + } + + @Test + public void test_maximize_tracks_definite_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(120f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(110f); + root_child2.setHeight(85f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(220f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(280f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(170f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_maximize_tracks_max_constraint() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setMaxWidth(400f); + root.setMaxHeight(250f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(150f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(160f); + root_child1.setHeight(110f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(170f); + root_child2.setHeight(105f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(160f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(110f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(310f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(170f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(105f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(160f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(110f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(-80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(170f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(105f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_expand_flexible_definite_free_space() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(133f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(233f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(267f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(367f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(133f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(267f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_expand_flexible_min_constraint() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setMinWidth(600f); + root.setMinHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(55f); + root_child2.setHeight(55f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(450f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(55f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(55f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(550f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(390f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(95f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(55f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(55f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_expand_flexible_max_constraint() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(800f); + root.setMaxWidth(500f); + root.setHeight(600f); + root.setMaxHeight(350f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(350f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(125f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(175f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(125f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(250f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(175f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(375f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(125f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(175f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(350f, root.getLayoutHeight(), 0.0f); + + assertEquals(375f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(125f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(175f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(125f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(250f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(175f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(125f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(175f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_expand_flexible_flex_less_than_one() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(180f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(180f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(320f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(80f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(180f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(180f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(180f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(80f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(180f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_expand_flexible_spanning_items() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(450f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(450f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(450f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(200f, root_child2.getLayoutY(), 0.0f); + assertEquals(225f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(450f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(375f, root_child2.getLayoutX(), 0.0f); + assertEquals(200f, root_child2.getLayoutY(), 0.0f); + assertEquals(225f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_stretch_auto_justify_content_stretch() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.STRETCH); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(120f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(110f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(190f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(290f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_stretch_auto_align_content_stretch() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.STRETCH); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(600f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeight(120f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeight(110f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(243f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(110f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(243f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(110f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_stretch_auto_both_axes() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.STRETCH); + root.setAlignContent(YogaAlign.STRETCH); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(120f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(110f); + root_child2.setHeight(85f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(190f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(290f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_content_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.CENTER); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_content_space_between() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_BETWEEN); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_content_space_around() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_AROUND); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(33f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(367f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(367f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(33f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_content_space_evenly() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_EVENLY); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(350f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(350f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_content_start() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.START); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(200f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(200f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_content_end() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.END); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(200f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(300f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(400f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(200f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(300f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(400f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_content_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.CENTER); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(100f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(300f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(100f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(300f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_content_space_between() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_BETWEEN); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(400f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(400f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_content_space_around() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_AROUND); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(33f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(367f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(33f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(367f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_content_space_evenly() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_EVENLY); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(50f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(350f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(50f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(350f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_self_start() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.START); + root_child0.setWidth(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setJustifySelf(YogaJustify.START); + root_child1.setWidth(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_self_end() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.END); + root_child0.setWidth(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setJustifySelf(YogaJustify.END); + root_child1.setWidth(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_self_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.CENTER); + root_child0.setWidth(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setJustifySelf(YogaJustify.CENTER); + root_child1.setWidth(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_self_stretch() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.STRETCH); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setJustifySelf(YogaJustify.STRETCH); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_self_auto_margin_left() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.LEFT); + root_child0.setWidth(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setMarginAuto(YogaEdge.LEFT); + root_child1.setWidth(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_self_auto_margin_right() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.RIGHT); + root_child0.setWidth(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setMarginAuto(YogaEdge.RIGHT); + root_child1.setWidth(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_justify_self_auto_margin_both() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.LEFT); + root_child0.setMarginAuto(YogaEdge.RIGHT); + root_child0.setWidth(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setMarginAuto(YogaEdge.LEFT); + root_child1.setMarginAuto(YogaEdge.RIGHT); + root_child1.setWidth(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_self_start() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setAlignSelf(YogaAlign.START); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setAlignSelf(YogaAlign.START); + root_child1.setWidthPercent(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_self_end() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setAlignSelf(YogaAlign.END); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setAlignSelf(YogaAlign.END); + root_child1.setWidthPercent(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(100f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(300f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(100f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(300f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_align_self_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setAlignSelf(YogaAlign.CENTER); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setAlignSelf(YogaAlign.CENTER); + root_child1.setWidthPercent(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(50f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(250f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(50f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(250f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_align_self_stretch() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_self_auto_margin_top() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.TOP); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setMarginAuto(YogaEdge.TOP); + root_child1.setWidthPercent(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(100f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(300f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(100f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(300f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_self_auto_margin_bottom() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.BOTTOM); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setMarginAuto(YogaEdge.BOTTOM); + root_child1.setWidthPercent(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_self_auto_margin_both() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.TOP); + root_child0.setMarginAuto(YogaEdge.BOTTOM); + root_child0.setWidthPercent(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setMarginAuto(YogaEdge.TOP); + root_child1.setMarginAuto(YogaEdge.BOTTOM); + root_child1.setWidthPercent(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(50f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(250f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(50f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(250f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_minimum_contribution_auto() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(120f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(150f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(270f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(270f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_minimum_contribution_definite() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(120f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(150f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(270f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(270f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_minimum_contribution_percentage_definite() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(30f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(40f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_minimum_contribution_min_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(120f); + root_child0.setMinWidth(150f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setMinWidth(180f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(330f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(180f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(330f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(180f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_content_based_min_definite_length() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(150f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(180f); + root_child1.setHeight(120f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(330f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(180f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(330f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(180f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_content_based_min_aspect_ratio() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(150f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setHeight(100f); + root_child1.setAspectRatio(0.5 / 1f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_content_based_min_content_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPadding(YogaEdge.LEFT, 20); + root_child0.setPadding(YogaEdge.TOP, 20); + root_child0.setPadding(YogaEdge.RIGHT, 20); + root_child0.setPadding(YogaEdge.BOTTOM, 20); + root_child0.setWidth(100f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPadding(YogaEdge.LEFT, 15); + root_child1.setPadding(YogaEdge.TOP, 15); + root_child1.setPadding(YogaEdge.RIGHT, 15); + root_child1.setPadding(YogaEdge.BOTTOM, 15); + root_child1.setWidth(120f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(220f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(220f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_content_based_min_fixed_track_clamp() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(300f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(250f); + root_child1.setHeight(120f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(250f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-50f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(250f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_content_based_min_span_fixed_max() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(500f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(120f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(470f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(500f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(320f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(470f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(-30f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(500f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_max_content_contribution_basic() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(150f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(180f); + root_child1.setHeight(120f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(330f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(180f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(330f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(180f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_max_content_contribution_margins() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMargin(YogaEdge.LEFT, 10f); + root_child0.setMargin(YogaEdge.TOP, 10f); + root_child0.setMargin(YogaEdge.RIGHT, 10f); + root_child0.setMargin(YogaEdge.BOTTOM, 10f); + root_child0.setWidth(150f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setMargin(YogaEdge.LEFT, 15f); + root_child1.setMargin(YogaEdge.TOP, 15f); + root_child1.setMargin(YogaEdge.RIGHT, 15f); + root_child1.setMargin(YogaEdge.BOTTOM, 15f); + root_child1.setWidth(180f); + root_child1.setHeight(120f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(380f, root.getLayoutWidth(), 0.0f); + assertEquals(150f, root.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(185f, root_child1.getLayoutX(), 0.0f); + assertEquals(15f, root_child1.getLayoutY(), 0.0f); + assertEquals(180f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(380f, root.getLayoutWidth(), 0.0f); + assertEquals(150f, root.getLayoutHeight(), 0.0f); + + assertEquals(220f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(15f, root_child1.getLayoutX(), 0.0f); + assertEquals(15f, root_child1.getLayoutY(), 0.0f); + assertEquals(180f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_limited_min_content_fixed_limit() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(400f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(120f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(310f, root.getLayoutWidth(), 0.0f); + assertEquals(230f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(400f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(110f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(310f, root.getLayoutWidth(), 0.0f); + assertEquals(230f, root.getLayoutHeight(), 0.0f); + + assertEquals(-90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(400f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(210f, root_child1.getLayoutX(), 0.0f); + assertEquals(110f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_limited_min_content_no_limit() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(400f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(120f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(230f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(400f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(110f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(230f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(400f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child1.getLayoutX(), 0.0f); + assertEquals(110f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_percentage_tracks_definite_container() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(250f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(250f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_percentage_tracks_indefinite_container() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(80f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(120f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(110f); + root_child2.setHeight(85f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(330f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(66f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(165f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(330f, root.getLayoutWidth(), 0.0f); + assertEquals(90f, root.getLayoutHeight(), 0.0f); + + assertEquals(230f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(144f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(120f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(55f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(85f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_percentage_tracks_mixed_fixed() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(400f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_percentage_gap_definite_container() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(300f); + root.setGapPercent(YogaGutter.COLUMN, 10f); + root.setGapPercent(YogaGutter.ROW, 20f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(210f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(420f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(150f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(450f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(240f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(150f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_spanning_items_span_2() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(250f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(110f); + root_child2.setHeight(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(480f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(260f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(370f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(480f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); + + assertEquals(230f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_spanning_items_span_3() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(380f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(490f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(380f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(390f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(490f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); + + assertEquals(110f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(380f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_spanning_items_overlapping() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(250f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(280f); + root_child1.setHeight(120f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(2); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(420f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child1.getLayoutX(), 0.0f); + assertEquals(110f, root_child1.getLayoutY(), 0.0f); + assertEquals(280f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(420f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(170f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(110f, root_child1.getLayoutY(), 0.0f); + assertEquals(280f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_spanning_items_both_axes() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(250f); + root_child0.setHeight(230f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(110f); + root_child2.setHeight(110f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(370f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(230f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(260f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(260f, root_child2.getLayoutX(), 0.0f); + assertEquals(115f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(110f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(370f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(230f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(115f, root_child2.getLayoutY(), 0.0f); + assertEquals(110f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(110f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_auto_margins_inline_left() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.LEFT); + root_child0.setWidth(150f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_auto_margins_inline_right() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.RIGHT); + root_child0.setWidth(150f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_auto_margins_inline_both() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.LEFT); + root_child0.setMarginAuto(YogaEdge.RIGHT); + root_child0.setWidth(150f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(75f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(75f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_auto_margins_block_top() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.TOP); + root_child0.setWidthPercent(100f); + root_child0.setHeight(150f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(150f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(150f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_auto_margins_block_bottom() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.BOTTOM); + root_child0.setWidthPercent(100f); + root_child0.setHeight(150f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_auto_margins_block_both() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.TOP); + root_child0.setMarginAuto(YogaEdge.BOTTOM); + root_child0.setWidthPercent(100f); + root_child0.setHeight(150f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(75f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(75f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_auto_margins_overrides_justify_self() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.START); + root_child0.setMarginAuto(YogaEdge.LEFT); + root_child0.setWidth(150f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_auto_margins_overrides_align_self() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setAlignSelf(YogaAlign.START); + root_child0.setMarginAuto(YogaEdge.TOP); + root_child0.setWidthPercent(100f); + root_child0.setHeight(150f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(150f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(150f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + } + + @Test + public void test_min_max_constraints_min_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(80f); + root_child0.setMinWidth(150f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(90f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(90f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(90f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_min_max_constraints_max_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setMaxWidth(120f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(280f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_min_max_constraints_min_height() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeight(80f); + root_child0.setMinHeight(150f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeight(90f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(150f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(150f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(90f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_min_max_constraints_max_height() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root_child0.setMaxHeight(120f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_min_max_constraints_both() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(80f); + root_child0.setMinWidth(100f); + root_child0.setMaxWidth(150f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(200f); + root_child1.setMinWidth(100f); + root_child1.setMaxWidth(130f); + root_child1.setHeight(100f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(230f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(130f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(230f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(130f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_gaps_justify_space_between() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_BETWEEN); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(100f); + root.setGap(YogaGutter.COLUMN, 20f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_gaps_align_space_around() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_AROUND); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(500f); + root.setGap(YogaGutter.ROW, 20f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(27f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(373f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(27f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(373f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_gaps_both_space_evenly() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_EVENLY); + root.setAlignContent(YogaAlign.SPACE_EVENLY); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setHeight(500f); + root.setGap(YogaGutter.COLUMN, 15f); + root.setGap(YogaGutter.ROW, 15f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(43f, root_child0.getLayoutX(), 0.0f); + assertEquals(43f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(43f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(358f, root_child2.getLayoutX(), 0.0f); + assertEquals(43f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(500f, root.getLayoutHeight(), 0.0f); + + assertEquals(358f, root_child0.getLayoutX(), 0.0f); + assertEquals(43f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(43f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(43f, root_child2.getLayoutX(), 0.0f); + assertEquals(43f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_gaps_spanning_items() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 20f); + root.setGap(YogaGutter.ROW, 20f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(4); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(340f, root.getLayoutWidth(), 0.0f); + assertEquals(340f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(220f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(240f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(120f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(220f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(340f, root.getLayoutWidth(), 0.0f); + assertEquals(340f, root.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(220f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(240f, root_child2.getLayoutX(), 0.0f); + assertEquals(120f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(220f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_complex_flexible_min_max_distribution() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_AROUND); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setMinWidth(400f); + root.setMaxWidth(800f); + root.setHeight(400f); + root.setGap(YogaGutter.COLUMN, 15f); + root.setGap(YogaGutter.ROW, 15f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(100f); + root_child0.setMinWidth(150f); + root_child0.setHeightPercent(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidthPercent(100f); + root_child1.setMaxWidth(250f); + root_child1.setHeightPercent(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeightPercent(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(193f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(165f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(250f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(193f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(460f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(140f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(193f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(450f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(150f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(193f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(185f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(250f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(193f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(140f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(193f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_complex_all_features_combined() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_EVENLY); + root.setJustifyItems(YogaJustify.CENTER); + root.setAlignContent(YogaAlign.SPACE_BETWEEN); + root.setAlignItems(YogaAlign.CENTER); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(800f); + root.setHeight(600f); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.START); + root_child0.setAlignSelf(YogaAlign.END); + root_child0.setMargin(YogaEdge.LEFT, 20f); + root_child0.setWidth(350f); + root_child0.setHeight(180f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(150f); + root_child1.setMaxHeight(100f); + root_child1.setAspectRatio(2 / 1f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setMinWidth(200f); + root_child2.setMaxWidth(300f); + root_child2.setHeightPercent(100f); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(4); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setMarginAuto(YogaEdge.LEFT); + root_child3.setMarginAuto(YogaEdge.TOP); + root_child3.setMarginAuto(YogaEdge.RIGHT); + root_child3.setMarginAuto(YogaEdge.BOTTOM); + root_child3.setAspectRatio(1 / 1f); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setJustifySelf(YogaJustify.STRETCH); + root_child4.setAlignSelf(YogaAlign.STRETCH); + root_child4.setWidthPercent(100f); + root_child4.setHeightPercent(100f); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(800f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(350f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(180f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(390f, root_child1.getLayoutX(), 0.0f); + assertEquals(3f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(110f, root_child2.getLayoutX(), 0.0f); + assertEquals(190f, root_child2.getLayoutY(), 0.0f); + assertEquals(260f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(465f, root_child3.getLayoutX(), 0.0f); + assertEquals(270f, root_child3.getLayoutY(), 0.0f); + assertEquals(0f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(560f, root_child4.getLayoutX(), 0.0f); + assertEquals(190f, root_child4.getLayoutY(), 0.0f); + assertEquals(240f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(800f, root.getLayoutWidth(), 0.0f); + assertEquals(600f, root.getLayoutHeight(), 0.0f); + + assertEquals(450f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(350f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(180f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(260f, root_child1.getLayoutX(), 0.0f); + assertEquals(3f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(75f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(430f, root_child2.getLayoutX(), 0.0f); + assertEquals(190f, root_child2.getLayoutY(), 0.0f); + assertEquals(260f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(335f, root_child3.getLayoutX(), 0.0f); + assertEquals(270f, root_child3.getLayoutY(), 0.0f); + assertEquals(0f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(190f, root_child4.getLayoutY(), 0.0f); + assertEquals(240f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child4.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_absolute_position_items() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(50f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setPositionType(YogaPositionType.ABSOLUTE); + root_child2.setPosition(YogaEdge.LEFT, 50f); + root_child2.setPosition(YogaEdge.TOP, 10f); + root_child2.setWidth(100f); + root_child2.setHeight(100f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setPositionType(YogaPositionType.ABSOLUTE); + root_child3.setPosition(YogaEdge.LEFT, 80f); + root_child3.setPosition(YogaEdge.TOP, 10f); + root_child3.setWidth(100f); + root_child3.setHeight(100f); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child3.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_display_none_items() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(50f); + root_child1.setDisplay(YogaDisplay.NONE); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_grid_item_with_display_contents_items() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setBorder(YogaEdge.LEFT, 2f); + root_child1.setBorder(YogaEdge.TOP, 2f); + root_child1.setBorder(YogaEdge.RIGHT, 2f); + root_child1.setBorder(YogaEdge.BOTTOM, 2f); + root_child1.setDisplay(YogaDisplay.CONTENTS); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(100f); + root_child1_child0.setHeight(100f); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(100f); + root_child2.setHeight(100f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_text_wraps_in_fixed_sized_column_tracks() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + root_child0.setData("Lorem ipsum dolor sit amet, consectetur"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_text_wraps_in_fixed_sized_column_tracks_max_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + + final YogaNode root_child0 = createNode(config); + root_child0.setMaxWidth(50f); + root.addChildAt(root_child0, 0); + root_child0.setData("Lorem ipsum dolor sit amet, consectetur"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); + + assertEquals(150f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + } + + @Test + public void test_text_wraps_in_fixed_sized_column_tracks_min_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setMinWidth(180f); + root.addChildAt(root_child0, 0); + root_child0.setData("Lorem ipsum dolor sit amet, consectetur"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(30f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(180f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(30f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(180f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/absolute_correct_cross_child_size_with_percentage.java b/java/tests/generated/com/facebook/yoga/absolute_correct_cross_child_size_with_percentage.java new file mode 100644 index 0000000000..7e89df79e1 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/absolute_correct_cross_child_size_with_percentage.java @@ -0,0 +1,134 @@ +/* + * 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 SignedSource<<9f2a69b929d43cea301731b759f8bda5>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/absolute_correct_cross_child_size_with_percentage.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class absolute_correct_cross_child_size_with_percentage { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_absolute_correct_cross_child_size_with_percentage() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setWidth(300f); + root.setHeight(110f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.LEFT, 50f); + root_child0.setPosition(YogaEdge.TOP, 40f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setWidth(200f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setWidthPercent(100f); + root_child0_child1.setHeight(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setWidthPercent(100f); + root_child0_child2.setHeight(10f); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child2_child0 = createNode(config); + root_child0_child2_child0.setWidth(10f); + root_child0_child2_child0.setHeight(10f); + root_child0_child2.addChildAt(root_child0_child2_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(40f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child2_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(110f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(40f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(190f, root_child0_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child2_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/chrome_issue_325928327.java b/java/tests/generated/com/facebook/yoga/chrome_issue_325928327.java new file mode 100644 index 0000000000..b82a6f4ce1 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/chrome_issue_325928327.java @@ -0,0 +1,102 @@ +/* + * 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 SignedSource<<66eb3e06107b80cd91c4156d773874cc>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/chrome_issue_325928327.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class chrome_issue_325928327 { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_chrome_issue_325928327_container() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyItems(YogaJustify.CENTER); + root_child0.setWidthPercent(100f); + root_child0.setHeight(40f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setHeightPercent(100f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child0_child0 = createNode(config); + root_child0_child0_child0.setHeightPercent(100f); + root_child0_child0_child0.setAspectRatio(1 / 1f); + root_child0_child0.addChildAt(root_child0_child0_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(0f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(0f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_align_self_sized_all.java b/java/tests/generated/com/facebook/yoga/grid_absolute_align_self_sized_all.java new file mode 100644 index 0000000000..4b59af8647 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_align_self_sized_all.java @@ -0,0 +1,225 @@ +/* + * 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 SignedSource<<2fc04769c6109bcb8b8e622314030da2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_align_self_sized_all.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_align_self_sized_all { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_align_self_sized_all() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setAlignSelf(YogaAlign.START); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setAlignSelf(YogaAlign.START); + root_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setAlignSelf(YogaAlign.END); + root_child2.setPositionType(YogaPositionType.ABSOLUTE); + root_child2.setWidth(20f); + root_child2.setHeight(20f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setAlignSelf(YogaAlign.END); + root_child3.setPositionType(YogaPositionType.ABSOLUTE); + root_child3.setWidth(60f); + root_child3.setHeight(60f); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setAlignSelf(YogaAlign.CENTER); + root_child4.setPositionType(YogaPositionType.ABSOLUTE); + root_child4.setWidth(20f); + root_child4.setHeight(20f); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setAlignSelf(YogaAlign.CENTER); + root_child5.setPositionType(YogaPositionType.ABSOLUTE); + root_child5.setWidth(60f); + root_child5.setHeight(60f); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setPositionType(YogaPositionType.ABSOLUTE); + root_child6.setWidth(20f); + root_child6.setHeight(20f); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root_child7.setPositionType(YogaPositionType.ABSOLUTE); + root_child7.setWidth(60f); + root_child7.setHeight(60f); + root.addChildAt(root_child7, 7); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(60f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(0f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child7.getLayoutX(), 0.0f); + assertEquals(0f, root_child7.getLayoutY(), 0.0f); + assertEquals(60f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child7.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child3.getLayoutX(), 0.0f); + assertEquals(60f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child6.getLayoutX(), 0.0f); + assertEquals(0f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child7.getLayoutX(), 0.0f); + assertEquals(0f, root_child7.getLayoutY(), 0.0f); + assertEquals(60f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child7.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_bottom_left.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_bottom_left.java new file mode 100644 index 0000000000..3f7a85dd6b --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_bottom_left.java @@ -0,0 +1,213 @@ +/* + * 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 SignedSource<<5b0b6d78d9a4784218175aec9200c4c6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_bottom_left.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_bottom_left { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_bottom_left() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.LEFT, 0f); + root_child0.setPosition(YogaEdge.BOTTOM, 0f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(160f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(160f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_bottom_left_margin.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_bottom_left_margin.java new file mode 100644 index 0000000000..14bdf29bec --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_bottom_left_margin.java @@ -0,0 +1,219 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_bottom_left_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_bottom_left_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_bottom_left_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.LEFT, 0f); + root_child0.setPosition(YogaEdge.BOTTOM, 0f); + root_child0.setMargin(YogaEdge.LEFT, 4f); + root_child0.setMargin(YogaEdge.TOP, 1f); + root_child0.setMargin(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.BOTTOM, 3f); + root_child0.setWidth(10f); + root_child0.setHeight(10f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(4f, root_child0.getLayoutX(), 0.0f); + assertEquals(147f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(4f, root_child0.getLayoutX(), 0.0f); + assertEquals(147f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_left_overrides_right.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_left_overrides_right.java new file mode 100644 index 0000000000..1c91934237 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_left_overrides_right.java @@ -0,0 +1,110 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_left_overrides_right.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_left_overrides_right { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_left_overrides_right() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.LEFT, 5f); + root_child0.setPosition(YogaEdge.RIGHT, 2f); + root_child0.setWidth(10f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(168f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_left_right.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_left_right.java new file mode 100644 index 0000000000..3eb540f5b3 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_left_right.java @@ -0,0 +1,213 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_left_right.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_left_right { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_left_right() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.LEFT, 5f); + root_child0.setPosition(YogaEdge.RIGHT, 2f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(173f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(173f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_left_right_margin.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_left_right_margin.java new file mode 100644 index 0000000000..0aa60b592f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_left_right_margin.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<3d70ae418cf1feb12545209c63f28088>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_left_right_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_left_right_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_left_right_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.LEFT, 5f); + root_child0.setPosition(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.LEFT, 4f); + root_child0.setMargin(YogaEdge.TOP, 1f); + root_child0.setMargin(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.BOTTOM, 3f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(9f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(167f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(9f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(167f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_negative_position.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_negative_position.java new file mode 100644 index 0000000000..dd793bd63f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_negative_position.java @@ -0,0 +1,216 @@ +/* + * 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 SignedSource<<7f0fbef2b7b380a0434a11288a82e5ef>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_negative_position.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_negative_position { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_negative_position() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.TOP, -5f); + root_child0.setPosition(YogaEdge.RIGHT, -15f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1.setPosition(YogaEdge.LEFT, -35f); + root_child1.setPosition(YogaEdge.BOTTOM, -25f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(195f, root_child0.getLayoutX(), 0.0f); + assertEquals(-5f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-35f, root_child1.getLayoutX(), 0.0f); + assertEquals(185f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(10f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(50f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(195f, root_child0.getLayoutX(), 0.0f); + assertEquals(-5f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-35f, root_child1.getLayoutX(), 0.0f); + assertEquals(185f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(10f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(50f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_negative_position_margin.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_negative_position_margin.java new file mode 100644 index 0000000000..de3f0cee13 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_negative_position_margin.java @@ -0,0 +1,224 @@ +/* + * 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 SignedSource<<90bc8b685f7d74d50a4d197b4e772740>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_negative_position_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_negative_position_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_negative_position_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.TOP, -5f); + root_child0.setPosition(YogaEdge.RIGHT, -15f); + root_child0.setMargin(YogaEdge.LEFT, 4f); + root_child0.setMargin(YogaEdge.TOP, 1f); + root_child0.setMargin(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.BOTTOM, 3f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1.setPosition(YogaEdge.LEFT, -35f); + root_child1.setPosition(YogaEdge.BOTTOM, -25f); + root_child1.setMargin(YogaEdge.LEFT, 4f); + root_child1.setMargin(YogaEdge.TOP, 1f); + root_child1.setMargin(YogaEdge.RIGHT, 2f); + root_child1.setMargin(YogaEdge.BOTTOM, 3f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(193f, root_child0.getLayoutX(), 0.0f); + assertEquals(-4f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-31f, root_child1.getLayoutX(), 0.0f); + assertEquals(182f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(10f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(50f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(193f, root_child0.getLayoutX(), 0.0f); + assertEquals(-4f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-31f, root_child1.getLayoutX(), 0.0f); + assertEquals(182f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(10f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(50f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_bottom.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_bottom.java new file mode 100644 index 0000000000..77e9fa7ace --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_bottom.java @@ -0,0 +1,213 @@ +/* + * 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 SignedSource<<39f18ffb8b72f07a5bb5ca29877a6323>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_bottom.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_top_bottom { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_top_bottom() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.TOP, 2f); + root_child0.setPosition(YogaEdge.BOTTOM, 5f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(2f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(153f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(2f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(153f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_bottom_margin.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_bottom_margin.java new file mode 100644 index 0000000000..9fa2fce9b0 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_bottom_margin.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<59f62a6a43ac322f469973f5bb50ef59>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_bottom_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_top_bottom_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_top_bottom_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.TOP, 2f); + root_child0.setPosition(YogaEdge.BOTTOM, 5f); + root_child0.setMargin(YogaEdge.LEFT, 4f); + root_child0.setMargin(YogaEdge.TOP, 1f); + root_child0.setMargin(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.BOTTOM, 3f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(4f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(149f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(178f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(149f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_right.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_right.java new file mode 100644 index 0000000000..dd8f56ae22 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_right.java @@ -0,0 +1,213 @@ +/* + * 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 SignedSource<<5fd388ac9ebe122d4d37a7d0605d87f2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_right.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_top_right { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_top_right() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.TOP, 0f); + root_child0.setPosition(YogaEdge.RIGHT, 0f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_right_margin.java b/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_right_margin.java new file mode 100644 index 0000000000..80898d69a1 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_container_top_right_margin.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<4583bc922d05e5d932c0a5eb3d8c5b9a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_right_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_container_top_right_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_container_top_right_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.TOP, 0f); + root_child0.setPosition(YogaEdge.RIGHT, 0f); + root_child0.setMargin(YogaEdge.LEFT, 4f); + root_child0.setMargin(YogaEdge.TOP, 1f); + root_child0.setMargin(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.BOTTOM, 3f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(178f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(178f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_justify_self_sized_all.java b/java/tests/generated/com/facebook/yoga/grid_absolute_justify_self_sized_all.java new file mode 100644 index 0000000000..7d25b5d286 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_justify_self_sized_all.java @@ -0,0 +1,227 @@ +/* + * 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 SignedSource<<5b19664aa9572f34c52fc1f6f0590955>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_justify_self_sized_all.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_justify_self_sized_all { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_justify_self_sized_all() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.START); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setJustifySelf(YogaJustify.START); + root_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setJustifySelf(YogaJustify.END); + root_child2.setPositionType(YogaPositionType.ABSOLUTE); + root_child2.setWidth(20f); + root_child2.setHeight(20f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setJustifySelf(YogaJustify.END); + root_child3.setPositionType(YogaPositionType.ABSOLUTE); + root_child3.setWidth(60f); + root_child3.setHeight(60f); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setJustifySelf(YogaJustify.CENTER); + root_child4.setPositionType(YogaPositionType.ABSOLUTE); + root_child4.setWidth(20f); + root_child4.setHeight(20f); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setJustifySelf(YogaJustify.CENTER); + root_child5.setPositionType(YogaPositionType.ABSOLUTE); + root_child5.setWidth(60f); + root_child5.setHeight(60f); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setJustifySelf(YogaJustify.STRETCH); + root_child6.setPositionType(YogaPositionType.ABSOLUTE); + root_child6.setWidth(20f); + root_child6.setHeight(20f); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root_child7.setJustifySelf(YogaJustify.STRETCH); + root_child7.setPositionType(YogaPositionType.ABSOLUTE); + root_child7.setWidth(60f); + root_child7.setHeight(60f); + root.addChildAt(root_child7, 7); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child5.getLayoutX(), 0.0f); + assertEquals(0f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(0f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child7.getLayoutX(), 0.0f); + assertEquals(0f, root_child7.getLayoutY(), 0.0f); + assertEquals(60f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child7.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child5.getLayoutX(), 0.0f); + assertEquals(0f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child6.getLayoutX(), 0.0f); + assertEquals(0f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child7.getLayoutX(), 0.0f); + assertEquals(0f, root_child7.getLayoutY(), 0.0f); + assertEquals(60f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child7.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_layout_within_border.java b/java/tests/generated/com/facebook/yoga/grid_absolute_layout_within_border.java new file mode 100644 index 0000000000..f84b91d61b --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_layout_within_border.java @@ -0,0 +1,147 @@ +/* + * 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 SignedSource<<2f86977d58204d6dadbd988a5d4f8548>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_layout_within_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_layout_within_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_layout_within_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 10); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 10); + root.setPadding(YogaEdge.BOTTOM, 10); + root.setBorder(YogaEdge.LEFT, 10f); + root.setBorder(YogaEdge.TOP, 10f); + root.setBorder(YogaEdge.RIGHT, 10f); + root.setBorder(YogaEdge.BOTTOM, 10f); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.LEFT, 0f); + root_child0.setPosition(YogaEdge.TOP, 0f); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1.setPosition(YogaEdge.RIGHT, 0f); + root_child1.setPosition(YogaEdge.BOTTOM, 0f); + root_child1.setWidth(50f); + root_child1.setHeight(50f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setPositionType(YogaPositionType.ABSOLUTE); + root_child2.setPosition(YogaEdge.LEFT, 0f); + root_child2.setPosition(YogaEdge.TOP, 0f); + root_child2.setMargin(YogaEdge.LEFT, 10f); + root_child2.setMargin(YogaEdge.TOP, 10f); + root_child2.setMargin(YogaEdge.RIGHT, 10f); + root_child2.setMargin(YogaEdge.BOTTOM, 10f); + root_child2.setWidth(50f); + root_child2.setHeight(50f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setPositionType(YogaPositionType.ABSOLUTE); + root_child3.setPosition(YogaEdge.RIGHT, 0f); + root_child3.setPosition(YogaEdge.BOTTOM, 0f); + root_child3.setMargin(YogaEdge.LEFT, 10f); + root_child3.setMargin(YogaEdge.TOP, 10f); + root_child3.setMargin(YogaEdge.RIGHT, 10f); + root_child3.setMargin(YogaEdge.BOTTOM, 10f); + root_child3.setWidth(50f); + root_child3.setHeight(50f); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_layout_within_border_static.java b/java/tests/generated/com/facebook/yoga/grid_absolute_layout_within_border_static.java new file mode 100644 index 0000000000..75fc7f7ce0 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_layout_within_border_static.java @@ -0,0 +1,147 @@ +/* + * 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 SignedSource<<899fe610c299f3be9f782742ff9ad2c2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_layout_within_border_static.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_layout_within_border_static { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_layout_within_border_static() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 10); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 10); + root.setPadding(YogaEdge.BOTTOM, 10); + root.setBorder(YogaEdge.LEFT, 10f); + root.setBorder(YogaEdge.TOP, 10f); + root.setBorder(YogaEdge.RIGHT, 10f); + root.setBorder(YogaEdge.BOTTOM, 10f); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.START); + root_child0.setAlignSelf(YogaAlign.START); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setJustifySelf(YogaJustify.END); + root_child1.setAlignSelf(YogaAlign.END); + root_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1.setWidth(50f); + root_child1.setHeight(50f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setJustifySelf(YogaJustify.START); + root_child2.setAlignSelf(YogaAlign.START); + root_child2.setPositionType(YogaPositionType.ABSOLUTE); + root_child2.setMargin(YogaEdge.LEFT, 10f); + root_child2.setMargin(YogaEdge.TOP, 10f); + root_child2.setMargin(YogaEdge.RIGHT, 10f); + root_child2.setMargin(YogaEdge.BOTTOM, 10f); + root_child2.setWidth(50f); + root_child2.setHeight(50f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setJustifySelf(YogaJustify.END); + root_child3.setAlignSelf(YogaAlign.END); + root_child3.setPositionType(YogaPositionType.ABSOLUTE); + root_child3.setMargin(YogaEdge.LEFT, 10f); + root_child3.setMargin(YogaEdge.TOP, 10f); + root_child3.setMargin(YogaEdge.RIGHT, 10f); + root_child3.setMargin(YogaEdge.BOTTOM, 10f); + root_child3.setWidth(50f); + root_child3.setHeight(50f); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_resolved_insets.java b/java/tests/generated/com/facebook/yoga/grid_absolute_resolved_insets.java new file mode 100644 index 0000000000..cdbe34b1a4 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_resolved_insets.java @@ -0,0 +1,301 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_resolved_insets.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_resolved_insets { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_resolved_insets() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + + final YogaNode root_child0 = createNode(config); + root_child0.setPadding(YogaEdge.LEFT, 15); + root_child0.setPadding(YogaEdge.TOP, 15); + root_child0.setPadding(YogaEdge.RIGHT, 15); + root_child0.setPadding(YogaEdge.BOTTOM, 15); + root_child0.setBorder(YogaEdge.LEFT, 20f); + root_child0.setBorder(YogaEdge.TOP, 20f); + root_child0.setBorder(YogaEdge.RIGHT, 20f); + root_child0.setBorder(YogaEdge.BOTTOM, 20f); + root_child0.setWidth(200f); + root_child0.setHeight(200f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPositionAuto(YogaEdge.LEFT); + root_child0_child0.setPositionAuto(YogaEdge.TOP); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child1.setPosition(YogaEdge.LEFT, 0f); + root_child0_child1.setPosition(YogaEdge.TOP, 0f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child2.setPositionPercent(YogaEdge.LEFT, 100f); + root_child0_child2.setPositionPercent(YogaEdge.TOP, 100f); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0_child3.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child3.setPositionPercent(YogaEdge.RIGHT, 100f); + root_child0_child3.setPositionPercent(YogaEdge.BOTTOM, 100f); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0_child4.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child4.setPosition(YogaEdge.LEFT, 30f); + root_child0_child4.setPosition(YogaEdge.TOP, 30f); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0_child5.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child5.setPosition(YogaEdge.LEFT, 0f); + root_child0_child5.setPosition(YogaEdge.TOP, 0f); + root_child0_child5.setWidthPercent(100f); + root_child0_child5.setHeightPercent(100f); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child1 = createNode(config); + root_child1.setOverflow(YogaOverflow.SCROLL); + root_child1.setPadding(YogaEdge.LEFT, 15); + root_child1.setPadding(YogaEdge.TOP, 15); + root_child1.setPadding(YogaEdge.RIGHT, 15); + root_child1.setPadding(YogaEdge.BOTTOM, 15); + root_child1.setBorder(YogaEdge.LEFT, 20f); + root_child1.setBorder(YogaEdge.TOP, 20f); + root_child1.setBorder(YogaEdge.RIGHT, 20f); + root_child1.setBorder(YogaEdge.BOTTOM, 20f); + root_child1.setWidth(200f); + root_child1.setHeight(200f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child1_child0.setPositionAuto(YogaEdge.LEFT); + root_child1_child0.setPositionAuto(YogaEdge.TOP); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child1_child1 = createNode(config); + root_child1_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1_child1.setPosition(YogaEdge.LEFT, 0f); + root_child1_child1.setPosition(YogaEdge.TOP, 0f); + root_child1.addChildAt(root_child1_child1, 1); + + final YogaNode root_child1_child2 = createNode(config); + root_child1_child2.setPositionType(YogaPositionType.ABSOLUTE); + root_child1_child2.setPositionPercent(YogaEdge.LEFT, 100f); + root_child1_child2.setPositionPercent(YogaEdge.TOP, 100f); + root_child1.addChildAt(root_child1_child2, 2); + + final YogaNode root_child1_child3 = createNode(config); + root_child1_child3.setPositionType(YogaPositionType.ABSOLUTE); + root_child1_child3.setPositionPercent(YogaEdge.RIGHT, 100f); + root_child1_child3.setPositionPercent(YogaEdge.BOTTOM, 100f); + root_child1.addChildAt(root_child1_child3, 3); + + final YogaNode root_child1_child4 = createNode(config); + root_child1_child4.setPositionType(YogaPositionType.ABSOLUTE); + root_child1_child4.setPosition(YogaEdge.LEFT, 30f); + root_child1_child4.setPosition(YogaEdge.TOP, 30f); + root_child1.addChildAt(root_child1_child4, 4); + + final YogaNode root_child1_child5 = createNode(config); + root_child1_child5.setPositionType(YogaPositionType.ABSOLUTE); + root_child1_child5.setPosition(YogaEdge.LEFT, 0f); + root_child1_child5.setPosition(YogaEdge.TOP, 0f); + root_child1_child5.setWidthPercent(100f); + root_child1_child5.setHeightPercent(100f); + root_child1.addChildAt(root_child1_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(180f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(160f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(180f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child5.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child5.getLayoutY(), 0.0f); + assertEquals(160f, root_child1_child5.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child1_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(180f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(160f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(200f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(180f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child1_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child5.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child5.getLayoutY(), 0.0f); + assertEquals(160f, root_child1_child5.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child1_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_top_overrides_bottom.java b/java/tests/generated/com/facebook/yoga/grid_absolute_top_overrides_bottom.java new file mode 100644 index 0000000000..3ef79b7862 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_top_overrides_bottom.java @@ -0,0 +1,214 @@ +/* + * 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 SignedSource<<30c10512acc1400e2e0f464e57059175>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_top_overrides_bottom.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_top_overrides_bottom { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_top_overrides_bottom() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.TOP, 2f); + root_child0.setPosition(YogaEdge.BOTTOM, 5f); + root_child0.setHeight(10f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(2f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(2f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_with_padding.java b/java/tests/generated/com/facebook/yoga/grid_absolute_with_padding.java new file mode 100644 index 0000000000..d5aee3250b --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_with_padding.java @@ -0,0 +1,216 @@ +/* + * 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 SignedSource<<7a02ce77a7eb926852178197f1ac6d40>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_with_padding.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_with_padding { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_with_padding() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.TOP, 0f); + root_child0.setPosition(YogaEdge.RIGHT, 0f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1.setPosition(YogaEdge.LEFT, 10f); + root_child1.setPosition(YogaEdge.BOTTOM, 10f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(150f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(10f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(50f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child1.getLayoutX(), 0.0f); + assertEquals(150f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(10f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(50f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_absolute_with_padding_and_margin.java b/java/tests/generated/com/facebook/yoga/grid_absolute_with_padding_and_margin.java new file mode 100644 index 0000000000..2b6109dffa --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_absolute_with_padding_and_margin.java @@ -0,0 +1,224 @@ +/* + * 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 SignedSource<<2aa948e137ee56f00538a981f5a57e11>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_with_padding_and_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_absolute_with_padding_and_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_absolute_with_padding_and_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPosition(YogaEdge.TOP, 0f); + root_child0.setPosition(YogaEdge.RIGHT, 0f); + root_child0.setMargin(YogaEdge.LEFT, 4f); + root_child0.setMargin(YogaEdge.TOP, 1f); + root_child0.setMargin(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.BOTTOM, 3f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPositionType(YogaPositionType.ABSOLUTE); + root_child1.setPosition(YogaEdge.LEFT, 10f); + root_child1.setPosition(YogaEdge.BOTTOM, 10f); + root_child1.setMargin(YogaEdge.LEFT, 4f); + root_child1.setMargin(YogaEdge.TOP, 1f); + root_child1.setMargin(YogaEdge.RIGHT, 2f); + root_child1.setMargin(YogaEdge.BOTTOM, 3f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(178f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(14f, root_child1.getLayoutX(), 0.0f); + assertEquals(147f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(10f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(50f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(178f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(14f, root_child1.getLayoutX(), 0.0f); + assertEquals(147f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(10f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(10f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(50f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_center.java b/java/tests/generated/com/facebook/yoga/grid_align_content_center.java new file mode 100644 index 0000000000..72ff68a1ab --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_center.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<<3999d811ced4c9414ce611720a36e1f3>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_center.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_center { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.CENTER); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(40f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(120f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(120f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(120f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(40f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(120f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(120f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(120f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_center_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_align_content_center_negative_space_gap.java new file mode 100644 index 0000000000..28fa646565 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_center_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_center_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_center_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_center_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.CENTER); + root_child0.setAlignContent(YogaAlign.CENTER); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(-10f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(-10f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(-10f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(-10f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(-10f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(-10f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_end.java b/java/tests/generated/com/facebook/yoga/grid_align_content_end.java new file mode 100644 index 0000000000..2eca2ac42d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_end.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<<635389015b7f9bf6598416bf4134a804>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_end.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_end { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_end() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.END); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(120f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(120f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(120f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(160f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(160f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(160f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(80f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(120f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(120f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(120f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(160f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(160f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(160f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_end_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_align_content_end_negative_space_gap.java new file mode 100644 index 0000000000..76d1e94c6c --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_end_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_end_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_end_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_end_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.CENTER); + root_child0.setAlignContent(YogaAlign.END); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(-20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(-20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(-20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(30f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(-20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(-20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(-20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(30f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_end_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_align_content_end_with_padding_border.java new file mode 100644 index 0000000000..f3361968b8 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_end_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<95d9167a1edb48ed8322b98f5090e2a9>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_end_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_end_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_end_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.END); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child0.getLayoutX(), 0.0f); + assertEquals(44f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child1.getLayoutX(), 0.0f); + assertEquals(44f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child2.getLayoutX(), 0.0f); + assertEquals(44f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child3.getLayoutX(), 0.0f); + assertEquals(84f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child4.getLayoutX(), 0.0f); + assertEquals(84f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child5.getLayoutX(), 0.0f); + assertEquals(84f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child6.getLayoutX(), 0.0f); + assertEquals(124f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child7.getLayoutX(), 0.0f); + assertEquals(124f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child8.getLayoutX(), 0.0f); + assertEquals(124f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child0.getLayoutX(), 0.0f); + assertEquals(44f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child1.getLayoutX(), 0.0f); + assertEquals(44f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child2.getLayoutX(), 0.0f); + assertEquals(44f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child3.getLayoutX(), 0.0f); + assertEquals(84f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child4.getLayoutX(), 0.0f); + assertEquals(84f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child5.getLayoutX(), 0.0f); + assertEquals(84f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child6.getLayoutX(), 0.0f); + assertEquals(124f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child7.getLayoutX(), 0.0f); + assertEquals(124f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child8.getLayoutX(), 0.0f); + assertEquals(124f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_space_around.java b/java/tests/generated/com/facebook/yoga/grid_align_content_space_around.java new file mode 100644 index 0000000000..8d9fcb048a --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_space_around.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_around.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_space_around { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_space_around() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_AROUND); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(13f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(13f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(13f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(147f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(147f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(147f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(13f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(13f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(13f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(147f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(147f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(147f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_space_around_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_align_content_space_around_negative_space_gap.java new file mode 100644 index 0000000000..3072408e1d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_space_around_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<<8c572d4963de3ffa94b91fe4edaf8346>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_around_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_space_around_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_space_around_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.CENTER); + root_child0.setAlignContent(YogaAlign.SPACE_AROUND); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_space_around_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_align_content_space_around_with_padding_border.java new file mode 100644 index 0000000000..5fbd4503a6 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_space_around_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_around_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_space_around_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_space_around_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_AROUND); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child0.getLayoutX(), 0.0f); + assertEquals(17f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child1.getLayoutX(), 0.0f); + assertEquals(17f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child2.getLayoutX(), 0.0f); + assertEquals(17f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child3.getLayoutX(), 0.0f); + assertEquals(68f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child4.getLayoutX(), 0.0f); + assertEquals(68f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child5.getLayoutX(), 0.0f); + assertEquals(68f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child6.getLayoutX(), 0.0f); + assertEquals(119f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child7.getLayoutX(), 0.0f); + assertEquals(119f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child8.getLayoutX(), 0.0f); + assertEquals(119f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child0.getLayoutX(), 0.0f); + assertEquals(17f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child1.getLayoutX(), 0.0f); + assertEquals(17f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child2.getLayoutX(), 0.0f); + assertEquals(17f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child3.getLayoutX(), 0.0f); + assertEquals(68f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child4.getLayoutX(), 0.0f); + assertEquals(68f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child5.getLayoutX(), 0.0f); + assertEquals(68f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child6.getLayoutX(), 0.0f); + assertEquals(119f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child7.getLayoutX(), 0.0f); + assertEquals(119f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child8.getLayoutX(), 0.0f); + assertEquals(119f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_space_between.java b/java/tests/generated/com/facebook/yoga/grid_align_content_space_between.java new file mode 100644 index 0000000000..4d8314c130 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_space_between.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<<1e25852bf5c65d559bdace65461bfc0a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_between.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_space_between { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_space_between() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_BETWEEN); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(160f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(160f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(160f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(160f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(160f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(160f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_space_between_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_align_content_space_between_negative_space_gap.java new file mode 100644 index 0000000000..6408e0a176 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_space_between_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_between_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_space_between_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_space_between_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.CENTER); + root_child0.setAlignContent(YogaAlign.SPACE_BETWEEN); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_space_between_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_align_content_space_between_with_padding_border.java new file mode 100644 index 0000000000..a382cc900d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_space_between_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<2b86c121a70d12711c0c90563824bc24>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_between_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_space_between_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_space_between_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_BETWEEN); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child3.getLayoutX(), 0.0f); + assertEquals(68f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child4.getLayoutX(), 0.0f); + assertEquals(68f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child5.getLayoutX(), 0.0f); + assertEquals(68f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child6.getLayoutX(), 0.0f); + assertEquals(124f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child7.getLayoutX(), 0.0f); + assertEquals(124f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child8.getLayoutX(), 0.0f); + assertEquals(124f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child3.getLayoutX(), 0.0f); + assertEquals(68f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child4.getLayoutX(), 0.0f); + assertEquals(68f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child5.getLayoutX(), 0.0f); + assertEquals(68f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child6.getLayoutX(), 0.0f); + assertEquals(124f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child7.getLayoutX(), 0.0f); + assertEquals(124f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child8.getLayoutX(), 0.0f); + assertEquals(124f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_space_evenly.java b/java/tests/generated/com/facebook/yoga/grid_align_content_space_evenly.java new file mode 100644 index 0000000000..a6d5dd9027 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_space_evenly.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<<14b597c34c1477c5e483f6f989b0f383>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_space_evenly { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_space_evenly() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_EVENLY); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(140f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(140f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(140f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(140f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(140f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(140f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_space_evenly_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_align_content_space_evenly_negative_space_gap.java new file mode 100644 index 0000000000..f0db3c6071 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_space_evenly_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_space_evenly_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_space_evenly_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.CENTER); + root_child0.setAlignContent(YogaAlign.SPACE_BETWEEN); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_space_evenly_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_align_content_space_evenly_with_padding_border.java new file mode 100644 index 0000000000..0af2ffd9db --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_space_evenly_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_space_evenly_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_space_evenly_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_EVENLY); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child3.getLayoutX(), 0.0f); + assertEquals(68f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child4.getLayoutX(), 0.0f); + assertEquals(68f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child5.getLayoutX(), 0.0f); + assertEquals(68f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child6.getLayoutX(), 0.0f); + assertEquals(116f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child7.getLayoutX(), 0.0f); + assertEquals(116f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child8.getLayoutX(), 0.0f); + assertEquals(116f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child3.getLayoutX(), 0.0f); + assertEquals(68f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child4.getLayoutX(), 0.0f); + assertEquals(68f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child5.getLayoutX(), 0.0f); + assertEquals(68f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child6.getLayoutX(), 0.0f); + assertEquals(116f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child7.getLayoutX(), 0.0f); + assertEquals(116f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child8.getLayoutX(), 0.0f); + assertEquals(116f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_start.java b/java/tests/generated/com/facebook/yoga/grid_align_content_start.java new file mode 100644 index 0000000000..31cf67755b --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_start.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_start.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_start { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_start() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.START); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_start_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_align_content_start_negative_space_gap.java new file mode 100644 index 0000000000..bdb0668da7 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_start_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<<94cc6733096b402dca4f3e827cd43741>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_start_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_start_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_start_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.CENTER); + root_child0.setAlignContent(YogaAlign.START); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_content_start_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_align_content_start_with_padding_border.java new file mode 100644 index 0000000000..53b1d2f3fb --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_content_start_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<2ee6161d2ede5336062684411ad84e44>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_start_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_content_start_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_content_start_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.START); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline.java new file mode 100644 index 0000000000..d64b47a790 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline.java @@ -0,0 +1,92 @@ +/* + * 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 SignedSource<<5229b929d8e9ad78154a2b9fecd1d6fc>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child.java new file mode 100644 index 0000000000..b8c72a23da --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child.java @@ -0,0 +1,108 @@ +/* + * 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 SignedSource<<92c6d4f3beea32231c6c83d725f9431e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_child { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_child() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(10f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_margin.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_margin.java new file mode 100644 index 0000000000..507bc80f11 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_margin.java @@ -0,0 +1,116 @@ +/* + * 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 SignedSource<<4641d7c49452ccae1de12716b58697da>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_child_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_child_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setMargin(YogaEdge.LEFT, 5f); + root_child0.setMargin(YogaEdge.TOP, 5f); + root_child0.setMargin(YogaEdge.RIGHT, 5f); + root_child0.setMargin(YogaEdge.BOTTOM, 5f); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setMargin(YogaEdge.LEFT, 5f); + root_child1_child0.setMargin(YogaEdge.TOP, 5f); + root_child1_child0.setMargin(YogaEdge.RIGHT, 5f); + root_child1_child0.setMargin(YogaEdge.BOTTOM, 5f); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(10f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(45f, root_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(-5f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_margin_percent.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_margin_percent.java new file mode 100644 index 0000000000..1692e30561 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_margin_percent.java @@ -0,0 +1,116 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_margin_percent.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_child_margin_percent { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_child_margin_percent() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginPercent(YogaEdge.LEFT, 5f); + root_child0.setMarginPercent(YogaEdge.TOP, 5f); + root_child0.setMarginPercent(YogaEdge.RIGHT, 5f); + root_child0.setMarginPercent(YogaEdge.BOTTOM, 5f); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setMarginPercent(YogaEdge.LEFT, 1f); + root_child1_child0.setMarginPercent(YogaEdge.TOP, 1f); + root_child1_child0.setMarginPercent(YogaEdge.RIGHT, 1f); + root_child1_child0.setMarginPercent(YogaEdge.BOTTOM, 1f); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(10f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(3f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(55f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(1f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(55f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_multiline.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_multiline.java new file mode 100644 index 0000000000..0104261ab6 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_multiline.java @@ -0,0 +1,166 @@ +/* + * 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 SignedSource<<69ddcbb9243f7aebcdf3f6cd1d43b2eb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_multiline.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_child_multiline { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_child_multiline() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(60f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWrap(YogaWrap.WRAP); + root_child1.setWidth(50f); + root_child1.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child1GridTemplateColumns = new YogaGridTrackList(); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1.setGridTemplateColumns(root_child1GridTemplateColumns); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(25f); + root_child1_child0.setHeight(20f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child1_child1 = createNode(config); + root_child1_child1.setWidth(25f); + root_child1_child1.setHeight(10f); + root_child1_child1.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child1, 1); + + final YogaNode root_child1_child2 = createNode(config); + root_child1_child2.setWidth(25f); + root_child1_child2.setHeight(20f); + root_child1_child2.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child2, 2); + + final YogaNode root_child1_child3 = createNode(config); + root_child1_child3.setWidth(25f); + root_child1_child3.setHeight(10f); + root_child1_child3.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_multiline_no_override_on_secondline.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_multiline_no_override_on_secondline.java new file mode 100644 index 0000000000..a9b7c3dafe --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_multiline_no_override_on_secondline.java @@ -0,0 +1,168 @@ +/* + * 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 SignedSource<<476e3ae6327c5c84b7dac6435e395383>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_multiline_no_override_on_secondline.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_child_multiline_no_override_on_secondline { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_child_multiline_no_override_on_secondline() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(60f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(25f); + root_child1.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child1GridTemplateColumns = new YogaGridTrackList(); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1.setGridTemplateColumns(root_child1GridTemplateColumns); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(25f); + root_child1_child0.setHeight(20f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child1_child1 = createNode(config); + root_child1_child1.setWidth(25f); + root_child1_child1.setHeight(10f); + root_child1_child1.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child1, 1); + + final YogaNode root_child1_child2 = createNode(config); + root_child1_child2.setWidth(25f); + root_child1_child2.setHeight(20f); + root_child1_child2.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child2, 2); + + final YogaNode root_child1_child3 = createNode(config); + root_child1_child3.setAlignSelf(YogaAlign.BASELINE); + root_child1_child3.setWidth(25f); + root_child1_child3.setHeight(10f); + root_child1_child3.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_multiline_override.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_multiline_override.java new file mode 100644 index 0000000000..fa9498086f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_multiline_override.java @@ -0,0 +1,169 @@ +/* + * 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 SignedSource<<455709e3a0b7e373f3433be8def72f7e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_multiline_override.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_child_multiline_override { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_child_multiline_override() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(60f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(25f); + root_child1.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child1GridTemplateColumns = new YogaGridTrackList(); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child1.setGridTemplateColumns(root_child1GridTemplateColumns); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(25f); + root_child1_child0.setHeight(20f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child1_child1 = createNode(config); + root_child1_child1.setAlignSelf(YogaAlign.BASELINE); + root_child1_child1.setWidth(25f); + root_child1_child1.setHeight(10f); + root_child1_child1.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child1, 1); + + final YogaNode root_child1_child2 = createNode(config); + root_child1_child2.setWidth(25f); + root_child1_child2.setHeight(20f); + root_child1_child2.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child2, 2); + + final YogaNode root_child1_child3 = createNode(config); + root_child1_child3.setAlignSelf(YogaAlign.BASELINE); + root_child1_child3.setWidth(25f); + root_child1_child3.setHeight(10f); + root_child1_child3.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(25f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_padding.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_padding.java new file mode 100644 index 0000000000..56abe2ee89 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_padding.java @@ -0,0 +1,116 @@ +/* + * 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 SignedSource<<0e0ffc83337b6f3fda7911779840177e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_padding.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_child_padding { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_child_padding() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 5); + root.setPadding(YogaEdge.TOP, 5); + root.setPadding(YogaEdge.RIGHT, 5); + root.setPadding(YogaEdge.BOTTOM, 5); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPadding(YogaEdge.LEFT, 5); + root_child1.setPadding(YogaEdge.TOP, 5); + root_child1.setPadding(YogaEdge.RIGHT, 5); + root_child1.setPadding(YogaEdge.BOTTOM, 5); + root_child1.setWidth(50f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(10f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child1.getLayoutX(), 0.0f); + assertEquals(55f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(45f, root_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(45f, root_child1.getLayoutX(), 0.0f); + assertEquals(55f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(-5f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_top.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_top.java new file mode 100644 index 0000000000..50104b72c3 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_top.java @@ -0,0 +1,109 @@ +/* + * 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 SignedSource<<852d0242b3f6ca436b8225489e702546>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_top.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_child_top { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_child_top() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setPosition(YogaEdge.TOP, 10f); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(10f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_top2.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_top2.java new file mode 100644 index 0000000000..e58f7a60a9 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_child_top2.java @@ -0,0 +1,109 @@ +/* + * 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 SignedSource<<7e8603b70f05a931655fc7873a73f9eb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_top2.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_child_top2 { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_child_top2() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setPosition(YogaEdge.TOP, 5f); + root_child1.setWidth(50f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(10f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(55f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(55f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_complex.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_complex.java new file mode 100644 index 0000000000..d8c15e46cd --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_complex.java @@ -0,0 +1,283 @@ +/* + * 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 SignedSource<<03ddae6ab0bb4b85fa74580b859cdc35>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_complex.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_complex { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_complex() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(20f); + root_child1.setHeight(20f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setHeight(10f); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(20f); + root_child2.setHeight(20f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child2_child0 = createNode(config); + root_child2_child0.setHeight(10f); + root_child2.addChildAt(root_child2_child0, 0); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(20f); + root_child3.setHeight(20f); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(20f); + root_child4.setHeight(20f); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setWidth(20f); + root_child5.setHeight(20f); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setWidth(20f); + root_child6.setHeight(20f); + root.addChildAt(root_child6, 6); + + final YogaNode root_child6_child0 = createNode(config); + root_child6_child0.setHeight(10f); + root_child6.addChildAt(root_child6_child0, 0); + + final YogaNode root_child7 = createNode(config); + root_child7.setWidth(20f); + root_child7.setHeight(20f); + root.addChildAt(root_child7, 7); + + final YogaNode root_child7_child0 = createNode(config); + root_child7_child0.setHeight(5f); + root_child7.addChildAt(root_child7_child0, 0); + + final YogaNode root_child8 = createNode(config); + root_child8.setWidth(20f); + root_child8.setHeight(20f); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(90f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child6_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child6_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child6_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(95f, root_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child7_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child7_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child7_child0.getLayoutWidth(), 0.0f); + assertEquals(5f, root_child7_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child6.getLayoutX(), 0.0f); + assertEquals(90f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child6_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child6_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child6_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child7.getLayoutX(), 0.0f); + assertEquals(95f, root_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child7_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child7_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child7_child0.getLayoutWidth(), 0.0f); + assertEquals(5f, root_child7_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(20f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_double_nested_child.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_double_nested_child.java new file mode 100644 index 0000000000..b0d9451312 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_double_nested_child.java @@ -0,0 +1,124 @@ +/* + * 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 SignedSource<<00811a9ed7bfc664994073470f1a9ba5>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_double_nested_child.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_double_nested_child { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_double_nested_child() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setWidth(50f); + root_child0_child0.setHeight(20f); + root_child0_child0.setDisplay(YogaDisplay.GRID); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(15f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(15f, root_child1_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(15f, root_child1_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_multiline.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_multiline.java new file mode 100644 index 0000000000..d4174dde18 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_multiline.java @@ -0,0 +1,167 @@ +/* + * 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 SignedSource<<3058c3d9311f0526594a48ee6b67baa0>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_multiline.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_multiline { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_multiline() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(10f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(50f); + root_child2.setHeight(20f); + root_child2.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child2, 2); + + final YogaNode root_child2_child0 = createNode(config); + root_child2_child0.setWidth(50f); + root_child2_child0.setHeight(10f); + root_child2_child0.setDisplay(YogaDisplay.GRID); + root_child2.addChildAt(root_child2_child0, 0); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(50f); + root_child3.setHeight(50f); + root_child3.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(60f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(60f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_multiline_column.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_multiline_column.java new file mode 100644 index 0000000000..0021caa903 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_multiline_column.java @@ -0,0 +1,167 @@ +/* + * 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 SignedSource<<87e0883d35c1155bd8aadb814cae403e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_multiline_column.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_multiline_column { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_multiline_column() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(30f); + root_child1.setHeight(50f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(20f); + root_child1_child0.setHeight(20f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(40f); + root_child2.setHeight(70f); + root_child2.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child2, 2); + + final YogaNode root_child2_child0 = createNode(config); + root_child2_child0.setWidth(10f); + root_child2_child0.setHeight(10f); + root_child2_child0.setDisplay(YogaDisplay.GRID); + root_child2.addChildAt(root_child2_child0, 0); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(50f); + root_child3.setHeight(20f); + root_child3.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(30f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(90f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(70f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(30f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child2.getLayoutX(), 0.0f); + assertEquals(90f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(70f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child3.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_multiline_row_and_column.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_multiline_row_and_column.java new file mode 100644 index 0000000000..57f72e1dc6 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_multiline_row_and_column.java @@ -0,0 +1,167 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_multiline_row_and_column.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_multiline_row_and_column { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_multiline_row_and_column() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(50f); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(10f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(50f); + root_child2.setHeight(20f); + root_child2.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child2, 2); + + final YogaNode root_child2_child0 = createNode(config); + root_child2_child0.setWidth(50f); + root_child2_child0.setHeight(10f); + root_child2_child0.setDisplay(YogaDisplay.GRID); + root_child2.addChildAt(root_child2_child0, 0); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(50f); + root_child3.setHeight(20f); + root_child3.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(90f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child2_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(90f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child3.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_nested_column.java b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_nested_column.java new file mode 100644 index 0000000000..24433a36c7 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_baseline_nested_column.java @@ -0,0 +1,138 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_nested_column.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_baseline_nested_column { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_baseline_nested_column() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.BASELINE); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(60f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setWidth(50f); + root_child1_child0.setHeight(80f); + root_child1_child0.setDisplay(YogaDisplay.GRID); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child1_child0_child0 = createNode(config); + root_child1_child0_child0.setWidth(50f); + root_child1_child0_child0.setHeight(30f); + root_child1_child0_child0.setDisplay(YogaDisplay.GRID); + root_child1_child0.addChildAt(root_child1_child0_child0, 0); + + final YogaNode root_child1_child0_child1 = createNode(config); + root_child1_child0_child1.setWidth(50f); + root_child1_child0_child1.setHeight(40f); + root_child1_child0_child1.setDisplay(YogaDisplay.GRID); + root_child1_child0.addChildAt(root_child1_child0_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0_child1.getLayoutX(), 0.0f); + assertEquals(30f, root_child1_child0_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1_child0_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0_child1.getLayoutX(), 0.0f); + assertEquals(30f, root_child1_child0_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1_child0_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_sized_center.java b/java/tests/generated/com/facebook/yoga/grid_align_items_sized_center.java new file mode 100644 index 0000000000..d59b68084a --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_sized_center.java @@ -0,0 +1,126 @@ +/* + * 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 SignedSource<<396aacac4dda130f12afbe9bb1548587>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_center.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_sized_center { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_sized_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.CENTER); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(70f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child1.getLayoutX(), 0.0f); + assertEquals(70f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_sized_end.java b/java/tests/generated/com/facebook/yoga/grid_align_items_sized_end.java new file mode 100644 index 0000000000..d85f52d27c --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_sized_end.java @@ -0,0 +1,126 @@ +/* + * 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 SignedSource<<622e03295ddb98f3e1eb269d625fd719>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_end.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_sized_end { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_sized_end() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.END); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child1.getLayoutX(), 0.0f); + assertEquals(60f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_sized_start.java b/java/tests/generated/com/facebook/yoga/grid_align_items_sized_start.java new file mode 100644 index 0000000000..1bbcd94f1b --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_sized_start.java @@ -0,0 +1,126 @@ +/* + * 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 SignedSource<<5253261893be484cb9025d2e42cfe0e8>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_start.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_sized_start { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_sized_start() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignItems(YogaAlign.START); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_items_sized_stretch.java b/java/tests/generated/com/facebook/yoga/grid_align_items_sized_stretch.java new file mode 100644 index 0000000000..10a2e3e9c0 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_items_sized_stretch.java @@ -0,0 +1,125 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_stretch.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_items_sized_stretch { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_items_sized_stretch() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_align_self_sized_all.java b/java/tests/generated/com/facebook/yoga/grid_align_self_sized_all.java new file mode 100644 index 0000000000..e1a20b67f6 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_align_self_sized_all.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<5440a9db72c576c5fac18e6f1a91cf1b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_self_sized_all.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_align_self_sized_all { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_align_self_sized_all() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setAlignSelf(YogaAlign.START); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setAlignSelf(YogaAlign.START); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setAlignSelf(YogaAlign.END); + root_child2.setWidth(20f); + root_child2.setHeight(20f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setAlignSelf(YogaAlign.END); + root_child3.setWidth(60f); + root_child3.setHeight(60f); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setAlignSelf(YogaAlign.CENTER); + root_child4.setWidth(20f); + root_child4.setHeight(20f); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setAlignSelf(YogaAlign.CENTER); + root_child5.setWidth(60f); + root_child5.setHeight(60f); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setWidth(20f); + root_child6.setHeight(20f); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root_child7.setWidth(60f); + root_child7.setHeight(60f); + root.addChildAt(root_child7, 7); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(60f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child7.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child3.getLayoutX(), 0.0f); + assertEquals(20f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(60f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child7.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_absolute_width_overrides_inset.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_absolute_width_overrides_inset.java new file mode 100644 index 0000000000..a8be10872e --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_absolute_width_overrides_inset.java @@ -0,0 +1,78 @@ +/* + * 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 SignedSource<<4b650237c2151bf21a3abcef004e889e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_absolute_width_overrides_inset.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_absolute_width_overrides_inset { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_absolute_width_overrides_inset() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + root.setHeight(300f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0.setPositionPercent(YogaEdge.LEFT, 10f); + root_child0.setPositionPercent(YogaEdge.TOP, 5f); + root_child0.setPositionPercent(YogaEdge.RIGHT, 10f); + root_child0.setWidthPercent(40f); + root_child0.setAspectRatio(3 / 1f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(15f, root_child0.getLayoutY(), 0.0f); + assertEquals(160f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(53f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(15f, root_child0.getLayoutY(), 0.0f); + assertEquals(160f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(53f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_child_fill_content_height.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_child_fill_content_height.java new file mode 100644 index 0000000000..5c50db2fa6 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_child_fill_content_height.java @@ -0,0 +1,87 @@ +/* + * 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 SignedSource<<380b52c446aa5e6ba837bfc0f18b8f0f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_child_fill_content_height.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_child_fill_content_height { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_child_fill_content_height() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setAspectRatio(0.5 / 1f); + root.addChildAt(root_child0, 0); + root_child0.setData("HHHH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child1 = createNode(config); + root_child1.setHeight(20f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(40f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(40f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_child_fill_content_width.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_child_fill_content_width.java new file mode 100644 index 0000000000..dd278e9434 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_child_fill_content_width.java @@ -0,0 +1,87 @@ +/* + * 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 SignedSource<<7f264f75e0517e69d0795e6b7764e167>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_child_fill_content_width.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_child_fill_content_width { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_child_fill_content_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root_child0.setData("HHHH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child1 = createNode(config); + root_child1.setHeight(20f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(40f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(40f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_height.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_height.java new file mode 100644 index 0000000000..4ba15338cf --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_height.java @@ -0,0 +1,74 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_height.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_fill_child_height { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_fill_child_height() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_max_height.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_max_height.java new file mode 100644 index 0000000000..b003697db1 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_max_height.java @@ -0,0 +1,76 @@ +/* + * 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 SignedSource<<6d61cff05d69d4293515668801b9102e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_max_height.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_fill_child_max_height { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_fill_child_max_height() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setMaxWidth(40f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root_child0.setData("HH​HH​HH​HH​HH​HH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_max_width.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_max_width.java new file mode 100644 index 0000000000..acc402e785 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_max_width.java @@ -0,0 +1,76 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_max_width.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_fill_child_max_width { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_fill_child_max_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setMaxHeight(20f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root_child0.setData("HH HH HH HH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_min_height.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_min_height.java new file mode 100644 index 0000000000..efe1be09db --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_min_height.java @@ -0,0 +1,74 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_min_height.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_fill_child_min_height { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_fill_child_min_height() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setMinWidth(50f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(25f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_width.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_width.java new file mode 100644 index 0000000000..ba6175012c --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_fill_child_width.java @@ -0,0 +1,74 @@ +/* + * 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 SignedSource<<60c01b3452f64426e5c90344a30a3d0c>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_width.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_fill_child_width { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_fill_child_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setHeight(50f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_height_to_width.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_height_to_width.java new file mode 100644 index 0000000000..458500a85f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_height_to_width.java @@ -0,0 +1,111 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_height_to_width.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_height_to_width { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_height_to_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setHeight(150f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setHeight(150f); + root_child1.setAspectRatio(0.5 / 1f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(375f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(75f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(375f, root.getLayoutWidth(), 0.0f); + assertEquals(300f, root.getLayoutHeight(), 0.0f); + + assertEquals(75f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(300f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(75f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_min_max_constraints.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_min_max_constraints.java new file mode 100644 index 0000000000..e3e356effa --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_min_max_constraints.java @@ -0,0 +1,113 @@ +/* + * 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 SignedSource<<45e218b4ac043a598d8cf9f7cfe19d29>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_min_max_constraints.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_min_max_constraints { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_min_max_constraints() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(200f); + root_child0.setMaxHeight(80f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(200f); + root_child1.setMinHeight(150f); + root_child1.setAspectRatio(2 / 1f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(150f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(150f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_overridden_by_explicit_sizes.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_overridden_by_explicit_sizes.java new file mode 100644 index 0000000000..63fa627cca --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_overridden_by_explicit_sizes.java @@ -0,0 +1,75 @@ +/* + * 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 SignedSource<<7b65e3d7574807e5ee821808d5d1ac80>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_overridden_by_explicit_sizes.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_overridden_by_explicit_sizes { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_overridden_by_explicit_sizes() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_overridden_by_explicit_sizes_flex.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_overridden_by_explicit_sizes_flex.java new file mode 100644 index 0000000000..653ff13165 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_overridden_by_explicit_sizes_flex.java @@ -0,0 +1,75 @@ +/* + * 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 SignedSource<<81c8fd41e032f8f984ee03bb48535cd9>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_overridden_by_explicit_sizes_flex.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_overridden_by_explicit_sizes_flex { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_overridden_by_explicit_sizes_flex() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_percentage_auto_margin.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_percentage_auto_margin.java new file mode 100644 index 0000000000..6743fa68d8 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_percentage_auto_margin.java @@ -0,0 +1,133 @@ +/* + * 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 SignedSource<<79c3971516894196ceace4a46a2c1030>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_percentage_auto_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_percentage_auto_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_percentage_auto_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.LEFT); + root_child0.setMarginAuto(YogaEdge.RIGHT); + root_child0.setWidth(120f); + root_child0.setAspectRatio(16 / 9f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root_child1.setHeight(80f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setMarginAuto(YogaEdge.TOP); + root_child2.setMarginAuto(YogaEdge.BOTTOM); + root_child2.setAspectRatio(1 / 1f); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(210f, root.getLayoutHeight(), 0.0f); + + assertEquals(15f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(270f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(210f, root.getLayoutHeight(), 0.0f); + + assertEquals(365f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(240f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_reresolution_auto_rows.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_reresolution_auto_rows.java new file mode 100644 index 0000000000..ac9e52df71 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_reresolution_auto_rows.java @@ -0,0 +1,103 @@ +/* + * 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 SignedSource<<6dd77edaff88b89f6a4a587b2b1d97e7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_reresolution_auto_rows.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_reresolution_auto_rows { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_reresolution_auto_rows() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setAspectRatio(2 / 1f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(250f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(250f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_spanning_items.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_spanning_items.java new file mode 100644 index 0000000000..0a2e587372 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_spanning_items.java @@ -0,0 +1,120 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_spanning_items.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_spanning_items { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_spanning_items() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setAspectRatio(3 / 1f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(150f); + root_child1.setAspectRatio(1 / 1f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(470f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(450f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(320f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(470f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(450f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(150f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_spanning_with_content_distribution.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_spanning_with_content_distribution.java new file mode 100644 index 0000000000..98df0894c9 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_spanning_with_content_distribution.java @@ -0,0 +1,137 @@ +/* + * 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 SignedSource<<637b31d82c71538a3ae73edb972b6cdd>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_spanning_with_content_distribution.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_spanning_with_content_distribution { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_spanning_with_content_distribution() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setAlignContent(YogaAlign.SPACE_BETWEEN); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(50f); + root_child0.setHeight(50f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(50f); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setAspectRatio(2 / 1f); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(3); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(450f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(400f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(450f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(400f, root_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(400f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_triggers_reresolution.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_triggers_reresolution.java new file mode 100644 index 0000000000..0fe44ab8d3 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_triggers_reresolution.java @@ -0,0 +1,85 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_triggers_reresolution.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_triggers_reresolution { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_triggers_reresolution() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(500f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(500f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(300f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_width_to_height.java b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_width_to_height.java new file mode 100644 index 0000000000..73f860eb8d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_aspect_ratio_width_to_height.java @@ -0,0 +1,111 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_width_to_height.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_aspect_ratio_width_to_height { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_width_to_height() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(200f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(200f); + root_child1.setAspectRatio(1.77 / 1f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(113f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(113f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(113f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(113f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(113f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_auto_margin_overflow_block.java b/java/tests/generated/com/facebook/yoga/grid_auto_margin_overflow_block.java new file mode 100644 index 0000000000..162aa2b70b --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_auto_margin_overflow_block.java @@ -0,0 +1,83 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_margin_overflow_block.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_auto_margin_overflow_block { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_auto_margin_overflow_block() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.TOP); + root_child0.setMarginAuto(YogaEdge.BOTTOM); + root_child0.setWidth(50f); + root_child0.setHeight(200f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_auto_margin_overflow_inline.java b/java/tests/generated/com/facebook/yoga/grid_auto_margin_overflow_inline.java new file mode 100644 index 0000000000..03b98cb79f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_auto_margin_overflow_inline.java @@ -0,0 +1,82 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_margin_overflow_inline.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_auto_margin_overflow_inline { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_auto_margin_overflow_inline() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginAuto(YogaEdge.LEFT); + root_child0.setMarginAuto(YogaEdge.RIGHT); + root_child0.setWidth(200f); + root_child0.setHeight(50f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(-100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_auto_rows.java b/java/tests/generated/com/facebook/yoga/grid_auto_rows.java new file mode 100644 index 0000000000..7aae49f1bb --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_auto_rows.java @@ -0,0 +1,191 @@ +/* + * 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 SignedSource<<5c085c57ef052b41fd7b325e1202434a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_rows.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_auto_rows { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_auto_rows() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + YogaGridTrackList rootGridAutoRows = new YogaGridTrackList(); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + rootGridAutoRows.addTrack(YogaGridTrackValue.auto()); + root.setGridAutoRows(rootGridAutoRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setGridRowStart(-4); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(180f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(90f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(100f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(120f, root_child5.getLayoutY(), 0.0f); + assertEquals(100f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(150f, root_child6.getLayoutY(), 0.0f); + assertEquals(100f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child7.getLayoutX(), 0.0f); + assertEquals(160f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child7.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(180f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(90f, root_child3.getLayoutY(), 0.0f); + assertEquals(100f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(100f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(120f, root_child5.getLayoutY(), 0.0f); + assertEquals(100f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(150f, root_child6.getLayoutY(), 0.0f); + assertEquals(100f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child7.getLayoutX(), 0.0f); + assertEquals(160f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child7.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_auto_single_item.java b/java/tests/generated/com/facebook/yoga/grid_auto_single_item.java new file mode 100644 index 0000000000..ef93dc4938 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_auto_single_item.java @@ -0,0 +1,207 @@ +/* + * 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 SignedSource<<49ed075affdd4d926f2ada6a66ea528e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_single_item.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_auto_single_item { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_auto_single_item() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_auto_single_item_fixed_width.java b/java/tests/generated/com/facebook/yoga/grid_auto_single_item_fixed_width.java new file mode 100644 index 0000000000..758c48c195 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_auto_single_item_fixed_width.java @@ -0,0 +1,208 @@ +/* + * 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 SignedSource<<8557744eadd86b55db907ff05f27e5c9>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_single_item_fixed_width.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_auto_single_item_fixed_width { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_auto_single_item_fixed_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setMinWidth(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(0f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(0f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(0f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(0f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_auto_single_item_fixed_width_with_definite_width.java b/java/tests/generated/com/facebook/yoga/grid_auto_single_item_fixed_width_with_definite_width.java new file mode 100644 index 0000000000..1921568b66 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_auto_single_item_fixed_width_with_definite_width.java @@ -0,0 +1,208 @@ +/* + * 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 SignedSource<<35c0736d5a473547ffbf3e0870c52877>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_single_item_fixed_width_with_definite_width.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_auto_single_item_fixed_width_with_definite_width { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_auto_single_item_fixed_width_with_definite_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(100f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(0f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(0f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(0f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(0f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_auto_takes_precedence_over_fr.java b/java/tests/generated/com/facebook/yoga/grid_auto_takes_precedence_over_fr.java new file mode 100644 index 0000000000..720d2ff555 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_auto_takes_precedence_over_fr.java @@ -0,0 +1,101 @@ +/* + * 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 SignedSource<<0bdffacf376fc1cd716e8306fa498d12>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_takes_precedence_over_fr.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_auto_takes_precedence_over_fr { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_auto_takes_precedence_over_fr() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(200f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_available_space_greater_than_max_content.java b/java/tests/generated/com/facebook/yoga/grid_available_space_greater_than_max_content.java new file mode 100644 index 0000000000..b209a8a5e7 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_available_space_greater_than_max_content.java @@ -0,0 +1,112 @@ +/* + * 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 SignedSource<<6c75c502c984d5d281c0819734bb1fdf>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_available_space_greater_than_max_content.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_available_space_greater_than_max_content { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_available_space_greater_than_max_content() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(400f); + + final YogaNode root_child0 = createNode(config); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + root_child0_child0.setData("HH HH HH HH"); + root_child0_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + root_child0_child1.setData("HH HH HH HH"); + root_child0_child1.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(10f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(400f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(110f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(110f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(110f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(400f, root.getLayoutWidth(), 0.0f); + assertEquals(10f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(400f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(290f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(110f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(110f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_basic.java b/java/tests/generated/com/facebook/yoga/grid_basic.java new file mode 100644 index 0000000000..a1a2bcffd8 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_basic.java @@ -0,0 +1,208 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_basic { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_basic() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_basic_implicit_tracks.java b/java/tests/generated/com/facebook/yoga/grid_basic_implicit_tracks.java new file mode 100644 index 0000000000..c975bbd4cc --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_basic_implicit_tracks.java @@ -0,0 +1,97 @@ +/* + * 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 SignedSource<<4a9c1fd2a74a834c09da22105ef5b144>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic_implicit_tracks.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_basic_implicit_tracks { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_basic_implicit_tracks() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(35f); + root_child1.setHeight(35f); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(40f, root.getLayoutWidth(), 0.0f); + assertEquals(75f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(35f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(35f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(40f, root.getLayoutWidth(), 0.0f); + assertEquals(75f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(35f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(35f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_basic_with_overflow.java b/java/tests/generated/com/facebook/yoga/grid_basic_with_overflow.java new file mode 100644 index 0000000000..e5d31e0374 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_basic_with_overflow.java @@ -0,0 +1,221 @@ +/* + * 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 SignedSource<<54c2b5ff57b504c850f2ab0f53f2df85>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic_with_overflow.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_basic_with_overflow { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_basic_with_overflow() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + + final YogaNode root_child9 = createNode(config); + root.addChildAt(root_child9, 9); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child9.getLayoutX(), 0.0f); + assertEquals(120f, root_child9.getLayoutY(), 0.0f); + assertEquals(40f, root_child9.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child9.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child9.getLayoutX(), 0.0f); + assertEquals(120f, root_child9.getLayoutY(), 0.0f); + assertEquals(40f, root_child9.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child9.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_basic_with_padding.java b/java/tests/generated/com/facebook/yoga/grid_basic_with_padding.java new file mode 100644 index 0000000000..67180a2a91 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_basic_with_padding.java @@ -0,0 +1,210 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic_with_padding.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_basic_with_padding { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_basic_with_padding() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(90f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(90f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_complex_mixed_spanning_alignment.java b/java/tests/generated/com/facebook/yoga/grid_complex_mixed_spanning_alignment.java new file mode 100644 index 0000000000..221c5067de --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_complex_mixed_spanning_alignment.java @@ -0,0 +1,149 @@ +/* + * 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 SignedSource<<97a28795d56fc91f96656fc3c0cd7926>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_complex_mixed_spanning_alignment.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_complex_mixed_spanning_alignment { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_complex_mixed_spanning_alignment() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_BETWEEN); + root.setAlignContent(YogaAlign.CENTER); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(600f); + root.setHeight(400f); + root.setGap(YogaGutter.COLUMN, 10f); + root.setGap(YogaGutter.ROW, 10f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.END); + root_child0.setWidth(250f); + root_child0.setHeightPercent(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setAlignSelf(YogaAlign.CENTER); + root_child1.setWidthPercent(100f); + root_child1.setHeight(80f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidthPercent(100f); + root_child2.setHeight(200f); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(4); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(260f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(110f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(90f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(600f, root.getLayoutWidth(), 0.0f); + assertEquals(400f, root.getLayoutHeight(), 0.0f); + + assertEquals(350f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(250f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(230f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(110f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(500f, root_child2.getLayoutX(), 0.0f); + assertEquals(90f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(200f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_display_none_fixed_size.java b/java/tests/generated/com/facebook/yoga/grid_display_none_fixed_size.java new file mode 100644 index 0000000000..4c89305767 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_display_none_fixed_size.java @@ -0,0 +1,89 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_display_none_fixed_size.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_display_none_fixed_size { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_display_none_fixed_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexGrow(1f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(20f); + root_child1.setHeight(20f); + root_child1.setDisplay(YogaDisplay.NONE); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_distribute_space_flex_auto.java b/java/tests/generated/com/facebook/yoga/grid_distribute_space_flex_auto.java new file mode 100644 index 0000000000..f0be6017f0 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_distribute_space_flex_auto.java @@ -0,0 +1,134 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_distribute_space_flex_auto.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_distribute_space_flex_auto { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_distribute_space_flex_auto() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(300f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(200f); + root_child0.setHeight(50f); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(50f); + root_child1.setHeight(30f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setHeight(30f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setWidth(50f); + root_child3.setHeight(30f); + root.addChildAt(root_child3, 3); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(300f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(200f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(250f, root_child1.getLayoutX(), 0.0f); + assertEquals(50f, root_child1.getLayoutY(), 0.0f); + assertEquals(50f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(200f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(50f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_expand_flexible_indefinite_free_space.java b/java/tests/generated/com/facebook/yoga/grid_expand_flexible_indefinite_free_space.java new file mode 100644 index 0000000000..da16be2523 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_expand_flexible_indefinite_free_space.java @@ -0,0 +1,138 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_expand_flexible_indefinite_free_space.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_expand_flexible_indefinite_free_space { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_expand_flexible_indefinite_free_space_container() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidthMaxContent(); + + final YogaNode root_child0 = createNode(config); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setWidth(100f); + root_child0_child0.setHeight(80f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setWidth(150f); + root_child0_child1.setHeight(120f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setWidth(120f); + root_child0_child2.setHeight(100f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(480f, root.getLayoutWidth(), 0.0f); + assertEquals(360f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(480f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(360f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(360f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(480f, root.getLayoutWidth(), 0.0f); + assertEquals(360f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(480f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(360f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(380f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(210f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(150f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_fixed_size_no_content_proportions.java b/java/tests/generated/com/facebook/yoga/grid_fr_fixed_size_no_content_proportions.java new file mode 100644 index 0000000000..bf0f9bff7d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_fixed_size_no_content_proportions.java @@ -0,0 +1,116 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_fixed_size_no_content_proportions.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_fixed_size_no_content_proportions { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_fixed_size_no_content_proportions() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(33f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(33f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(67f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(167f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(33f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(67f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_fixed_size_no_content_proportions_sub_1_sum.java b/java/tests/generated/com/facebook/yoga/grid_fr_fixed_size_no_content_proportions_sub_1_sum.java new file mode 100644 index 0000000000..b4b051c197 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_fixed_size_no_content_proportions_sub_1_sum.java @@ -0,0 +1,103 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_fixed_size_no_content_proportions_sub_1_sum.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_fixed_size_no_content_proportions_sub_1_sum { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_fixed_size_no_content_proportions_sub_1_sum() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_fixed_size_single_item.java b/java/tests/generated/com/facebook/yoga/grid_fr_fixed_size_single_item.java new file mode 100644 index 0000000000..f5a6c00aa8 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_fixed_size_single_item.java @@ -0,0 +1,205 @@ +/* + * 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 SignedSource<<23483b7fce211ae1af2f6329f4ae1cc5>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_fixed_size_single_item.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_fixed_size_single_item { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_fixed_size_single_item() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setWidth(100f); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(60f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(120f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(120f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child8.getLayoutX(), 0.0f); + assertEquals(120f, root_child8.getLayoutY(), 0.0f); + assertEquals(60f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(60f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(120f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child7.getLayoutX(), 0.0f); + assertEquals(120f, root_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(120f, root_child8.getLayoutY(), 0.0f); + assertEquals(60f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_no_sized_items_indefinite.java b/java/tests/generated/com/facebook/yoga/grid_fr_no_sized_items_indefinite.java new file mode 100644 index 0000000000..04276a2889 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_no_sized_items_indefinite.java @@ -0,0 +1,202 @@ +/* + * 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 SignedSource<<4889319755f484b86fc30199389f4d46>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_no_sized_items_indefinite.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_no_sized_items_indefinite { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_no_sized_items_indefinite() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(40f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(0f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(40f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(40f, root_child7.getLayoutY(), 0.0f); + assertEquals(0f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child8.getLayoutX(), 0.0f); + assertEquals(40f, root_child8.getLayoutY(), 0.0f); + assertEquals(0f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(40f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(0f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(40f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child7.getLayoutX(), 0.0f); + assertEquals(40f, root_child7.getLayoutY(), 0.0f); + assertEquals(0f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(40f, root_child8.getLayoutY(), 0.0f); + assertEquals(0f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_single_item_indefinite.java b/java/tests/generated/com/facebook/yoga/grid_fr_single_item_indefinite.java new file mode 100644 index 0000000000..6cced6f9f5 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_single_item_indefinite.java @@ -0,0 +1,219 @@ +/* + * 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 SignedSource<<46aa965cd8aef782b941cb8f2809c609>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_single_item_indefinite.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_single_item_indefinite { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_single_item_indefinite() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidthMaxContent(); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthAuto(); + root_child0.setHeightAuto(); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setWidth(100f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(240f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(240f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(100f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion.java b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion.java new file mode 100644 index 0000000000..c95e5c5334 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion.java @@ -0,0 +1,118 @@ +/* + * 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 SignedSource<<55ecc8a34316a8d075571c88a1a519b5>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_span_2_proportion { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_span_2_proportion() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(60f); + root_child0.setGridColumnStartSpan(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_sub_1_sum.java b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_sub_1_sum.java new file mode 100644 index 0000000000..0d667a18a1 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_sub_1_sum.java @@ -0,0 +1,122 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_sub_1_sum.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_span_2_proportion_sub_1_sum { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_span_2_proportion_sub_1_sum() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(60f); + root_child0.setGridColumnStartSpan(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(24f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(24f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(36f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(36f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(24f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(36f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_with_non_spanned_track.java b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_with_non_spanned_track.java new file mode 100644 index 0000000000..6cef743dbc --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_with_non_spanned_track.java @@ -0,0 +1,162 @@ +/* + * 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 SignedSource<<50768b5f7f6432455ed7cebc5fd898e1>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_with_non_spanned_track.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_span_2_proportion_with_non_spanned_track { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_span_2_proportion_with_non_spanned_track() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidthMaxContent(); + + final YogaNode root_child0 = createNode(config); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setWidth(60f); + root_child0_child0.setGridColumnStartSpan(2); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(60f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(60f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_zero_sum.java b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_zero_sum.java new file mode 100644 index 0000000000..e749cb39d2 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_zero_sum.java @@ -0,0 +1,118 @@ +/* + * 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 SignedSource<<3b53d8ae037daf8a65e029800eccdf5d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_zero_sum.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_span_2_proportion_zero_sum { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_span_2_proportion_zero_sum() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(60f); + root_child0.setGridColumnStartSpan(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.java b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.java new file mode 100644 index 0000000000..3a3f85d433 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.java @@ -0,0 +1,148 @@ +/* + * 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 SignedSource<<976607ad3e9440cdd1df766951931dd9>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_fr_span_2_proportion_zero_sum_with_non_spanned_track { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_span_2_proportion_zero_sum_with_non_spanned_track() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(60f); + root_child0.setGridColumnStartSpan(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_gap.java b/java/tests/generated/com/facebook/yoga/grid_gap.java new file mode 100644 index 0000000000..15caab62fd --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_gap.java @@ -0,0 +1,210 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setGap(YogaGutter.COLUMN, 40f); + root.setGap(YogaGutter.ROW, 40f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(160f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(160f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child8.getLayoutX(), 0.0f); + assertEquals(160f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(80f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(80f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(80f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(160f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(160f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(160f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_hidden.java b/java/tests/generated/com/facebook/yoga/grid_hidden.java new file mode 100644 index 0000000000..6f9047cb8c --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_hidden.java @@ -0,0 +1,211 @@ +/* + * 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 SignedSource<<17d2cad8a3c074b013b840e786eb8e99>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_hidden.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_hidden { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_hidden() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setDisplay(YogaDisplay.NONE); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setDisplay(YogaDisplay.NONE); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setDisplay(YogaDisplay.NONE); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(0f, root_child6.getLayoutY(), 0.0f); + assertEquals(0f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(40f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(40f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(0f, root_child6.getLayoutY(), 0.0f); + assertEquals(0f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(40f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(40f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_center.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_center.java new file mode 100644 index 0000000000..f0f63d4939 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_center.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<<72cd1761c28d83428f639f40f6a67703>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_center.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_center { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.CENTER); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_center_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_center_negative_space_gap.java new file mode 100644 index 0000000000..71bd658e24 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_center_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<<94d3f52119c3ba2d483e7989a3d892f8>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_center_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_center_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_center_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.CENTER); + root_child0.setAlignContent(YogaAlign.CENTER); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_center_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_center_with_padding_border.java new file mode 100644 index 0000000000..b23363a9c5 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_center_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<80bbe7c6f1d7cf37319ce2fbfecda1df>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_center_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_center_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_center_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.CENTER); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(52f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(132f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(52f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(132f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(52f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(132f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(132f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(52f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(132f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(52f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(132f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(52f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_end.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_end.java new file mode 100644 index 0000000000..0d0a7112f5 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_end.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<<592a93a6d2b78267528c05e9b28eaf12>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_end.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_end { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_end() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.END); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_end_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_end_negative_space_gap.java new file mode 100644 index 0000000000..66a18501ad --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_end_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<<3cbf7980c1ef0220aba6ae2d9aece46e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_end_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_end_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_end_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.END); + root_child0.setAlignContent(YogaAlign.CENTER); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_end_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_end_with_padding_border.java new file mode 100644 index 0000000000..5290bdca02 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_end_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<3585644a65b6069860209f9e8ba824bc>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_end_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_end_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_end_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.END); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_space_around.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_around.java new file mode 100644 index 0000000000..d2dc3ca198 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_around.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<<86b8edb900aafc90b35616cf55a3107b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_around.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_space_around { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_space_around() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_AROUND); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(13f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(147f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(13f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(147f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(13f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(147f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(147f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(13f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(147f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(13f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(147f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(13f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_space_around_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_around_negative_space_gap.java new file mode 100644 index 0000000000..93b028c88d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_around_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<<174ab98290c01ef9af4411cd32cafb28>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_around_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_space_around_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_space_around_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.SPACE_AROUND); + root_child0.setAlignContent(YogaAlign.CENTER); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_space_around_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_around_with_padding_border.java new file mode 100644 index 0000000000..8afb66ceac --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_around_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<6d1d32a1ce3a9fc1bec5ce8d5530b454>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_around_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_space_around_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_space_around_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_AROUND); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(49f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(135f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(49f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(135f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(49f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(135f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(135f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(49f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(135f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(49f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(135f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(49f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_space_between.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_between.java new file mode 100644 index 0000000000..842fda2fe3 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_between.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<<157bb887b6948187810648f27a559e15>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_between.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_space_between { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_space_between() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_BETWEEN); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_space_between_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_between_negative_space_gap.java new file mode 100644 index 0000000000..14a5c2616f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_between_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<<7689c052f6619a4f08863c72f1c8733c>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_between_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_space_between_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_space_between_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.SPACE_BETWEEN); + root_child0.setAlignContent(YogaAlign.CENTER); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_space_between_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_between_with_padding_border.java new file mode 100644 index 0000000000..427420cf74 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_between_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<4f28f82ee62e351c55cca7e034e2c7d1>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_between_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_space_between_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_space_between_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_BETWEEN); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_space_evenly.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_evenly.java new file mode 100644 index 0000000000..b5438718e5 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_evenly.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_evenly.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_space_evenly { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_space_evenly() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_EVENLY); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_space_evenly_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_evenly_negative_space_gap.java new file mode 100644 index 0000000000..3838ac67f6 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_evenly_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<<58736ad41055a41f36cfa569faba0d9e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_evenly_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_space_evenly_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_space_evenly_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.SPACE_EVENLY); + root_child0.setAlignContent(YogaAlign.CENTER); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_space_evenly_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_evenly_with_padding_border.java new file mode 100644 index 0000000000..215ff395c5 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_space_evenly_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_evenly_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_space_evenly_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_space_evenly_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.SPACE_EVENLY); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(134f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(134f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(134f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(134f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(134f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(134f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(92f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_start.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_start.java new file mode 100644 index 0000000000..5b9cb3155f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_start.java @@ -0,0 +1,209 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_start.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_start { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_start() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.START); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(160f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_start_negative_space_gap.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_start_negative_space_gap.java new file mode 100644 index 0000000000..ce582e06cd --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_start_negative_space_gap.java @@ -0,0 +1,232 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_start_negative_space_gap.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_start_negative_space_gap { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_start_negative_space_gap() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setBorder(YogaEdge.LEFT, 60f); + root.setBorder(YogaEdge.TOP, 60f); + root.setBorder(YogaEdge.RIGHT, 60f); + root.setBorder(YogaEdge.BOTTOM, 60f); + root.setWidth(240f); + root.setHeight(240f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifyContent(YogaJustify.START); + root_child0.setAlignContent(YogaAlign.CENTER); + root_child0.setWidth(120f); + root_child0.setHeight(120f); + root_child0.setGap(YogaGutter.COLUMN, 10f); + root_child0.setGap(YogaGutter.ROW, 10f); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(240f, root.getLayoutWidth(), 0.0f); + assertEquals(240f, root.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0.getLayoutX(), 0.0f); + assertEquals(60f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_content_start_with_padding_border.java b/java/tests/generated/com/facebook/yoga/grid_justify_content_start_with_padding_border.java new file mode 100644 index 0000000000..6ca582caa1 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_content_start_with_padding_border.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_start_with_padding_border.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_content_start_with_padding_border { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_content_start_with_padding_border() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.START); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setBorder(YogaEdge.LEFT, 8f); + root.setBorder(YogaEdge.TOP, 2f); + root.setBorder(YogaEdge.RIGHT, 4f); + root.setBorder(YogaEdge.BOTTOM, 6f); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(88f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(128f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child0.getLayoutX(), 0.0f); + assertEquals(12f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child1.getLayoutX(), 0.0f); + assertEquals(12f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child2.getLayoutX(), 0.0f); + assertEquals(12f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child3.getLayoutX(), 0.0f); + assertEquals(52f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child4.getLayoutX(), 0.0f); + assertEquals(52f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child5.getLayoutX(), 0.0f); + assertEquals(52f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(136f, root_child6.getLayoutX(), 0.0f); + assertEquals(92f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child7.getLayoutX(), 0.0f); + assertEquals(92f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(56f, root_child8.getLayoutX(), 0.0f); + assertEquals(92f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_center.java b/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_center.java new file mode 100644 index 0000000000..4c022f9874 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_center.java @@ -0,0 +1,126 @@ +/* + * 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 SignedSource<<867b33b0a2f922e2854da90c6d4cac51>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_center.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_items_sized_center { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_items_sized_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyItems(YogaJustify.CENTER); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_end.java b/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_end.java new file mode 100644 index 0000000000..99908e470f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_end.java @@ -0,0 +1,126 @@ +/* + * 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 SignedSource<<8d2ecb43c12e5d5a3ea30ff4e7601797>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_end.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_items_sized_end { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_items_sized_end() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyItems(YogaJustify.END); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_start.java b/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_start.java new file mode 100644 index 0000000000..332133aefd --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_start.java @@ -0,0 +1,126 @@ +/* + * 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 SignedSource<<7421337383b30eb56910bf2bb3242d27>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_start.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_items_sized_start { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_items_sized_start() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyItems(YogaJustify.START); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_stretch.java b/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_stretch.java new file mode 100644 index 0000000000..a9aaac0c41 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_items_sized_stretch.java @@ -0,0 +1,126 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_stretch.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_items_sized_stretch { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_items_sized_stretch() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyItems(YogaJustify.STRETCH); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child1.getLayoutX(), 0.0f); + assertEquals(80f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_justify_self_sized_all.java b/java/tests/generated/com/facebook/yoga/grid_justify_self_sized_all.java new file mode 100644 index 0000000000..9e01fcd5c9 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_justify_self_sized_all.java @@ -0,0 +1,219 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_self_sized_all.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_justify_self_sized_all { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_justify_self_sized_all() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.START); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setJustifySelf(YogaJustify.START); + root_child1.setWidth(60f); + root_child1.setHeight(60f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setJustifySelf(YogaJustify.END); + root_child2.setWidth(20f); + root_child2.setHeight(20f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setJustifySelf(YogaJustify.END); + root_child3.setWidth(60f); + root_child3.setHeight(60f); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setJustifySelf(YogaJustify.CENTER); + root_child4.setWidth(20f); + root_child4.setHeight(20f); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root_child5.setJustifySelf(YogaJustify.CENTER); + root_child5.setWidth(60f); + root_child5.setHeight(60f); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setJustifySelf(YogaJustify.STRETCH); + root_child6.setWidth(20f); + root_child6.setHeight(20f); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root_child7.setJustifySelf(YogaJustify.STRETCH); + root_child7.setWidth(60f); + root_child7.setHeight(60f); + root.addChildAt(root_child7, 7); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(60f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child7.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(60f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(60f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(60f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(60f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child7.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_auto_margins.java b/java/tests/generated/com/facebook/yoga/grid_margins_auto_margins.java new file mode 100644 index 0000000000..6d2bed15db --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_auto_margins.java @@ -0,0 +1,226 @@ +/* + * 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 SignedSource<<2b37ca645ccbd326d93539da1f51e5bb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_auto_margins.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_auto_margins { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_auto_margins() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setJustifySelf(YogaJustify.START); + root_child2.setMarginAuto(YogaEdge.LEFT); + root_child2.setMarginAuto(YogaEdge.RIGHT); + root_child2.setWidth(20f); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setAlignSelf(YogaAlign.START); + root_child4.setMarginAuto(YogaEdge.TOP); + root_child4.setMarginAuto(YogaEdge.BOTTOM); + root_child4.setHeight(20f); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setJustifySelf(YogaJustify.START); + root_child6.setAlignSelf(YogaAlign.START); + root_child6.setMarginAuto(YogaEdge.LEFT); + root_child6.setMarginAuto(YogaEdge.TOP); + root_child6.setMarginAuto(YogaEdge.RIGHT); + root_child6.setMarginAuto(YogaEdge.BOTTOM); + root_child6.setWidth(20f); + root_child6.setHeight(20f); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(60f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(60f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(130f, root_child6.getLayoutX(), 0.0f); + assertEquals(100f, root_child6.getLayoutY(), 0.0f); + assertEquals(20f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_auto_margins_override_stretch.java b/java/tests/generated/com/facebook/yoga/grid_margins_auto_margins_override_stretch.java new file mode 100644 index 0000000000..9de1e724f9 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_auto_margins_override_stretch.java @@ -0,0 +1,217 @@ +/* + * 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 SignedSource<<3a43713ca4043e875a0808b3e7e0b84f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_auto_margins_override_stretch.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_auto_margins_override_stretch { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_auto_margins_override_stretch() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root_child6.setJustifySelf(YogaJustify.STRETCH); + root_child6.setMarginAuto(YogaEdge.LEFT); + root_child6.setMarginAuto(YogaEdge.TOP); + root_child6.setMarginAuto(YogaEdge.RIGHT); + root_child6.setMarginAuto(YogaEdge.BOTTOM); + root.addChildAt(root_child6, 6); + root_child6.setData("HH​HH"); + root_child6.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(105f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child6.getLayoutX(), 0.0f); + assertEquals(105f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child7.getLayoutX(), 0.0f); + assertEquals(90f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child8.getLayoutX(), 0.0f); + assertEquals(90f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_fixed_center.java b/java/tests/generated/com/facebook/yoga/grid_margins_fixed_center.java new file mode 100644 index 0000000000..a2801b76c5 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_fixed_center.java @@ -0,0 +1,179 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_center.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_fixed_center { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_fixed_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.CENTER); + root_child0.setAlignSelf(YogaAlign.CENTER); + root_child0.setMargin(YogaEdge.LEFT, 8f); + root_child0.setMargin(YogaEdge.TOP, 2f); + root_child0.setMargin(YogaEdge.RIGHT, 4f); + root_child0.setMargin(YogaEdge.BOTTOM, 6f); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(52f, root_child0.getLayoutX(), 0.0f); + assertEquals(18f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(132f, root_child0.getLayoutX(), 0.0f); + assertEquals(18f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_fixed_end.java b/java/tests/generated/com/facebook/yoga/grid_margins_fixed_end.java new file mode 100644 index 0000000000..9be67b9b0e --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_fixed_end.java @@ -0,0 +1,179 @@ +/* + * 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 SignedSource<<2fdfe80d08910bbf30d82d8a0d2a0f23>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_end.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_fixed_end { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_fixed_end() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.END); + root_child0.setAlignSelf(YogaAlign.END); + root_child0.setMargin(YogaEdge.LEFT, 4f); + root_child0.setMargin(YogaEdge.TOP, 1f); + root_child0.setMargin(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.BOTTOM, 3f); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(58f, root_child0.getLayoutX(), 0.0f); + assertEquals(27f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(124f, root_child0.getLayoutX(), 0.0f); + assertEquals(27f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_fixed_start.java b/java/tests/generated/com/facebook/yoga/grid_margins_fixed_start.java new file mode 100644 index 0000000000..67007b3188 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_fixed_start.java @@ -0,0 +1,179 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_start.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_fixed_start { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_fixed_start() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.START); + root_child0.setAlignSelf(YogaAlign.START); + root_child0.setMargin(YogaEdge.LEFT, 4f); + root_child0.setMargin(YogaEdge.TOP, 1f); + root_child0.setMargin(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.BOTTOM, 3f); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(44f, root_child0.getLayoutX(), 0.0f); + assertEquals(11f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(138f, root_child0.getLayoutX(), 0.0f); + assertEquals(11f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_fixed_stretch.java b/java/tests/generated/com/facebook/yoga/grid_margins_fixed_stretch.java new file mode 100644 index 0000000000..7a97f92f24 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_fixed_stretch.java @@ -0,0 +1,178 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_stretch.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_fixed_stretch { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_fixed_stretch() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 40); + root.setPadding(YogaEdge.TOP, 10); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 30); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.STRETCH); + root_child0.setMargin(YogaEdge.LEFT, 4f); + root_child0.setMargin(YogaEdge.TOP, 1f); + root_child0.setMargin(YogaEdge.RIGHT, 2f); + root_child0.setMargin(YogaEdge.BOTTOM, 3f); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(44f, root_child0.getLayoutX(), 0.0f); + assertEquals(11f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(180f, root.getLayoutWidth(), 0.0f); + assertEquals(160f, root.getLayoutHeight(), 0.0f); + + assertEquals(138f, root_child0.getLayoutX(), 0.0f); + assertEquals(11f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child1.getLayoutX(), 0.0f); + assertEquals(10f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(10f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_percent_center.java b/java/tests/generated/com/facebook/yoga/grid_margins_percent_center.java new file mode 100644 index 0000000000..eedccc61ac --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_percent_center.java @@ -0,0 +1,175 @@ +/* + * 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 SignedSource<<09a923e8026e6de1d5102a9767dd616a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_center.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_percent_center { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_percent_center() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.CENTER); + root_child0.setAlignSelf(YogaAlign.CENTER); + root_child0.setMarginPercent(YogaEdge.LEFT, 20f); + root_child0.setMarginPercent(YogaEdge.TOP, 5f); + root_child0.setMarginPercent(YogaEdge.RIGHT, 10f); + root_child0.setMarginPercent(YogaEdge.BOTTOM, 15f); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(1f, root_child0.getLayoutX(), 0.0f); + assertEquals(9f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(41f, root_child0.getLayoutX(), 0.0f); + assertEquals(9f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_percent_end.java b/java/tests/generated/com/facebook/yoga/grid_margins_percent_end.java new file mode 100644 index 0000000000..9cbacd02d5 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_percent_end.java @@ -0,0 +1,175 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_end.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_percent_end { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_percent_end() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.END); + root_child0.setAlignSelf(YogaAlign.END); + root_child0.setMarginPercent(YogaEdge.LEFT, 20f); + root_child0.setMarginPercent(YogaEdge.TOP, 5f); + root_child0.setMarginPercent(YogaEdge.RIGHT, 10f); + root_child0.setMarginPercent(YogaEdge.BOTTOM, 15f); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(-2f, root_child0.getLayoutX(), 0.0f); + assertEquals(17f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(44f, root_child0.getLayoutX(), 0.0f); + assertEquals(17f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_percent_start.java b/java/tests/generated/com/facebook/yoga/grid_margins_percent_start.java new file mode 100644 index 0000000000..5472e30897 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_percent_start.java @@ -0,0 +1,175 @@ +/* + * 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 SignedSource<<03767bcfc5ac39e650ca3ec5b4c914ab>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_start.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_percent_start { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_percent_start() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.START); + root_child0.setAlignSelf(YogaAlign.START); + root_child0.setMarginPercent(YogaEdge.LEFT, 20f); + root_child0.setMarginPercent(YogaEdge.TOP, 5f); + root_child0.setMarginPercent(YogaEdge.RIGHT, 10f); + root_child0.setMarginPercent(YogaEdge.BOTTOM, 15f); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(4f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(38f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_margins_percent_stretch.java b/java/tests/generated/com/facebook/yoga/grid_margins_percent_stretch.java new file mode 100644 index 0000000000..6873a62af7 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_margins_percent_stretch.java @@ -0,0 +1,174 @@ +/* + * 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 SignedSource<<0541a62cbdd8542c86702f32638f03c2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_stretch.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_margins_percent_stretch { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_margins_percent_stretch() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.STRETCH); + root_child0.setMarginPercent(YogaEdge.LEFT, 20f); + root_child0.setMarginPercent(YogaEdge.TOP, 5f); + root_child0.setMarginPercent(YogaEdge.RIGHT, 10f); + root_child0.setMarginPercent(YogaEdge.BOTTOM, 15f); + root_child0.setWidth(20f); + root_child0.setHeight(20f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(4f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(38f, root_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_minmax_auto_fixed_10px.java b/java/tests/generated/com/facebook/yoga/grid_minmax_auto_fixed_10px.java new file mode 100644 index 0000000000..2ce49f201f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_minmax_auto_fixed_10px.java @@ -0,0 +1,98 @@ +/* + * 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 SignedSource<<4cf9fc61f6adef71ffb7b34827145813>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_auto_fixed_10px.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_minmax_auto_fixed_10px { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_minmax_auto_fixed_10px() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + root_child0.setData("HH​HH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(10f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(10f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_minmax_auto_percent_definite.java b/java/tests/generated/com/facebook/yoga/grid_minmax_auto_percent_definite.java new file mode 100644 index 0000000000..3c7efb5b50 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_minmax_auto_percent_definite.java @@ -0,0 +1,98 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_auto_percent_definite.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_minmax_auto_percent_definite { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_minmax_auto_percent_definite() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + root_child0.setData("HH​HH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(20f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_minmax_auto_percent_indefinite.java b/java/tests/generated/com/facebook/yoga/grid_minmax_auto_percent_indefinite.java new file mode 100644 index 0000000000..c6be825413 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_minmax_auto_percent_indefinite.java @@ -0,0 +1,111 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_auto_percent_indefinite.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_minmax_auto_percent_indefinite { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_minmax_auto_percent_indefinite() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidthMaxContent(); + + final YogaNode root_child0 = createNode(config); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + root_child0_child0.setData("HH HH"); + root_child0_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_minmax_column_fixed_width_above_range.java b/java/tests/generated/com/facebook/yoga/grid_minmax_column_fixed_width_above_range.java new file mode 100644 index 0000000000..3d64b6b658 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_minmax_column_fixed_width_above_range.java @@ -0,0 +1,221 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_fixed_width_above_range.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_minmax_column_fixed_width_above_range { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_minmax_column_fixed_width_above_range() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(140f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(140f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(140f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_minmax_column_fixed_width_below_range.java b/java/tests/generated/com/facebook/yoga/grid_minmax_column_fixed_width_below_range.java new file mode 100644 index 0000000000..d3cb934b82 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_minmax_column_fixed_width_below_range.java @@ -0,0 +1,221 @@ +/* + * 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 SignedSource<<6e1de9f0c6b62b35a4546b6595aad94b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_fixed_width_below_range.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_minmax_column_fixed_width_below_range { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_minmax_column_fixed_width_below_range() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(90f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(90f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(90f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(20f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(20f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(-10f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_minmax_column_fixed_width_within_range.java b/java/tests/generated/com/facebook/yoga/grid_minmax_column_fixed_width_within_range.java new file mode 100644 index 0000000000..34e7acbe4d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_minmax_column_fixed_width_within_range.java @@ -0,0 +1,221 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_fixed_width_within_range.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_minmax_column_fixed_width_within_range { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_minmax_column_fixed_width_within_range() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(110f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + + final YogaNode root_child7 = createNode(config); + root.addChildAt(root_child7, 7); + + final YogaNode root_child8 = createNode(config); + root.addChildAt(root_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(110f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(30f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(110f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child7.getLayoutY(), 0.0f); + assertEquals(30f, root_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_minmax_column_indefinite.java b/java/tests/generated/com/facebook/yoga/grid_minmax_column_indefinite.java new file mode 100644 index 0000000000..986f159197 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_minmax_column_indefinite.java @@ -0,0 +1,234 @@ +/* + * 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 SignedSource<<08374d26313e3ff8a54ae478c1cd9ffc>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_indefinite.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_minmax_column_indefinite { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_minmax_column_indefinite() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidthMaxContent(); + + final YogaNode root_child0 = createNode(config); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + + final YogaNode root_child0_child5 = createNode(config); + root_child0.addChildAt(root_child0_child5, 5); + + final YogaNode root_child0_child6 = createNode(config); + root_child0.addChildAt(root_child0_child6, 6); + + final YogaNode root_child0_child7 = createNode(config); + root_child0.addChildAt(root_child0_child7, 7); + + final YogaNode root_child0_child8 = createNode(config); + root_child0.addChildAt(root_child0_child8, 8); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(120f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(120f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child5.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child6.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child6.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child0_child7.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child7.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child7.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child8.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child8.getLayoutY(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child8.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_minmax_column_with_auto_fixed.java b/java/tests/generated/com/facebook/yoga/grid_minmax_column_with_auto_fixed.java new file mode 100644 index 0000000000..78db29b669 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_minmax_column_with_auto_fixed.java @@ -0,0 +1,115 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_with_auto_fixed.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_minmax_column_with_auto_fixed { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_minmax_column_with_auto_fixed() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(60f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_minmax_column_with_fr_fixed.java b/java/tests/generated/com/facebook/yoga/grid_minmax_column_with_fr_fixed.java new file mode 100644 index 0000000000..629361ab29 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_minmax_column_with_fr_fixed.java @@ -0,0 +1,114 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_with_fr_fixed.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_minmax_column_with_fr_fixed { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_minmax_column_with_fr_fixed() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(60f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(60f, root.getLayoutWidth(), 0.0f); + assertEquals(40f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(20f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_overflow_inline_axis_hidden.java b/java/tests/generated/com/facebook/yoga/grid_overflow_inline_axis_hidden.java new file mode 100644 index 0000000000..351e4b0265 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_overflow_inline_axis_hidden.java @@ -0,0 +1,75 @@ +/* + * 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 SignedSource<<34f6cd75021068f7f9aec621ce0e852f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_inline_axis_hidden.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_overflow_inline_axis_hidden { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_overflow_inline_axis_hidden() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(50f); + root.setHeight(50f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setOverflow(YogaOverflow.HIDDEN); + root.addChildAt(root_child0, 0); + root_child0.setData("HHHHHHHHHH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_overflow_inline_axis_scroll.java b/java/tests/generated/com/facebook/yoga/grid_overflow_inline_axis_scroll.java new file mode 100644 index 0000000000..e232f1483f --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_overflow_inline_axis_scroll.java @@ -0,0 +1,75 @@ +/* + * 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 SignedSource<<6a44169ab65c4d0bf8dde0b5c189f7c0>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_inline_axis_scroll.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_overflow_inline_axis_scroll { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_overflow_inline_axis_scroll() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(50f); + root.setHeight(50f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setOverflow(YogaOverflow.SCROLL); + root.addChildAt(root_child0, 0); + root_child0.setData("HHHHHHHHHH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(50f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_overflow_inline_axis_visible.java b/java/tests/generated/com/facebook/yoga/grid_overflow_inline_axis_visible.java new file mode 100644 index 0000000000..041156ff53 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_overflow_inline_axis_visible.java @@ -0,0 +1,74 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_inline_axis_visible.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_overflow_inline_axis_visible { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_overflow_inline_axis_visible() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(50f); + root.setHeight(50f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + root_child0.setData("HHHHHHHHHH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(-50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_overridden_by_available_space.java b/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_overridden_by_available_space.java new file mode 100644 index 0000000000..13bb169af6 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_overridden_by_available_space.java @@ -0,0 +1,87 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_overridden_by_available_space.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_overflow_scrollbars_overridden_by_available_space { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_overflow_scrollbars_overridden_by_available_space() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(2f); + root.setHeight(4f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setOverflow(YogaOverflow.SCROLL); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(2f, root.getLayoutWidth(), 0.0f); + assertEquals(4f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(2f, root.getLayoutWidth(), 0.0f); + assertEquals(4f, root.getLayoutHeight(), 0.0f); + + assertEquals(2f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_overridden_by_max_size.java b/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_overridden_by_max_size.java new file mode 100644 index 0000000000..475cf78c97 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_overridden_by_max_size.java @@ -0,0 +1,73 @@ +/* + * 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 SignedSource<<35c6dc45a17dacff6d5b7a22f6f69318>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_overridden_by_max_size.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_overflow_scrollbars_overridden_by_max_size { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_overflow_scrollbars_overridden_by_max_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setOverflow(YogaOverflow.SCROLL); + root.setMaxWidth(2f); + root.setMaxHeight(4f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(0f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(0f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_overridden_by_size.java b/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_overridden_by_size.java new file mode 100644 index 0000000000..fac2c931a6 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_overridden_by_size.java @@ -0,0 +1,73 @@ +/* + * 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 SignedSource<<8171dc3959dd04f055c465fed8bf5fbd>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_overridden_by_size.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_overflow_scrollbars_overridden_by_size { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_overflow_scrollbars_overridden_by_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setOverflow(YogaOverflow.SCROLL); + root.setWidth(2f); + root.setHeight(4f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(2f, root.getLayoutWidth(), 0.0f); + assertEquals(4f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(2f, root.getLayoutWidth(), 0.0f); + assertEquals(4f, root.getLayoutHeight(), 0.0f); + + assertEquals(2f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_take_up_space_both_axis.java b/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_take_up_space_both_axis.java new file mode 100644 index 0000000000..42569131de --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_overflow_scrollbars_take_up_space_both_axis.java @@ -0,0 +1,73 @@ +/* + * 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 SignedSource<<1fc296a9aa02c6e20704cc5d2191839d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_take_up_space_both_axis.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_overflow_scrollbars_take_up_space_both_axis { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_overflow_scrollbars_take_up_space_both_axis() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setOverflow(YogaOverflow.SCROLL); + root.setWidth(50f); + root.setHeight(50f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(50f, root.getLayoutWidth(), 0.0f); + assertEquals(50f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_container_max_size.java b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_container_max_size.java new file mode 100644 index 0000000000..8b4768f48d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_container_max_size.java @@ -0,0 +1,80 @@ +/* + * 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 SignedSource<<31425462c94f8905a61c67d54679c33d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_container_max_size.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_padding_border_overrides_container_max_size { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_padding_border_overrides_container_max_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 8); + root.setPadding(YogaEdge.TOP, 2); + root.setPadding(YogaEdge.RIGHT, 4); + root.setPadding(YogaEdge.BOTTOM, 6); + root.setBorder(YogaEdge.LEFT, 7f); + root.setBorder(YogaEdge.TOP, 1f); + root.setBorder(YogaEdge.RIGHT, 3f); + root.setBorder(YogaEdge.BOTTOM, 5f); + root.setMaxWidth(12f); + root.setMaxHeight(12f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(15f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(15f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_container_size.java b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_container_size.java new file mode 100644 index 0000000000..8453cbe5b4 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_container_size.java @@ -0,0 +1,80 @@ +/* + * 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 SignedSource<<341e57412900c66281ace49578c9cca7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_container_size.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_padding_border_overrides_container_size { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_padding_border_overrides_container_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 8); + root.setPadding(YogaEdge.TOP, 2); + root.setPadding(YogaEdge.RIGHT, 4); + root.setPadding(YogaEdge.BOTTOM, 6); + root.setBorder(YogaEdge.LEFT, 7f); + root.setBorder(YogaEdge.TOP, 1f); + root.setBorder(YogaEdge.RIGHT, 3f); + root.setBorder(YogaEdge.BOTTOM, 5f); + root.setWidth(12f); + root.setHeight(12f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(15f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(15f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_max_size.java b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_max_size.java new file mode 100644 index 0000000000..0fd4e36d34 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_max_size.java @@ -0,0 +1,80 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_max_size.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_padding_border_overrides_max_size { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_padding_border_overrides_max_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setPadding(YogaEdge.LEFT, 8); + root_child0.setPadding(YogaEdge.TOP, 2); + root_child0.setPadding(YogaEdge.RIGHT, 4); + root_child0.setPadding(YogaEdge.BOTTOM, 6); + root_child0.setBorder(YogaEdge.LEFT, 7f); + root_child0.setBorder(YogaEdge.TOP, 1f); + root_child0.setBorder(YogaEdge.RIGHT, 3f); + root_child0.setBorder(YogaEdge.BOTTOM, 5f); + root_child0.setMaxWidth(12f); + root_child0.setMaxHeight(12f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(22f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(14f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(22f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(14f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_min_size.java b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_min_size.java new file mode 100644 index 0000000000..cfc6ece6a5 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_min_size.java @@ -0,0 +1,78 @@ +/* + * 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 SignedSource<<85dc4c015ead5f6f8abc45d05ebc9a77>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_min_size.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_padding_border_overrides_min_size { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_padding_border_overrides_min_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setPadding(YogaEdge.LEFT, 8); + root_child0.setPadding(YogaEdge.TOP, 2); + root_child0.setPadding(YogaEdge.RIGHT, 4); + root_child0.setPadding(YogaEdge.BOTTOM, 6); + root_child0.setBorder(YogaEdge.LEFT, 7f); + root_child0.setBorder(YogaEdge.TOP, 1f); + root_child0.setBorder(YogaEdge.RIGHT, 3f); + root_child0.setBorder(YogaEdge.BOTTOM, 5f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(22f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(14f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(22f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(14f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_size.java b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_size.java new file mode 100644 index 0000000000..d3d0bd942c --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_padding_border_overrides_size.java @@ -0,0 +1,80 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_size.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_padding_border_overrides_size { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_padding_border_overrides_size() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setPadding(YogaEdge.LEFT, 8); + root_child0.setPadding(YogaEdge.TOP, 2); + root_child0.setPadding(YogaEdge.RIGHT, 4); + root_child0.setPadding(YogaEdge.BOTTOM, 6); + root_child0.setBorder(YogaEdge.LEFT, 7f); + root_child0.setBorder(YogaEdge.TOP, 1f); + root_child0.setBorder(YogaEdge.RIGHT, 3f); + root_child0.setBorder(YogaEdge.BOTTOM, 5f); + root_child0.setWidth(12f); + root_child0.setHeight(12f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(22f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(14f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(22f, root.getLayoutWidth(), 0.0f); + assertEquals(14f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(22f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(14f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_item_inside_stretch_item.java b/java/tests/generated/com/facebook/yoga/grid_percent_item_inside_stretch_item.java new file mode 100644 index 0000000000..4896b59568 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_item_inside_stretch_item.java @@ -0,0 +1,88 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_item_inside_stretch_item.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_item_inside_stretch_item { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_item_inside_stretch_item() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setWidthPercent(50f); + root_child0_child0.setDisplay(YogaDisplay.GRID); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_inside_stretch_alignment.java b/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_inside_stretch_alignment.java new file mode 100644 index 0000000000..257e73be39 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_inside_stretch_alignment.java @@ -0,0 +1,87 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_inside_stretch_alignment.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_items_nested_inside_stretch_alignment { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_items_nested_inside_stretch_alignment() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPaddingPercent(YogaEdge.TOP, 20); + root_child0_child0.setDisplay(YogaDisplay.GRID); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_moderate.java b/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_moderate.java new file mode 100644 index 0000000000..4a2402843a --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_moderate.java @@ -0,0 +1,107 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_moderate.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_items_nested_moderate { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_items_nested_moderate() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 3); + root.setPadding(YogaEdge.TOP, 3); + root.setPadding(YogaEdge.RIGHT, 3); + root.setPadding(YogaEdge.BOTTOM, 3); + root.setWidth(200f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setMargin(YogaEdge.LEFT, 5f); + root_child0.setMargin(YogaEdge.TOP, 5f); + root_child0.setMargin(YogaEdge.RIGHT, 5f); + root_child0.setMargin(YogaEdge.BOTTOM, 5f); + root_child0.setPaddingPercent(YogaEdge.LEFT, 3); + root_child0.setPaddingPercent(YogaEdge.TOP, 3); + root_child0.setPaddingPercent(YogaEdge.RIGHT, 3); + root_child0.setPaddingPercent(YogaEdge.BOTTOM, 3); + root_child0.setWidthPercent(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setMarginPercent(YogaEdge.LEFT, 5f); + root_child0_child0.setMarginPercent(YogaEdge.TOP, 5f); + root_child0_child0.setMarginPercent(YogaEdge.RIGHT, 5f); + root_child0_child0.setMarginPercent(YogaEdge.BOTTOM, 5f); + root_child0_child0.setPadding(YogaEdge.LEFT, 3); + root_child0_child0.setPadding(YogaEdge.TOP, 3); + root_child0_child0.setPadding(YogaEdge.RIGHT, 3); + root_child0_child0.setPadding(YogaEdge.BOTTOM, 3); + root_child0_child0.setWidthPercent(45f); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(24f, root.getLayoutHeight(), 0.0f); + + assertEquals(8f, root_child0.getLayoutX(), 0.0f); + assertEquals(8f, root_child0.getLayoutY(), 0.0f); + assertEquals(8f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(8f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(1f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(6f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(6f, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(24f, root.getLayoutHeight(), 0.0f); + + assertEquals(184f, root_child0.getLayoutX(), 0.0f); + assertEquals(8f, root_child0.getLayoutY(), 0.0f); + assertEquals(8f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(8f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(1f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(6f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(6f, root_child0_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_with_margin.java b/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_with_margin.java new file mode 100644 index 0000000000..99d6475743 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_with_margin.java @@ -0,0 +1,91 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_with_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_items_nested_with_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_items_nested_with_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidthPercent(50f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setMarginPercent(YogaEdge.LEFT, 5f); + root_child0_child0.setMarginPercent(YogaEdge.TOP, 5f); + root_child0_child0.setMarginPercent(YogaEdge.RIGHT, 5f); + root_child0_child0.setMarginPercent(YogaEdge.BOTTOM, 5f); + root_child0_child0.setWidthPercent(45f); + root_child0.addChildAt(root_child0_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_with_padding_margin.java b/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_with_padding_margin.java new file mode 100644 index 0000000000..edf7df1f81 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_items_nested_with_padding_margin.java @@ -0,0 +1,149 @@ +/* + * 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 SignedSource<<60800ed42e3b54e2dba518165c7284d7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_with_padding_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_items_nested_with_padding_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_items_nested_with_padding_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setMargin(YogaEdge.LEFT, 5f); + root_child0.setMargin(YogaEdge.TOP, 5f); + root_child0.setMargin(YogaEdge.RIGHT, 5f); + root_child0.setMargin(YogaEdge.BOTTOM, 5f); + root_child0.setPadding(YogaEdge.LEFT, 3); + root_child0.setPadding(YogaEdge.TOP, 3); + root_child0.setPadding(YogaEdge.RIGHT, 3); + root_child0.setPadding(YogaEdge.BOTTOM, 3); + root_child0.setMinWidthPercent(60f); + root_child0.setDisplay(YogaDisplay.GRID); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setMargin(YogaEdge.LEFT, 5f); + root_child0_child0.setMargin(YogaEdge.TOP, 5f); + root_child0_child0.setMargin(YogaEdge.RIGHT, 5f); + root_child0_child0.setMargin(YogaEdge.BOTTOM, 5f); + root_child0_child0.setPaddingPercent(YogaEdge.LEFT, 3); + root_child0_child0.setPaddingPercent(YogaEdge.TOP, 3); + root_child0_child0.setPaddingPercent(YogaEdge.RIGHT, 3); + root_child0_child0.setPaddingPercent(YogaEdge.BOTTOM, 3); + root_child0_child0.setWidthPercent(50f); + root_child0_child0.setDisplay(YogaDisplay.GRID); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child0_child0 = createNode(config); + root_child0_child0_child0.setMarginPercent(YogaEdge.LEFT, 5f); + root_child0_child0_child0.setMarginPercent(YogaEdge.TOP, 5f); + root_child0_child0_child0.setMarginPercent(YogaEdge.RIGHT, 5f); + root_child0_child0_child0.setMarginPercent(YogaEdge.BOTTOM, 5f); + root_child0_child0_child0.setPadding(YogaEdge.LEFT, 3); + root_child0_child0_child0.setPadding(YogaEdge.TOP, 3); + root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 3); + root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 3); + root_child0_child0_child0.setWidthPercent(45f); + root_child0_child0.addChildAt(root_child0_child0_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(5f, root_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child0.getLayoutY(), 0.0f); + assertEquals(22f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(8f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(8f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(8f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(1f, root_child0_child0_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0_child0_child0.getLayoutY(), 0.0f); + assertEquals(6f, root_child0_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(32f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child1.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(173f, root_child0.getLayoutX(), 0.0f); + assertEquals(5f, root_child0.getLayoutY(), 0.0f); + assertEquals(22f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(6f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(8f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(8f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(8f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(1f, root_child0_child0_child0.getLayoutX(), 0.0f); + assertEquals(1f, root_child0_child0_child0.getLayoutY(), 0.0f); + assertEquals(6f, root_child0_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(6f, root_child0_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(168f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(32f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(160f, root_child1.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_items_width_and_margin.java b/java/tests/generated/com/facebook/yoga/grid_percent_items_width_and_margin.java new file mode 100644 index 0000000000..0c936cd922 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_items_width_and_margin.java @@ -0,0 +1,84 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_width_and_margin.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_items_width_and_margin { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_items_width_and_margin() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 3); + root.setPadding(YogaEdge.TOP, 3); + root.setPadding(YogaEdge.RIGHT, 3); + root.setPadding(YogaEdge.BOTTOM, 3); + root.setWidth(200f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setMarginPercent(YogaEdge.LEFT, 5f); + root_child0.setMarginPercent(YogaEdge.TOP, 5f); + root_child0.setMarginPercent(YogaEdge.RIGHT, 5f); + root_child0.setMarginPercent(YogaEdge.BOTTOM, 5f); + root_child0.setPadding(YogaEdge.LEFT, 3); + root_child0.setPadding(YogaEdge.TOP, 3); + root_child0.setPadding(YogaEdge.RIGHT, 3); + root_child0.setPadding(YogaEdge.BOTTOM, 3); + root_child0.setWidthPercent(45f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(13f, root.getLayoutHeight(), 0.0f); + + assertEquals(3f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(6f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(6f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(13f, root.getLayoutHeight(), 0.0f); + + assertEquals(191f, root_child0.getLayoutX(), 0.0f); + assertEquals(3f, root_child0.getLayoutY(), 0.0f); + assertEquals(6f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(6f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_items_width_and_padding.java b/java/tests/generated/com/facebook/yoga/grid_percent_items_width_and_padding.java new file mode 100644 index 0000000000..44def2d4b8 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_items_width_and_padding.java @@ -0,0 +1,76 @@ +/* + * 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 SignedSource<<5712bda2bbb97aa6eb02796a5c4212ed>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_width_and_padding.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_items_width_and_padding { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_items_width_and_padding() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setPaddingPercent(YogaEdge.LEFT, 3); + root_child0.setPaddingPercent(YogaEdge.TOP, 3); + root_child0.setPaddingPercent(YogaEdge.RIGHT, 3); + root_child0.setPaddingPercent(YogaEdge.BOTTOM, 3); + root_child0.setWidthPercent(50f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_tracks_definite_overflow.java b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_definite_overflow.java new file mode 100644 index 0000000000..8b90311e1a --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_definite_overflow.java @@ -0,0 +1,159 @@ +/* + * 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 SignedSource<<2ad2519fa21c74385f9190a59b4240eb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_definite_overflow.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_tracks_definite_overflow { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_tracks_definite_overflow() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(60f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(48f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(48f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(48f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(48f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(48f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child4.getLayoutX(), 0.0f); + assertEquals(30f, root_child4.getLayoutY(), 0.0f); + assertEquals(48f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(48f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(96f, root_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child5.getLayoutY(), 0.0f); + assertEquals(48f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(48f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); + + assertEquals(72f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(48f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(24f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(48f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(-24f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(48f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(72f, root_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child3.getLayoutY(), 0.0f); + assertEquals(48f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(48f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(24f, root_child4.getLayoutX(), 0.0f); + assertEquals(30f, root_child4.getLayoutY(), 0.0f); + assertEquals(48f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(48f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(-24f, root_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child5.getLayoutY(), 0.0f); + assertEquals(48f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(48f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_tracks_definite_underflow.java b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_definite_underflow.java new file mode 100644 index 0000000000..f8bf104559 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_definite_underflow.java @@ -0,0 +1,159 @@ +/* + * 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 SignedSource<<6a89af96b6edcb3a45afdbdc0dbb7916>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_definite_underflow.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_tracks_definite_underflow { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_tracks_definite_underflow() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(60f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(12f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(18f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(12f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(24f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(18f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(36f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(36f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(18f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(18f, root_child3.getLayoutY(), 0.0f); + assertEquals(12f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(36f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(12f, root_child4.getLayoutX(), 0.0f); + assertEquals(18f, root_child4.getLayoutY(), 0.0f); + assertEquals(24f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(36f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(36f, root_child5.getLayoutX(), 0.0f); + assertEquals(18f, root_child5.getLayoutY(), 0.0f); + assertEquals(36f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(36f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(60f, root.getLayoutHeight(), 0.0f); + + assertEquals(108f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(12f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(18f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(84f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(24f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(18f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(36f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(18f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(108f, root_child3.getLayoutX(), 0.0f); + assertEquals(18f, root_child3.getLayoutY(), 0.0f); + assertEquals(12f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(36f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(84f, root_child4.getLayoutX(), 0.0f); + assertEquals(18f, root_child4.getLayoutY(), 0.0f); + assertEquals(24f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(36f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(48f, root_child5.getLayoutX(), 0.0f); + assertEquals(18f, root_child5.getLayoutY(), 0.0f); + assertEquals(36f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(36f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_tracks_indefinite_only.java b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_indefinite_only.java new file mode 100644 index 0000000000..3ae3d7d717 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_indefinite_only.java @@ -0,0 +1,157 @@ +/* + * 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 SignedSource<<450d134f5cd335a5836dc26eb13bc288>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_indefinite_only.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_tracks_indefinite_only { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_tracks_indefinite_only() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(0f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(0f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(0f, root_child5.getLayoutY(), 0.0f); + assertEquals(0f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child5.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(0f, root.getLayoutWidth(), 0.0f); + assertEquals(0f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(0f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(0f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child5.getLayoutX(), 0.0f); + assertEquals(0f, root_child5.getLayoutY(), 0.0f); + assertEquals(0f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child5.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_tracks_indefinite_with_content_overflow.java b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_indefinite_with_content_overflow.java new file mode 100644 index 0000000000..3d6d3db389 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_indefinite_with_content_overflow.java @@ -0,0 +1,176 @@ +/* + * 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 SignedSource<<92a16cbb0d0a76d679e3b5b0f549f20b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_indefinite_with_content_overflow.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_tracks_indefinite_with_content_overflow { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_tracks_indefinite_with_content_overflow() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setGridColumnStart(1); + root_child1.setGridRowStart(1); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child6.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(40f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child4.getLayoutY(), 0.0f); + assertEquals(40f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child5.getLayoutX(), 0.0f); + assertEquals(50f, root_child5.getLayoutY(), 0.0f); + assertEquals(40f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(-20f, root_child6.getLayoutX(), 0.0f); + assertEquals(50f, root_child6.getLayoutY(), 0.0f); + assertEquals(40f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child6.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_percent_tracks_indefinite_with_content_underflow.java b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_indefinite_with_content_underflow.java new file mode 100644 index 0000000000..507cb24052 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_percent_tracks_indefinite_with_content_underflow.java @@ -0,0 +1,176 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_indefinite_with_content_underflow.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_percent_tracks_indefinite_with_content_underflow { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_percent_tracks_indefinite_with_content_underflow() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setGridColumnStart(1); + root_child1.setGridRowStart(1); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root.addChildAt(root_child4, 4); + + final YogaNode root_child5 = createNode(config); + root.addChildAt(root_child5, 5); + + final YogaNode root_child6 = createNode(config); + root.addChildAt(root_child6, 6); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(30f, root_child4.getLayoutY(), 0.0f); + assertEquals(10f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(30f, root_child6.getLayoutX(), 0.0f); + assertEquals(30f, root_child6.getLayoutY(), 0.0f); + assertEquals(30f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child6.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(20f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child4.getLayoutX(), 0.0f); + assertEquals(30f, root_child4.getLayoutY(), 0.0f); + assertEquals(10f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child4.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child5.getLayoutX(), 0.0f); + assertEquals(30f, root_child5.getLayoutY(), 0.0f); + assertEquals(20f, root_child5.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child5.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child6.getLayoutX(), 0.0f); + assertEquals(30f, root_child6.getLayoutY(), 0.0f); + assertEquals(30f, root_child6.getLayoutWidth(), 0.0f); + assertEquals(60f, root_child6.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_placement_auto_negative.java b/java/tests/generated/com/facebook/yoga/grid_placement_auto_negative.java new file mode 100644 index 0000000000..3174c416c9 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_placement_auto_negative.java @@ -0,0 +1,123 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_placement_auto_negative.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_placement_auto_negative { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_placement_auto_negative() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setGridColumnStart(-5); + root_child0.setGridRowStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setGridRowStart(2); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(0f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.java b/java/tests/generated/com/facebook/yoga/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.java new file mode 100644 index 0000000000..12cb01a21d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.java @@ -0,0 +1,124 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_placement_definite_in_secondary_axis_with_fully_definite_negative { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_placement_definite_in_secondary_axis_with_fully_definite_negative() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setGridRowStart(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setGridColumnStart(-4); + root_child1.setGridRowStart(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setGridRowStart(1); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(40f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(40f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1.getLayoutX(), 0.0f); + assertEquals(40f, root_child1.getLayoutY(), 0.0f); + assertEquals(0f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(0f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_placement_definite_primary.java b/java/tests/generated/com/facebook/yoga/grid_placement_definite_primary.java new file mode 100644 index 0000000000..05c9fe3824 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_placement_definite_primary.java @@ -0,0 +1,138 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_placement_definite_primary.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_placement_definite_primary { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_placement_definite_primary() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + root.setHeight(200f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + + final YogaNode root_child0 = createNode(config); + root_child0.setGridColumnStart(1); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setGridColumnStart(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setGridColumnStart(1); + root.addChildAt(root_child2, 2); + + final YogaNode root_child3 = createNode(config); + root_child3.setGridColumnStart(2); + root.addChildAt(root_child3, 3); + + final YogaNode root_child4 = createNode(config); + root_child4.setGridColumnStart(1); + root.addChildAt(root_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(66f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(66f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(148f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(66f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(66f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(148f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(66f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(200f, root.getLayoutHeight(), 0.0f); + + assertEquals(134f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(66f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(-14f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(148f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(134f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(66f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(-14f, root_child3.getLayoutX(), 0.0f); + assertEquals(0f, root_child3.getLayoutY(), 0.0f); + assertEquals(148f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(134f, root_child4.getLayoutX(), 0.0f); + assertEquals(0f, root_child4.getLayoutY(), 0.0f); + assertEquals(66f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child4.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_relative_all_sides.java b/java/tests/generated/com/facebook/yoga/grid_relative_all_sides.java new file mode 100644 index 0000000000..0a8a4748a1 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_relative_all_sides.java @@ -0,0 +1,77 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_relative_all_sides.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_relative_all_sides { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_relative_all_sides() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setPosition(YogaEdge.LEFT, 10f); + root_child0.setPosition(YogaEdge.TOP, 10f); + root_child0.setPosition(YogaEdge.RIGHT, 10f); + root_child0.setPosition(YogaEdge.BOTTOM, 10f); + root_child0.setWidth(40f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_size_child_fixed_tracks.java b/java/tests/generated/com/facebook/yoga/grid_size_child_fixed_tracks.java new file mode 100644 index 0000000000..d74c5132a0 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_size_child_fixed_tracks.java @@ -0,0 +1,178 @@ +/* + * 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 SignedSource<<24b85c9fb9862cef21384b9f43b59203>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_size_child_fixed_tracks.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_size_child_fixed_tracks { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_size_child_fixed_tracks() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(120f); + root.setHeight(120f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setJustifySelf(YogaJustify.START); + root_child0.setAlignSelf(YogaAlign.START); + root.addChildAt(root_child0, 0); + root_child0.setData("HH HH HH HH"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child1 = createNode(config); + root_child1.setJustifySelf(YogaJustify.START); + root_child1.setAlignSelf(YogaAlign.START); + root.addChildAt(root_child1, 1); + root_child1.setData("HHH HHH"); + root_child1.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child2 = createNode(config); + root_child2.setJustifySelf(YogaJustify.START); + root_child2.setAlignSelf(YogaAlign.START); + root.addChildAt(root_child2, 2); + root_child2.setData("HH HHHH"); + root_child2.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child3 = createNode(config); + root_child3.setJustifySelf(YogaJustify.START); + root_child3.setAlignSelf(YogaAlign.START); + root_child3.setWidth(20f); + root.addChildAt(root_child3, 3); + root_child3.setData("HH HH HH HH"); + root_child3.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + + final YogaNode root_child4 = createNode(config); + root_child4.setJustifySelf(YogaJustify.START); + root_child4.setAlignSelf(YogaAlign.START); + root_child4.setMaxWidth(30f); + root.addChildAt(root_child4, 4); + root_child4.setData("HH HH HH HH"); + root_child4.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(120f, root.getLayoutWidth(), 0.0f); + assertEquals(120f, root.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(40f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child2.getLayoutY(), 0.0f); + assertEquals(40f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child3.getLayoutY(), 0.0f); + assertEquals(20f, root_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child4.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/grid_taffy_issue_624.java b/java/tests/generated/com/facebook/yoga/grid_taffy_issue_624.java new file mode 100644 index 0000000000..6fa297c63d --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/grid_taffy_issue_624.java @@ -0,0 +1,152 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_taffy_issue_624.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class grid_taffy_issue_624 { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_taffy_issue_624() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setJustifyContent(YogaJustify.START); + root.setJustifyItems(YogaJustify.START); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(320f); + root.setHeight(640f); + root.setDisplay(YogaDisplay.GRID); + YogaGridTrackList rootGridTemplateColumns = new YogaGridTrackList(); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateColumns(rootGridTemplateColumns); + YogaGridTrackList rootGridTemplateRows = new YogaGridTrackList(); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + rootGridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root.setGridTemplateRows(rootGridTemplateRows); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(100f); + root_child0.setHeight(50f); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root_child0.setGridRowEndSpan(2); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setWidth(40f); + root_child1.setHeight(30f); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEndSpan(2); + root_child1.setGridRowStart(1); + root_child1.setGridRowEndSpan(2); + root.addChildAt(root_child1, 1); + + final YogaNode root_child2 = createNode(config); + root_child2.setWidth(120f); + root_child2.setHeight(20f); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEndSpan(2); + root_child2.setGridRowStart(3); + root_child2.setGridRowEndSpan(1); + root.addChildAt(root_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(320f, root.getLayoutWidth(), 0.0f); + assertEquals(640f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(320f, root.getLayoutWidth(), 0.0f); + assertEquals(640f, root.getLayoutHeight(), 0.0f); + + assertEquals(220f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(180f, root_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1.getLayoutY(), 0.0f); + assertEquals(40f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(200f, root_child2.getLayoutX(), 0.0f); + assertEquals(50f, root_child2.getLayoutY(), 0.0f); + assertEquals(120f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(20f, root_child2.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/xgrid_aspect_ratio_fill_child_min_width.java b/java/tests/generated/com/facebook/yoga/xgrid_aspect_ratio_fill_child_min_width.java new file mode 100644 index 0000000000..240c5fcf23 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/xgrid_aspect_ratio_fill_child_min_width.java @@ -0,0 +1,74 @@ +/* + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/xgrid_aspect_ratio_fill_child_min_width.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class xgrid_aspect_ratio_fill_child_min_width { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_aspect_ratio_fill_child_min_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + root.setDisplay(YogaDisplay.GRID); + + final YogaNode root_child0 = createNode(config); + root_child0.setMinHeight(50f); + root_child0.setAspectRatio(2 / 1f); + root.addChildAt(root_child0, 0); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(100f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child0.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/java/tests/generated/com/facebook/yoga/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.java b/java/tests/generated/com/facebook/yoga/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.java new file mode 100644 index 0000000000..3a5769bb73 --- /dev/null +++ b/java/tests/generated/com/facebook/yoga/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.java @@ -0,0 +1,168 @@ +/* + * 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 SignedSource<<6a5e89f8c961b317fc983f9d746adfde>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.html + */ + +package com.facebook.yoga; + +import static org.junit.Assert.assertEquals; + +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import com.facebook.yoga.utils.TestUtils; + +@RunWith(Parameterized.class) +public class xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track { + @Parameterized.Parameters(name = "{0}") + public static Iterable nodeFactories() { + return TestParametrization.nodeFactories(); + } + + @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory; + + @Test + public void test_grid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidthMaxContent(); + + final YogaNode root_child0 = createNode(config); + root_child0.setDisplay(YogaDisplay.GRID); + YogaGridTrackList root_child0GridTemplateColumns = new YogaGridTrackList(); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateColumns.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + YogaGridTrackList root_child0GridTemplateRows = new YogaGridTrackList(); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0GridTemplateRows.addTrack(YogaGridTrackValue.auto()); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setWidth(60f); + root_child0_child0.setGridColumnStartSpan(2); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0.addChildAt(root_child0_child2, 2); + + final YogaNode root_child0_child3 = createNode(config); + root_child0.addChildAt(root_child0_child3, 3); + + final YogaNode root_child0_child4 = createNode(config); + root_child0.addChildAt(root_child0_child4, 4); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(78f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(78f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(9f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(24f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(24f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(36f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(60f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(9f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(78f, root.getLayoutWidth(), 0.0f); + assertEquals(80f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(78f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(80f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(18f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(60f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(9f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(9f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(54f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(24f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child2.getLayoutHeight(), 0.0f); + + assertEquals(18f, root_child0_child3.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutY(), 0.0f); + assertEquals(36f, root_child0_child3.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child3.getLayoutHeight(), 0.0f); + + assertEquals(9f, root_child0_child4.getLayoutX(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutY(), 0.0f); + assertEquals(9f, root_child0_child4.getLayoutWidth(), 0.0f); + assertEquals(40f, root_child0_child4.getLayoutHeight(), 0.0f); + } + + private YogaNode createNode(YogaConfig config) { + return mNodeFactory.create(config); + } +} diff --git a/javascript/CMakeLists.txt b/javascript/CMakeLists.txt index d3ddf3a6f2..4aed9b8578 100644 --- a/javascript/CMakeLists.txt +++ b/javascript/CMakeLists.txt @@ -7,9 +7,8 @@ cmake_minimum_required(VERSION 3.13...3.26) set(CMAKE_VERBOSE_MAKEFILE on) project(yoga) -file(GLOB SOURCES CONFIGURE_DEPENDS +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../yoga/*.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../yoga/**/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) include_directories(..) diff --git a/javascript/src/Node.cpp b/javascript/src/Node.cpp index 42f6d82f63..b3aa359244 100644 --- a/javascript/src/Node.cpp +++ b/javascript/src/Node.cpp @@ -6,8 +6,10 @@ */ #include +#include #include +#include #include "./Config.h" #include "./Layout.h" @@ -124,6 +126,14 @@ void Node::setJustifyContent(int justifyContent) { YGNodeStyleSetJustifyContent(m_node, static_cast(justifyContent)); } +void Node::setJustifyItems(int justifyItems) { + YGNodeStyleSetJustifyItems(m_node, static_cast(justifyItems)); +} + +void Node::setJustifySelf(int justifySelf) { + YGNodeStyleSetJustifySelf(m_node, static_cast(justifySelf)); +} + void Node::setMargin(int edge, double margin) { YGNodeStyleSetMargin(m_node, static_cast(edge), margin); } @@ -590,3 +600,102 @@ void Node::setAlwaysFormsContainingBlock(bool alwaysFormsContainingBlock) { return YGNodeSetAlwaysFormsContainingBlock( m_node, alwaysFormsContainingBlock); } + +// Helper function to convert JS track value to YGGridTrackValueRef +static YGGridTrackValueRef convertTrackValue(emscripten::val track) { + int type = track["type"].as(); + + switch (type) { + case YGGridTrackTypeAuto: + return YGAuto(); + case YGGridTrackTypePoints: { + float value = track["value"].as(); + return YGPoints(value); + } + case YGGridTrackTypePercent: { + float value = track["value"].as(); + return YGPercent(value); + } + case YGGridTrackTypeFr: { + float value = track["value"].as(); + return YGFr(value); + } + case YGGridTrackTypeMinmax: { + YGGridTrackValueRef minVal = convertTrackValue(track["min"]); + YGGridTrackValueRef maxVal = convertTrackValue(track["max"]); + return YGMinMax(minVal, maxVal); + } + default: + return YGAuto(); + } +} + +// Helper function to build grid track list from JS array +static YGGridTrackListRef buildGridTrackList(emscripten::val tracks) { + YGGridTrackListRef trackList = YGGridTrackListCreate(); + + unsigned length = tracks["length"].as(); + for (unsigned i = 0; i < length; i++) { + emscripten::val track = tracks[i]; + YGGridTrackValueRef trackValue = convertTrackValue(track); + YGGridTrackListAddTrack(trackList, trackValue); + } + + return trackList; +} + +void Node::setGridTemplateColumns(emscripten::val tracks) { + YGGridTrackListRef trackList = buildGridTrackList(tracks); + YGNodeStyleSetGridTemplateColumns(m_node, trackList); + YGGridTrackListFree(trackList); +} + +void Node::setGridTemplateRows(emscripten::val tracks) { + YGGridTrackListRef trackList = buildGridTrackList(tracks); + YGNodeStyleSetGridTemplateRows(m_node, trackList); + YGGridTrackListFree(trackList); +} + +void Node::setGridAutoColumns(emscripten::val tracks) { + YGGridTrackListRef trackList = buildGridTrackList(tracks); + YGNodeStyleSetGridAutoColumns(m_node, trackList); + YGGridTrackListFree(trackList); +} + +void Node::setGridAutoRows(emscripten::val tracks) { + YGGridTrackListRef trackList = buildGridTrackList(tracks); + YGNodeStyleSetGridAutoRows(m_node, trackList); + YGGridTrackListFree(trackList); +} + +void Node::setGridColumnStart(int value) { + YGNodeStyleSetGridColumnStart(m_node, value); +} + +void Node::setGridColumnStartSpan(int span) { + YGNodeStyleSetGridColumnStartSpan(m_node, span); +} + +void Node::setGridColumnEnd(int value) { + YGNodeStyleSetGridColumnEnd(m_node, value); +} + +void Node::setGridColumnEndSpan(int span) { + YGNodeStyleSetGridColumnEndSpan(m_node, span); +} + +void Node::setGridRowStart(int value) { + YGNodeStyleSetGridRowStart(m_node, value); +} + +void Node::setGridRowStartSpan(int span) { + YGNodeStyleSetGridRowStartSpan(m_node, span); +} + +void Node::setGridRowEnd(int value) { + YGNodeStyleSetGridRowEnd(m_node, value); +} + +void Node::setGridRowEndSpan(int span) { + YGNodeStyleSetGridRowEndSpan(m_node, span); +} diff --git a/javascript/src/Node.h b/javascript/src/Node.h index e101b436db..44c13b19df 100644 --- a/javascript/src/Node.h +++ b/javascript/src/Node.h @@ -84,6 +84,8 @@ class Node { void setFlexDirection(int flexDirection); void setFlexWrap(int flexWrap); void setJustifyContent(int justifyContent); + void setJustifyItems(int justifyItems); + void setJustifySelf(int justifySelf); void setDirection(int direction); void setMargin(int edge, double margin); @@ -150,6 +152,20 @@ class Node { void setBoxSizing(int boxSizing); + // Grid setters + void setGridTemplateColumns(emscripten::val tracks); + void setGridTemplateRows(emscripten::val tracks); + void setGridAutoColumns(emscripten::val tracks); + void setGridAutoRows(emscripten::val tracks); + void setGridColumnStart(int value); + void setGridColumnStartSpan(int span); + void setGridColumnEnd(int value); + void setGridColumnEndSpan(int span); + void setGridRowStart(int value); + void setGridRowStartSpan(int span); + void setGridRowEnd(int value); + void setGridRowEndSpan(int span); + public: // Style getters int getPositionType(void) const; Value getPosition(int edge) const; diff --git a/javascript/src/embind.cpp b/javascript/src/embind.cpp index a2f7202961..2e53981b71 100644 --- a/javascript/src/embind.cpp +++ b/javascript/src/embind.cpp @@ -78,6 +78,8 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) { .function("setFlexDirection", &Node::setFlexDirection) .function("setFlexWrap", &Node::setFlexWrap) .function("setJustifyContent", &Node::setJustifyContent) + .function("setJustifyItems", &Node::setJustifyItems) + .function("setJustifySelf", &Node::setJustifySelf) .function("setMargin", &Node::setMargin) .function("setMarginPercent", &Node::setMarginPercent) @@ -192,6 +194,20 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) { .function( "setAlwaysFormsContainingBlock", &Node::setAlwaysFormsContainingBlock) + // Grid setters + .function("setGridTemplateColumns", &Node::setGridTemplateColumns) + .function("setGridTemplateRows", &Node::setGridTemplateRows) + .function("setGridAutoColumns", &Node::setGridAutoColumns) + .function("setGridAutoRows", &Node::setGridAutoRows) + .function("setGridColumnStart", &Node::setGridColumnStart) + .function("setGridColumnStartSpan", &Node::setGridColumnStartSpan) + .function("setGridColumnEnd", &Node::setGridColumnEnd) + .function("setGridColumnEndSpan", &Node::setGridColumnEndSpan) + .function("setGridRowStart", &Node::setGridRowStart) + .function("setGridRowStartSpan", &Node::setGridRowStartSpan) + .function("setGridRowEnd", &Node::setGridRowEnd) + .function("setGridRowEndSpan", &Node::setGridRowEndSpan) + .function("isReferenceBaseline", &Node::isReferenceBaseline) .function("setIsReferenceBaseline", &Node::setIsReferenceBaseline) diff --git a/javascript/src/generated/YGEnums.ts b/javascript/src/generated/YGEnums.ts index f389fe2fdf..f50aa88a73 100644 --- a/javascript/src/generated/YGEnums.ts +++ b/javascript/src/generated/YGEnums.ts @@ -17,6 +17,8 @@ export enum Align { SpaceBetween = 6, SpaceAround = 7, SpaceEvenly = 8, + Start = 9, + End = 10, } export enum BoxSizing { @@ -39,6 +41,7 @@ export enum Display { Flex = 0, None = 1, Contents = 2, + Grid = 3, } export enum Edge { @@ -73,6 +76,14 @@ export enum FlexDirection { RowReverse = 3, } +export enum GridTrackType { + Auto = 0, + Points = 1, + Percent = 2, + Fr = 3, + Minmax = 4, +} + export enum Gutter { Column = 0, Row = 1, @@ -80,12 +91,16 @@ export enum Gutter { } export enum Justify { - FlexStart = 0, - Center = 1, - FlexEnd = 2, - SpaceBetween = 3, - SpaceAround = 4, - SpaceEvenly = 5, + Auto = 0, + FlexStart = 1, + Center = 2, + FlexEnd = 3, + SpaceBetween = 4, + SpaceAround = 5, + SpaceEvenly = 6, + Stretch = 7, + Start = 8, + End = 9, } export enum LogLevel { @@ -146,6 +161,8 @@ const constants = { ALIGN_SPACE_BETWEEN: Align.SpaceBetween, ALIGN_SPACE_AROUND: Align.SpaceAround, ALIGN_SPACE_EVENLY: Align.SpaceEvenly, + ALIGN_START: Align.Start, + ALIGN_END: Align.End, BOX_SIZING_BORDER_BOX: BoxSizing.BorderBox, BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox, DIMENSION_WIDTH: Dimension.Width, @@ -156,6 +173,7 @@ const constants = { DISPLAY_FLEX: Display.Flex, DISPLAY_NONE: Display.None, DISPLAY_CONTENTS: Display.Contents, + DISPLAY_GRID: Display.Grid, EDGE_LEFT: Edge.Left, EDGE_TOP: Edge.Top, EDGE_RIGHT: Edge.Right, @@ -176,15 +194,24 @@ const constants = { FLEX_DIRECTION_COLUMN_REVERSE: FlexDirection.ColumnReverse, FLEX_DIRECTION_ROW: FlexDirection.Row, FLEX_DIRECTION_ROW_REVERSE: FlexDirection.RowReverse, + GRID_TRACK_TYPE_AUTO: GridTrackType.Auto, + GRID_TRACK_TYPE_POINTS: GridTrackType.Points, + GRID_TRACK_TYPE_PERCENT: GridTrackType.Percent, + GRID_TRACK_TYPE_FR: GridTrackType.Fr, + GRID_TRACK_TYPE_MINMAX: GridTrackType.Minmax, GUTTER_COLUMN: Gutter.Column, GUTTER_ROW: Gutter.Row, GUTTER_ALL: Gutter.All, + JUSTIFY_AUTO: Justify.Auto, JUSTIFY_FLEX_START: Justify.FlexStart, JUSTIFY_CENTER: Justify.Center, JUSTIFY_FLEX_END: Justify.FlexEnd, JUSTIFY_SPACE_BETWEEN: Justify.SpaceBetween, JUSTIFY_SPACE_AROUND: Justify.SpaceAround, JUSTIFY_SPACE_EVENLY: Justify.SpaceEvenly, + JUSTIFY_STRETCH: Justify.Stretch, + JUSTIFY_START: Justify.Start, + JUSTIFY_END: Justify.End, LOG_LEVEL_ERROR: LogLevel.Error, LOG_LEVEL_WARN: LogLevel.Warn, LOG_LEVEL_INFO: LogLevel.Info, diff --git a/javascript/src/wrapAssembly.ts b/javascript/src/wrapAssembly.ts index 9b2dc1e6ec..01fb8bf5a9 100644 --- a/javascript/src/wrapAssembly.ts +++ b/javascript/src/wrapAssembly.ts @@ -20,6 +20,7 @@ import type { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, @@ -47,6 +48,13 @@ type Value = { value: number; }; +type GridTrackValue = { + type: GridTrackType; + value?: number; + min?: GridTrackValue; + max?: GridTrackValue; +}; + export type Config = { free(): void; isExperimentalFeatureEnabled(feature: ExperimentalFeature): boolean; @@ -170,6 +178,8 @@ export type Node = { setHeightPercent(height: number | undefined): void; setHeightStretch(): void; setJustifyContent(justifyContent: Justify): void; + setJustifyItems(justifyItems: Justify): void; + setJustifySelf(justifySelf: Justify): void; setGap(gutter: Gutter, gapLength: number | `${number}%` | undefined): Value; setGapPercent(gutter: Gutter, gapLength: number | undefined): Value; setMargin( @@ -258,6 +268,18 @@ export type Node = { unsetDirtiedFunc(): void; unsetMeasureFunc(): void; setAlwaysFormsContainingBlock(alwaysFormsContainingBlock: boolean): void; + setGridTemplateColumns(tracks: GridTrackValue[]): void; + setGridTemplateRows(tracks: GridTrackValue[]): void; + setGridAutoColumns(tracks: GridTrackValue[]): void; + setGridAutoRows(tracks: GridTrackValue[]): void; + setGridColumnStart(value: number): void; + setGridColumnStartSpan(span: number): void; + setGridColumnEnd(value: number): void; + setGridColumnEndSpan(span: number): void; + setGridRowStart(value: number): void; + setGridRowStartSpan(span: number): void; + setGridRowEnd(value: number): void; + setGridRowEndSpan(span: number): void; }; export type Yoga = { diff --git a/javascript/tests/generated/YGAbsolutePositionTest.test.ts b/javascript/tests/generated/YGAbsolutePositionTest.test.ts index 694086e23c..34102ab20d 100644 --- a/javascript/tests/generated/YGAbsolutePositionTest.test.ts +++ b/javascript/tests/generated/YGAbsolutePositionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<9deb466dfc94bb340137a9e6b5d5c63d>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGAlignContentTest.test.ts b/javascript/tests/generated/YGAlignContentTest.test.ts index aecef1a641..0d9a664741 100644 --- a/javascript/tests/generated/YGAlignContentTest.test.ts +++ b/javascript/tests/generated/YGAlignContentTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<82fd535509f8091cc2ea8503097520f1>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGAlignItemsTest.test.ts b/javascript/tests/generated/YGAlignItemsTest.test.ts index ae4dc63585..cdf3f9be9b 100644 --- a/javascript/tests/generated/YGAlignItemsTest.test.ts +++ b/javascript/tests/generated/YGAlignItemsTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<70b8fab25ecc3cd2ac855fc05c0ae528>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGAlignSelfTest.test.ts b/javascript/tests/generated/YGAlignSelfTest.test.ts index 5d2e49ecc9..509366341b 100644 --- a/javascript/tests/generated/YGAlignSelfTest.test.ts +++ b/javascript/tests/generated/YGAlignSelfTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<1badc9ed5a0cb8d9a4a1b23653cfbe58>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignSelfTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGAndroidNewsFeed.test.ts b/javascript/tests/generated/YGAndroidNewsFeed.test.ts index 488ed8d531..af16f244d3 100644 --- a/javascript/tests/generated/YGAndroidNewsFeed.test.ts +++ b/javascript/tests/generated/YGAndroidNewsFeed.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAndroidNewsFeed.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGAspectRatioTest.test.ts b/javascript/tests/generated/YGAspectRatioTest.test.ts index 69a7427809..31de4d5773 100644 --- a/javascript/tests/generated/YGAspectRatioTest.test.ts +++ b/javascript/tests/generated/YGAspectRatioTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<57064c3213fc22e0637ae5768ce6fea5>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAspectRatioTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGAutoTest.test.ts b/javascript/tests/generated/YGAutoTest.test.ts index 5e9557dc0f..81653007fd 100644 --- a/javascript/tests/generated/YGAutoTest.test.ts +++ b/javascript/tests/generated/YGAutoTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<234cdb7f76ac586e034a5b6ca2033fa4>> + * @generated SignedSource<<77991f9b9a3b5330ab0985fcbc7dc2be>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAutoTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGBorderTest.test.ts b/javascript/tests/generated/YGBorderTest.test.ts index ddbdd2aad1..d88d740e4f 100644 --- a/javascript/tests/generated/YGBorderTest.test.ts +++ b/javascript/tests/generated/YGBorderTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBorderTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGBoxSizingTest.test.ts b/javascript/tests/generated/YGBoxSizingTest.test.ts index d967870518..4f1d038021 100644 --- a/javascript/tests/generated/YGBoxSizingTest.test.ts +++ b/javascript/tests/generated/YGBoxSizingTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGDimensionTest.test.ts b/javascript/tests/generated/YGDimensionTest.test.ts index 39c140df0e..c6c7f1f3a9 100644 --- a/javascript/tests/generated/YGDimensionTest.test.ts +++ b/javascript/tests/generated/YGDimensionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<719c8f3b9fea672881a47f593f4aabd0>> + * @generated SignedSource<<0269633bd4c55343906f703147336507>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDimensionTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGDisplayTest.test.ts b/javascript/tests/generated/YGDisplayTest.test.ts index 9c6cd8d773..414d5296e3 100644 --- a/javascript/tests/generated/YGDisplayTest.test.ts +++ b/javascript/tests/generated/YGDisplayTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGFlexDirectionTest.test.ts b/javascript/tests/generated/YGFlexDirectionTest.test.ts index 2999befc5e..05208847a2 100644 --- a/javascript/tests/generated/YGFlexDirectionTest.test.ts +++ b/javascript/tests/generated/YGFlexDirectionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<285a0c9dd4b646e7b1af77658fc41d99>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexDirectionTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGFlexTest.test.ts b/javascript/tests/generated/YGFlexTest.test.ts index 6eee8e8640..d19104df11 100644 --- a/javascript/tests/generated/YGFlexTest.test.ts +++ b/javascript/tests/generated/YGFlexTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<60e19ea0b6b108cd6b0d4062c0b0316d>> + * @generated SignedSource<<38b3c3ba2b4d7f3b82504101e60ba0b5>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGFlexWrapTest.test.ts b/javascript/tests/generated/YGFlexWrapTest.test.ts index 28ee4cee2e..a8d9ece2c5 100644 --- a/javascript/tests/generated/YGFlexWrapTest.test.ts +++ b/javascript/tests/generated/YGFlexWrapTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<5c4e3faf7c401d359b341c41a3055313>> + * @generated SignedSource<<88720c733aee14a331371d80be8ff492>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexWrapTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGGapTest.test.ts b/javascript/tests/generated/YGGapTest.test.ts index d38f592eaa..fe1238cba9 100644 --- a/javascript/tests/generated/YGGapTest.test.ts +++ b/javascript/tests/generated/YGGapTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3fad56933a314f0a81b6ed504040ffae>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGapTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGGridTest.test.ts b/javascript/tests/generated/YGGridTest.test.ts new file mode 100644 index 0000000000..eb177b831b --- /dev/null +++ b/javascript/tests/generated/YGGridTest.test.ts @@ -0,0 +1,4126 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGridTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_all_properties', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + const rootGridAutoColumns = []; + rootGridAutoColumns.push({type: GridTrackType.Points, value: 100}); + rootGridAutoColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridAutoColumns(rootGridAutoColumns); + const rootGridAutoRows = []; + rootGridAutoRows.push({type: GridTrackType.Points, value: 100}); + rootGridAutoRows.push({type: GridTrackType.Points, value: 200}); + root.setGridAutoRows(rootGridAutoRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(5); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(4); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(400); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(400); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(500); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_auto_tracks', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(220); + root.setHeight(160); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 10); + root_child0.setPadding(Edge.Top, 10); + root_child0.setPadding(Edge.Right, 10); + root_child0.setPadding(Edge.Bottom, 10); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_auto_tracks_with_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 15); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(120); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPadding(Edge.Left, 40); + root_child2.setPadding(Edge.Top, 40); + root_child2.setPadding(Edge.Right, 40); + root_child2.setPadding(Edge.Bottom, 40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(135); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(130); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(135); + + expect(root_child0.getComputedLeft()).toBe(130); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(130); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_auto_tracks_with_margins', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 15); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 10); + root_child0.setWidth(120); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Top, 10); + root_child1.setWidth(120); + root_child1.setHeight(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPadding(Edge.Left, 40); + root_child2.setPadding(Edge.Top, 40); + root_child2.setPadding(Edge.Right, 40); + root_child2.setPadding(Edge.Bottom, 40); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(415); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(130); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(215); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(415); + + expect(root_child0.getComputedLeft()).toBe(130); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(130); + expect(root_child2.getComputedTop()).toBe(215); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_spanning_items', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(6); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 40); + root_child1.setPadding(Edge.Top, 40); + root_child1.setPadding(Edge.Right, 40); + root_child1.setPadding(Edge.Bottom, 40); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(210); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(210); + expect(root_child0.getComputedHeight()).toBe(210); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(220); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(220); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(210); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(210); + expect(root_child0.getComputedHeight()).toBe(210); + + expect(root_child1.getComputedLeft()).toBe(130); + expect(root_child1.getComputedTop()).toBe(220); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(220); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_holy_grail', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 60}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(80); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(200); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(200); + root_child3.setHeight("100%"); + root_child3.setGridColumnStart(3); + root_child3.setGridColumnEnd(4); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth("100%"); + root_child4.setHeight(60); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(4); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(260); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(260); + + expect(root_child3.getComputedLeft()).toBe(300); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(200); + expect(root_child3.getComputedHeight()).toBe(260); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(340); + expect(root_child4.getComputedWidth()).toBe(500); + expect(root_child4.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(300); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(260); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(260); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(200); + expect(root_child3.getComputedHeight()).toBe(260); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(340); + expect(root_child4.getComputedWidth()).toBe(500); + expect(root_child4.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_sidebar_layout', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 250}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(250); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(500); + + 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(500); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(500); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_header_content_footer', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(600); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight(80); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(3); + root_child2.setGridRowEnd(4); + root.insertChild(root_child2, 2); + 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(600); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(420); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(520); + expect(root_child2.getComputedWidth()).toBe(400); + expect(root_child2.getComputedHeight()).toBe(80); + + 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(600); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(420); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(520); + expect(root_child2.getComputedWidth()).toBe(400); + expect(root_child2.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_card_layout', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(500); + root.setGap(Gutter.Column, 20); + root.setGap(Gutter.Row, 20); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 250}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 250}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(250); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(200); + root_child1.setHeight(250); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(200); + root_child2.setHeight(250); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(200); + root_child3.setHeight(250); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(2); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(200); + root_child4.setHeight(250); + root_child4.setGridColumnStart(2); + root_child4.setGridColumnEnd(3); + root_child4.setGridRowStart(2); + root_child4.setGridRowEnd(3); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(200); + root_child5.setHeight(250); + root_child5.setGridColumnStart(3); + root_child5.setGridColumnEnd(4); + root_child5.setGridRowStart(2); + root_child5.setGridRowEnd(3); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(250); + + expect(root_child1.getComputedLeft()).toBe(220); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(250); + + expect(root_child2.getComputedLeft()).toBe(440); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(250); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(270); + expect(root_child3.getComputedWidth()).toBe(200); + expect(root_child3.getComputedHeight()).toBe(250); + + expect(root_child4.getComputedLeft()).toBe(220); + expect(root_child4.getComputedTop()).toBe(270); + expect(root_child4.getComputedWidth()).toBe(200); + expect(root_child4.getComputedHeight()).toBe(250); + + expect(root_child5.getComputedLeft()).toBe(440); + expect(root_child5.getComputedTop()).toBe(270); + expect(root_child5.getComputedWidth()).toBe(200); + expect(root_child5.getComputedHeight()).toBe(250); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(400); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(250); + + expect(root_child1.getComputedLeft()).toBe(180); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(250); + + expect(root_child2.getComputedLeft()).toBe(-40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(250); + + expect(root_child3.getComputedLeft()).toBe(400); + expect(root_child3.getComputedTop()).toBe(270); + expect(root_child3.getComputedWidth()).toBe(200); + expect(root_child3.getComputedHeight()).toBe(250); + + expect(root_child4.getComputedLeft()).toBe(180); + expect(root_child4.getComputedTop()).toBe(270); + expect(root_child4.getComputedWidth()).toBe(200); + expect(root_child4.getComputedHeight()).toBe(250); + + expect(root_child5.getComputedLeft()).toBe(-40); + expect(root_child5.getComputedTop()).toBe(270); + expect(root_child5.getComputedWidth()).toBe(200); + expect(root_child5.getComputedHeight()).toBe(250); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_dashboard_layout', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(600); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 220}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 70}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(70); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(220); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(4); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth("100%"); + root_child3.setHeight("100%"); + root_child3.setGridColumnStart(3); + root_child3.setGridColumnEnd(4); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth("100%"); + root_child4.setHeight("100%"); + root_child4.setGridColumnStart(2); + root_child4.setGridColumnEnd(4); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(600); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(70); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(220); + expect(root_child1.getComputedHeight()).toBe(520); + + expect(root_child2.getComputedLeft()).toBe(230); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(130); + expect(root_child2.getComputedHeight()).toBe(255); + + expect(root_child3.getComputedLeft()).toBe(370); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(130); + expect(root_child3.getComputedHeight()).toBe(255); + + expect(root_child4.getComputedLeft()).toBe(230); + expect(root_child4.getComputedTop()).toBe(345); + expect(root_child4.getComputedWidth()).toBe(270); + expect(root_child4.getComputedHeight()).toBe(255); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(600); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(70); + + expect(root_child1.getComputedLeft()).toBe(280); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(220); + expect(root_child1.getComputedHeight()).toBe(520); + + expect(root_child2.getComputedLeft()).toBe(140); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(130); + expect(root_child2.getComputedHeight()).toBe(255); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(130); + expect(root_child3.getComputedHeight()).toBe(255); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(345); + expect(root_child4.getComputedWidth()).toBe(270); + expect(root_child4.getComputedHeight()).toBe(255); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_magazine_layout', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(900); + root.setHeight(700); + root.setGap(Gutter.Column, 15); + root.setGap(Gutter.Row, 15); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 300}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight(300); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight(200); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth("100%"); + root_child3.setHeight(200); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(3); + root_child3.setGridRowEnd(4); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(900); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(590); + expect(root_child0.getComputedHeight()).toBe(515); + + expect(root_child1.getComputedLeft()).toBe(605); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(295); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(605); + expect(root_child2.getComputedTop()).toBe(315); + expect(root_child2.getComputedWidth()).toBe(295); + expect(root_child2.getComputedHeight()).toBe(200); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(530); + expect(root_child3.getComputedWidth()).toBe(900); + expect(root_child3.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(900); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(310); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(590); + expect(root_child0.getComputedHeight()).toBe(515); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(295); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(315); + expect(root_child2.getComputedWidth()).toBe(295); + expect(root_child2.getComputedHeight()).toBe(200); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(530); + expect(root_child3.getComputedWidth()).toBe(900); + expect(root_child3.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_app_layout', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(600); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 60}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 60}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(60); + root_child0.setHeight(60); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight(60); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(60); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth("100%"); + root_child3.setHeight("100%"); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth("100%"); + root_child4.setHeight(50); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(3); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.insertChild(root_child4, 4); + 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(600); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(340); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(60); + expect(root_child2.getComputedWidth()).toBe(60); + expect(root_child2.getComputedHeight()).toBe(490); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(340); + expect(root_child3.getComputedHeight()).toBe(490); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(550); + expect(root_child4.getComputedWidth()).toBe(400); + expect(root_child4.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(600); + + expect(root_child0.getComputedLeft()).toBe(340); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(340); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(340); + expect(root_child2.getComputedTop()).toBe(60); + expect(root_child2.getComputedWidth()).toBe(60); + expect(root_child2.getComputedHeight()).toBe(490); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(340); + expect(root_child3.getComputedHeight()).toBe(490); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(550); + expect(root_child4.getComputedWidth()).toBe(400); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_asymmetric_layout', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(600); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(200); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(3); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(4); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth("100%"); + root_child3.setHeight(200); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth("100%"); + root_child4.setHeight(200); + root_child4.setGridColumnStart(2); + root_child4.setGridColumnEnd(4); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(600); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(397); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(407); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(193); + expect(root_child1.getComputedHeight()).toBe(410); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(210); + expect(root_child2.getComputedWidth()).toBe(193); + expect(root_child2.getComputedHeight()).toBe(410); + + expect(root_child3.getComputedLeft()).toBe(203); + expect(root_child3.getComputedTop()).toBe(210); + expect(root_child3.getComputedWidth()).toBe(194); + expect(root_child3.getComputedHeight()).toBe(200); + + expect(root_child4.getComputedLeft()).toBe(203); + expect(root_child4.getComputedTop()).toBe(420); + expect(root_child4.getComputedWidth()).toBe(397); + expect(root_child4.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(600); + + expect(root_child0.getComputedLeft()).toBe(203); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(397); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(193); + expect(root_child1.getComputedHeight()).toBe(410); + + expect(root_child2.getComputedLeft()).toBe(407); + expect(root_child2.getComputedTop()).toBe(210); + expect(root_child2.getComputedWidth()).toBe(193); + expect(root_child2.getComputedHeight()).toBe(410); + + expect(root_child3.getComputedLeft()).toBe(203); + expect(root_child3.getComputedTop()).toBe(210); + expect(root_child3.getComputedWidth()).toBe(194); + expect(root_child3.getComputedHeight()).toBe(200); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(420); + expect(root_child4.getComputedWidth()).toBe(397); + expect(root_child4.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_with_percentage_tracks', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 20}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + 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(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(50); + + 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(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_percentage_tracks_with_definite_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 20}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(120); + + expect(root_child3.getComputedLeft()).toBe(30); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(120); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(210); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(300); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(120); + + expect(root_child3.getComputedLeft()).toBe(210); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_spanning_items_with_span', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setGridColumnStartSpan(2); + root_child0.setGridRowStartSpan(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(420); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(110); + expect(root_child0.getComputedHeight()).toBe(310); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(110); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(200); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(320); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(420); + + expect(root_child0.getComputedLeft()).toBe(110); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(110); + expect(root_child0.getComputedHeight()).toBe(310); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(110); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(200); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(320); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_mixed_units', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(400); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(80); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight(80); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(80); + root_child2.setGridColumnStart(4); + root_child2.setGridColumnEnd(5); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth("100%"); + root_child3.setHeight("100%"); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth("100%"); + root_child4.setHeight("100%"); + root_child4.setGridColumnStart(3); + root_child4.setGridColumnEnd(5); + root_child4.setGridRowStart(2); + root_child4.setGridRowEnd(3); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth("100%"); + root_child5.setHeight(80); + root_child5.setGridColumnStart(1); + root_child5.setGridColumnEnd(5); + root_child5.setGridRowStart(3); + root_child5.setGridRowEnd(4); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(380); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(500); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(233); + expect(root_child3.getComputedHeight()).toBe(220); + + expect(root_child4.getComputedLeft()).toBe(243); + expect(root_child4.getComputedTop()).toBe(90); + expect(root_child4.getComputedWidth()).toBe(357); + expect(root_child4.getComputedHeight()).toBe(220); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(320); + expect(root_child5.getComputedWidth()).toBe(600); + expect(root_child5.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(500); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(380); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(367); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(233); + expect(root_child3.getComputedHeight()).toBe(220); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(90); + expect(root_child4.getComputedWidth()).toBe(357); + expect(root_child4.getComputedHeight()).toBe(220); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(320); + expect(root_child5.getComputedWidth()).toBe(600); + expect(root_child5.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_overlapping_items', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(4); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + 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_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_implicit_rows', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + const rootGridAutoRows = []; + rootGridAutoRows.push({type: GridTrackType.Points, value: 80}); + root.setGridAutoRows(rootGridAutoRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(80); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(80); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(80); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(2); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.insertChild(root_child4, 4); + 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(260); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(80); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(180); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(80); + + 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(260); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(80); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(180); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_implicit_columns', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + const rootGridAutoColumns = []; + rootGridAutoColumns.push({type: GridTrackType.Points, value: 80}); + root.setGridAutoColumns(rootGridAutoColumns); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(80); + root_child2.setHeight(100); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(80); + root_child3.setHeight(100); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(80); + root_child4.setHeight(100); + root_child4.setGridColumnStart(3); + root_child4.setGridColumnEnd(4); + root_child4.setGridRowStart(1); + root_child4.setGridRowEnd(2); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(260); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(80); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(80); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(180); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(80); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(260); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(160); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(80); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(80); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(80); + expect(root_child4.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_complex_spanning', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(400); + root.setGap(Gutter.Column, 5); + root.setGap(Gutter.Row, 5); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight(100); + root_child1.setGridColumnStart(3); + root_child1.setGridColumnEnd(5); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(4); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root_child3.setGridColumnStart(4); + root_child3.setGridColumnEnd(5); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight("100%"); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(2); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(5); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(100); + root_child5.setHeight(100); + root_child5.setGridColumnStart(2); + root_child5.setGridColumnEnd(3); + root_child5.setGridRowStart(3); + root_child5.setGridRowEnd(4); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setWidth("100%"); + root_child6.setHeight(100); + root_child6.setGridColumnStart(2); + root_child6.setGridColumnEnd(5); + root_child6.setGridRowStart(4); + root_child6.setGridRowEnd(5); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root_child7.setWidth(100); + root_child7.setHeight(100); + root_child7.setGridColumnStart(4); + root_child7.setGridColumnEnd(5); + root_child7.setGridRowStart(3); + root_child7.setGridRowEnd(4); + root.insertChild(root_child7, 7); + 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(205); + expect(root_child0.getComputedHeight()).toBe(205); + + expect(root_child1.getComputedLeft()).toBe(210); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(205); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(210); + expect(root_child2.getComputedTop()).toBe(105); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(205); + + expect(root_child3.getComputedLeft()).toBe(315); + expect(root_child3.getComputedTop()).toBe(105); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(210); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(205); + + expect(root_child5.getComputedLeft()).toBe(105); + expect(root_child5.getComputedTop()).toBe(210); + expect(root_child5.getComputedWidth()).toBe(100); + expect(root_child5.getComputedHeight()).toBe(100); + + expect(root_child6.getComputedLeft()).toBe(105); + expect(root_child6.getComputedTop()).toBe(315); + expect(root_child6.getComputedWidth()).toBe(310); + expect(root_child6.getComputedHeight()).toBe(100); + + expect(root_child7.getComputedLeft()).toBe(315); + expect(root_child7.getComputedTop()).toBe(210); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(100); + + 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(195); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(205); + expect(root_child0.getComputedHeight()).toBe(205); + + expect(root_child1.getComputedLeft()).toBe(-15); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(205); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(105); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(205); + + expect(root_child3.getComputedLeft()).toBe(-15); + expect(root_child3.getComputedTop()).toBe(105); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(300); + expect(root_child4.getComputedTop()).toBe(210); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(205); + + expect(root_child5.getComputedLeft()).toBe(195); + expect(root_child5.getComputedTop()).toBe(210); + expect(root_child5.getComputedWidth()).toBe(100); + expect(root_child5.getComputedHeight()).toBe(100); + + expect(root_child6.getComputedLeft()).toBe(-15); + expect(root_child6.getComputedTop()).toBe(315); + expect(root_child6.getComputedWidth()).toBe(310); + expect(root_child6.getComputedHeight()).toBe(100); + + expect(root_child7.getComputedLeft()).toBe(-15); + expect(root_child7.getComputedTop()).toBe(210); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_sparse_placement', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root_child1.setGridColumnStart(3); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(3); + root_child2.setGridRowEnd(4); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root_child3.setGridColumnStart(4); + root_child3.setGridColumnEnd(5); + root_child3.setGridRowStart(1); + root_child3.setGridRowEnd(2); + root.insertChild(root_child3, 3); + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(200); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(300); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + 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(300); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(200); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_negative_line_numbers', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(-1); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight(100); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(-2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(-2); + root_child2.setGridColumnEnd(-1); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(-1); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(2); + root_child3.setGridRowStart(-2); + root_child3.setGridRowEnd(-1); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(200); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(200); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(200); + + expect(root_child3.getComputedLeft()).toBe(200); + expect(root_child3.getComputedTop()).toBe(200); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_all_fractional_units', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(600); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 3}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 2}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(4); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth("100%"); + root_child3.setHeight("100%"); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth("100%"); + root_child4.setHeight("100%"); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(2); + root_child4.setGridRowStart(3); + root_child4.setGridRowEnd(4); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth("100%"); + root_child5.setHeight("100%"); + root_child5.setGridColumnStart(2); + root_child5.setGridColumnEnd(3); + root_child5.setGridRowStart(3); + root_child5.setGridRowEnd(4); + root.insertChild(root_child5, 5); + 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(600); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(300); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(600); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(300); + expect(root_child3.getComputedHeight()).toBe(300); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(400); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(200); + + expect(root_child5.getComputedLeft()).toBe(100); + expect(root_child5.getComputedTop()).toBe(400); + expect(root_child5.getComputedWidth()).toBe(200); + expect(root_child5.getComputedHeight()).toBe(200); + + 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(600); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(600); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(300); + expect(root_child3.getComputedHeight()).toBe(300); + + expect(root_child4.getComputedLeft()).toBe(300); + expect(root_child4.getComputedTop()).toBe(400); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(200); + + expect(root_child5.getComputedLeft()).toBe(100); + expect(root_child5.getComputedTop()).toBe(400); + expect(root_child5.getComputedWidth()).toBe(200); + expect(root_child5.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_uniform_cells', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth("100%"); + root_child3.setHeight("100%"); + root_child3.setGridColumnStart(4); + root_child3.setGridColumnEnd(5); + root_child3.setGridRowStart(1); + root_child3.setGridRowEnd(2); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth("100%"); + root_child4.setHeight("100%"); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(2); + root_child4.setGridRowStart(2); + root_child4.setGridRowEnd(3); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth("100%"); + root_child5.setHeight("100%"); + root_child5.setGridColumnStart(2); + root_child5.setGridColumnEnd(3); + root_child5.setGridRowStart(2); + root_child5.setGridRowEnd(3); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setWidth("100%"); + root_child6.setHeight("100%"); + root_child6.setGridColumnStart(3); + root_child6.setGridColumnEnd(4); + root_child6.setGridRowStart(2); + root_child6.setGridRowEnd(3); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root_child7.setWidth("100%"); + root_child7.setHeight("100%"); + root_child7.setGridColumnStart(4); + root_child7.setGridColumnEnd(5); + root_child7.setGridRowStart(2); + root_child7.setGridRowEnd(3); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root_child8.setWidth("100%"); + root_child8.setHeight("100%"); + root_child8.setGridColumnStart(1); + root_child8.setGridColumnEnd(2); + root_child8.setGridRowStart(3); + root_child8.setGridRowEnd(4); + root.insertChild(root_child8, 8); + + const root_child9 = Yoga.Node.create(config); + root_child9.setWidth("100%"); + root_child9.setHeight("100%"); + root_child9.setGridColumnStart(2); + root_child9.setGridColumnEnd(3); + root_child9.setGridRowStart(3); + root_child9.setGridRowEnd(4); + root.insertChild(root_child9, 9); + + const root_child10 = Yoga.Node.create(config); + root_child10.setWidth("100%"); + root_child10.setHeight("100%"); + root_child10.setGridColumnStart(3); + root_child10.setGridColumnEnd(4); + root_child10.setGridRowStart(3); + root_child10.setGridRowEnd(4); + root.insertChild(root_child10, 10); + + const root_child11 = Yoga.Node.create(config); + root_child11.setWidth("100%"); + root_child11.setHeight("100%"); + root_child11.setGridColumnStart(4); + root_child11.setGridColumnEnd(5); + root_child11.setGridRowStart(3); + root_child11.setGridRowEnd(4); + root.insertChild(root_child11, 11); + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(300); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(100); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + expect(root_child5.getComputedLeft()).toBe(100); + expect(root_child5.getComputedTop()).toBe(100); + expect(root_child5.getComputedWidth()).toBe(100); + expect(root_child5.getComputedHeight()).toBe(100); + + expect(root_child6.getComputedLeft()).toBe(200); + expect(root_child6.getComputedTop()).toBe(100); + expect(root_child6.getComputedWidth()).toBe(100); + expect(root_child6.getComputedHeight()).toBe(100); + + expect(root_child7.getComputedLeft()).toBe(300); + expect(root_child7.getComputedTop()).toBe(100); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(100); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(200); + expect(root_child8.getComputedWidth()).toBe(100); + expect(root_child8.getComputedHeight()).toBe(100); + + expect(root_child9.getComputedLeft()).toBe(100); + expect(root_child9.getComputedTop()).toBe(200); + expect(root_child9.getComputedWidth()).toBe(100); + expect(root_child9.getComputedHeight()).toBe(100); + + expect(root_child10.getComputedLeft()).toBe(200); + expect(root_child10.getComputedTop()).toBe(200); + expect(root_child10.getComputedWidth()).toBe(100); + expect(root_child10.getComputedHeight()).toBe(100); + + expect(root_child11.getComputedLeft()).toBe(300); + expect(root_child11.getComputedTop()).toBe(200); + expect(root_child11.getComputedWidth()).toBe(100); + expect(root_child11.getComputedHeight()).toBe(100); + + 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(300); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(300); + expect(root_child4.getComputedTop()).toBe(100); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + expect(root_child5.getComputedLeft()).toBe(200); + expect(root_child5.getComputedTop()).toBe(100); + expect(root_child5.getComputedWidth()).toBe(100); + expect(root_child5.getComputedHeight()).toBe(100); + + expect(root_child6.getComputedLeft()).toBe(100); + expect(root_child6.getComputedTop()).toBe(100); + expect(root_child6.getComputedWidth()).toBe(100); + expect(root_child6.getComputedHeight()).toBe(100); + + expect(root_child7.getComputedLeft()).toBe(0); + expect(root_child7.getComputedTop()).toBe(100); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(100); + + expect(root_child8.getComputedLeft()).toBe(300); + expect(root_child8.getComputedTop()).toBe(200); + expect(root_child8.getComputedWidth()).toBe(100); + expect(root_child8.getComputedHeight()).toBe(100); + + expect(root_child9.getComputedLeft()).toBe(200); + expect(root_child9.getComputedTop()).toBe(200); + expect(root_child9.getComputedWidth()).toBe(100); + expect(root_child9.getComputedHeight()).toBe(100); + + expect(root_child10.getComputedLeft()).toBe(100); + expect(root_child10.getComputedTop()).toBe(200); + expect(root_child10.getComputedWidth()).toBe(100); + expect(root_child10.getComputedHeight()).toBe(100); + + expect(root_child11.getComputedLeft()).toBe(0); + expect(root_child11.getComputedTop()).toBe(200); + expect(root_child11.getComputedWidth()).toBe(100); + expect(root_child11.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_auto_placement_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(200); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_large_spans', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(250); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(50); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(6); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(5); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(6); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(5); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(150); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(150); + expect(root_child2.getComputedHeight()).toBe(150); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(150); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(150); + expect(root_child2.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_unequal_fractions', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 3}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(3); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth("100%"); + root_child3.setHeight("100%"); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(2); + root_child3.setGridRowEnd(3); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(300); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(400); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(300); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(200); + expect(root_child3.getComputedWidth()).toBe(400); + expect(root_child3.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(500); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(300); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(300); + + expect(root_child3.getComputedLeft()).toBe(200); + expect(root_child3.getComputedTop()).toBe(200); + expect(root_child3.getComputedWidth()).toBe(400); + expect(root_child3.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_single_cell', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 300}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(300); + root_child0.setHeight(200); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + 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(300); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_single_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(470); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 120}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(200); + root_child1.setHeight(150); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(200); + root_child2.setHeight(100); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEnd(2); + root_child2.setGridRowStart(3); + root_child2.setGridRowEnd(4); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(200); + root_child3.setHeight(120); + root_child3.setGridColumnStart(1); + root_child3.setGridColumnEnd(2); + root_child3.setGridRowStart(4); + root_child3.setGridRowEnd(5); + root.insertChild(root_child3, 3); + 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(470); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(150); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(250); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(350); + expect(root_child3.getComputedWidth()).toBe(200); + expect(root_child3.getComputedHeight()).toBe(120); + + 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(470); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(150); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(250); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(350); + expect(root_child3.getComputedWidth()).toBe(200); + expect(root_child3.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_single_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(470); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 120}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(200); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(150); + root_child1.setHeight(200); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(200); + root_child2.setGridColumnStart(3); + root_child2.setGridColumnEnd(4); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(120); + root_child3.setHeight(200); + root_child3.setGridColumnStart(4); + root_child3.setGridColumnEnd(5); + root_child3.setGridRowStart(1); + root_child3.setGridRowEnd(2); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(470); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(250); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(200); + + expect(root_child3.getComputedLeft()).toBe(350); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(120); + expect(root_child3.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(470); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(370); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(220); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(200); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(120); + expect(root_child3.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_tall_narrow', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 50}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(5); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(50); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(3); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(50); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(3); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(100); + root_child3.setHeight(50); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(3); + root_child3.setGridRowStart(3); + root_child3.setGridRowEnd(4); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(50); + root_child4.setGridColumnStart(2); + root_child4.setGridColumnEnd(3); + root_child4.setGridRowStart(4); + root_child4.setGridRowEnd(5); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth("100%"); + root_child5.setHeight("100%"); + root_child5.setGridColumnStart(1); + root_child5.setGridColumnEnd(3); + root_child5.setGridRowStart(5); + root_child5.setGridRowEnd(9); + root.insertChild(root_child5, 5); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(150); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(50); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(200); + expect(root_child5.getComputedWidth()).toBe(200); + expect(root_child5.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(400); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(150); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(50); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(200); + expect(root_child5.getComputedWidth()).toBe(200); + expect(root_child5.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_wide_short', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 50}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(5); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight("100%"); + root_child1.setGridColumnStart(5); + root_child1.setGridColumnEnd(6); + root_child1.setGridRowStart(1); + root_child1.setGridRowEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(100); + root_child2.setGridColumnStart(6); + root_child2.setGridColumnEnd(7); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(2); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(100); + root_child3.setGridColumnStart(7); + root_child3.setGridColumnEnd(8); + root_child3.setGridRowStart(1); + root_child3.setGridRowEnd(2); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(100); + root_child4.setGridColumnStart(8); + root_child4.setGridColumnEnd(9); + root_child4.setGridRowStart(1); + root_child4.setGridRowEnd(2); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth("100%"); + root_child5.setHeight(100); + root_child5.setGridColumnStart(1); + root_child5.setGridColumnEnd(5); + root_child5.setGridRowStart(2); + root_child5.setGridRowEnd(3); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setWidth("100%"); + root_child6.setHeight(100); + root_child6.setGridColumnStart(6); + root_child6.setGridColumnEnd(9); + root_child6.setGridRowStart(2); + root_child6.setGridRowEnd(3); + root.insertChild(root_child6, 6); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(250); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(300); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(350); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(100); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(100); + expect(root_child5.getComputedWidth()).toBe(200); + expect(root_child5.getComputedHeight()).toBe(100); + + expect(root_child6.getComputedLeft()).toBe(250); + expect(root_child6.getComputedTop()).toBe(100); + expect(root_child6.getComputedWidth()).toBe(150); + expect(root_child6.getComputedHeight()).toBe(100); + + 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(200); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(100); + + expect(root_child5.getComputedLeft()).toBe(200); + expect(root_child5.getComputedTop()).toBe(100); + expect(root_child5.getComputedWidth()).toBe(200); + expect(root_child5.getComputedHeight()).toBe(100); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(100); + expect(root_child6.getComputedWidth()).toBe(150); + expect(root_child6.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_gap_percentage_definite_size_2', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 1); + root.setBorder(Edge.Top, 1); + root.setBorder(Edge.Right, 1); + root.setBorder(Edge.Bottom, 1); + root.setGap(Gutter.Column, "70%"); + root.setGap(Gutter.Row, "40%"); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 10}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 10}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 10}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 20); + root_child0.setPadding(Edge.Top, 20); + root_child0.setPadding(Edge.Right, 20); + root_child0.setPadding(Edge.Bottom, 20); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 20); + root_child1.setPadding(Edge.Top, 20); + root_child1.setPadding(Edge.Right, 20); + root_child1.setPadding(Edge.Bottom, 20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPadding(Edge.Left, 20); + root_child2.setPadding(Edge.Top, 20); + root_child2.setPadding(Edge.Right, 20); + root_child2.setPadding(Edge.Bottom, 20); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(5); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(82); + expect(root.getComputedHeight()).toBe(82); + + expect(root_child0.getComputedLeft()).toBe(1); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(128); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(185); + expect(root_child1.getComputedTop()).toBe(1); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(57); + expect(root_child2.getComputedTop()).toBe(73); + expect(root_child2.getComputedWidth()).toBe(136); + expect(root_child2.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(82); + expect(root.getComputedHeight()).toBe(82); + + expect(root_child0.getComputedLeft()).toBe(-47); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(128); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(-143); + expect(root_child1.getComputedTop()).toBe(1); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(-111); + expect(root_child2.getComputedTop()).toBe(73); + expect(root_child2.getComputedWidth()).toBe(136); + expect(root_child2.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/YGGridTestFlows.test.ts b/javascript/tests/generated/YGGridTestFlows.test.ts new file mode 100644 index 0000000000..e71cbf25a5 --- /dev/null +++ b/javascript/tests/generated/YGGridTestFlows.test.ts @@ -0,0 +1,7113 @@ +/** + * 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 SignedSource<<2d459212a686054177c006fa40e47fa7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGridTestFlows.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_indefinite_container_size_percentage_tracks', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 80}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPadding(Edge.Left, 30); + root_child2.setPadding(Edge.Top, 30); + root_child2.setPadding(Edge.Right, 30); + root_child2.setPadding(Edge.Bottom, 30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setMinWidth(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setBorder(Edge.Left, 10); + root_child4.setBorder(Edge.Top, 10); + root_child4.setBorder(Edge.Right, 10); + root_child4.setBorder(Edge.Bottom, 10); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(260); + 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); + + expect(root_child1.getComputedLeft()).toBe(104); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(234); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(260); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(104); + expect(root_child3.getComputedHeight()).toBe(80); + + expect(root_child4.getComputedLeft()).toBe(104); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(130); + expect(root_child4.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(260); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(56); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-234); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(260); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(156); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(104); + expect(root_child3.getComputedHeight()).toBe(80); + + expect(root_child4.getComputedLeft()).toBe(26); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(130); + expect(root_child4.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_definite_container_size_percentage_tracks', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + root.setGap(Gutter.Column, "20%"); + root.setGap(Gutter.Row, "10%"); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 50}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 80}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMinWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPadding(Edge.Left, 40); + root_child2.setPadding(Edge.Top, 40); + root_child2.setPadding(Edge.Right, 40); + root_child2.setPadding(Edge.Bottom, 40); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setMargin(Edge.Left, "10%"); + root_child3.setMargin(Edge.Top, "10%"); + root_child3.setMargin(Edge.Right, "10%"); + root_child3.setMargin(Edge.Bottom, "10%"); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(180); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(390); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(300); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(12); + expect(root_child3.getComputedTop()).toBe(122); + expect(root_child3.getComputedWidth()).toBe(96); + expect(root_child3.getComputedHeight()).toBe(216); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(-30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(-390); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(300); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(192); + expect(root_child3.getComputedTop()).toBe(122); + expect(root_child3.getComputedWidth()).toBe(96); + expect(root_child3.getComputedHeight()).toBe(216); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('init_track_fixed_sizing', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 120}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(300); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(150); + expect(root_child2.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(400); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(150); + expect(root_child2.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('init_track_intrinsic_sizing', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(150); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(70); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(250); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(70); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(400); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(130); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(70); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('init_track_flexible_sizing', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(300); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + 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(200); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('init_track_mixed_sizing', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(80); + root_child1.setHeight(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(140); + expect(root_child2.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(500); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(420); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(280); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(140); + expect(root_child2.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('resolve_intrinsic_single_span', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(120); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(140); + root_child2.setHeight(70); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(110); + root_child3.setHeight(85); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(130); + root_child4.setHeight(95); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(390); + expect(root.getComputedHeight()).toBe(185); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(250); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(140); + expect(root_child2.getComputedHeight()).toBe(70); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(110); + expect(root_child3.getComputedHeight()).toBe(85); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(90); + expect(root_child4.getComputedWidth()).toBe(130); + expect(root_child4.getComputedHeight()).toBe(95); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(390); + expect(root.getComputedHeight()).toBe(185); + + expect(root_child0.getComputedLeft()).toBe(270); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(170); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(140); + expect(root_child2.getComputedHeight()).toBe(70); + + expect(root_child3.getComputedLeft()).toBe(280); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(110); + expect(root_child3.getComputedHeight()).toBe(85); + + expect(root_child4.getComputedLeft()).toBe(140); + expect(root_child4.getComputedTop()).toBe(90); + expect(root_child4.getComputedWidth()).toBe(130); + expect(root_child4.getComputedHeight()).toBe(95); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('resolve_intrinsic_multi_span', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(250); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(80); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(110); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(300); + root_child3.setHeight(120); + root_child3.setGridColumnStart(2); + root_child3.setGridColumnEnd(4); + root.insertChild(root_child3, 3); + 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(220); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(320); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(110); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(300); + expect(root_child3.getComputedHeight()).toBe(120); + + 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(220); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(300); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(110); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(300); + expect(root_child3.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('resolve_intrinsic_flexible_tracks', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(300); + root_child0.setHeight(80); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + 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(190); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(300); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(100); + + 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(190); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(280); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('resolve_intrinsic_progressive_spans', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(110); + root_child1.setHeight(85); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(90); + root_child2.setHeight(75); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(105); + root_child3.setHeight(82); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(250); + root_child4.setHeight(90); + root_child4.setGridColumnStart(1); + root_child4.setGridColumnEnd(3); + root_child4.setGridRowStart(2); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(230); + root_child5.setHeight(95); + root_child5.setGridColumnStart(3); + root_child5.setGridColumnEnd(5); + root_child5.setGridRowStart(2); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setWidth(380); + root_child6.setHeight(100); + root_child6.setGridColumnStart(1); + root_child6.setGridColumnEnd(4); + root_child6.setGridRowStart(3); + root.insertChild(root_child6, 6); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(508); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(131); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(110); + expect(root_child1.getComputedHeight()).toBe(85); + + expect(root_child2.getComputedLeft()).toBe(272); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(90); + expect(root_child2.getComputedHeight()).toBe(75); + + expect(root_child3.getComputedLeft()).toBe(390); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(105); + expect(root_child3.getComputedHeight()).toBe(82); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(95); + expect(root_child4.getComputedWidth()).toBe(250); + expect(root_child4.getComputedHeight()).toBe(90); + + expect(root_child5.getComputedLeft()).toBe(272); + expect(root_child5.getComputedTop()).toBe(95); + expect(root_child5.getComputedWidth()).toBe(230); + expect(root_child5.getComputedHeight()).toBe(95); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(200); + expect(root_child6.getComputedWidth()).toBe(380); + expect(root_child6.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(508); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(408); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(267); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(110); + expect(root_child1.getComputedHeight()).toBe(85); + + expect(root_child2.getComputedLeft()).toBe(146); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(90); + expect(root_child2.getComputedHeight()).toBe(75); + + expect(root_child3.getComputedLeft()).toBe(13); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(105); + expect(root_child3.getComputedHeight()).toBe(82); + + expect(root_child4.getComputedLeft()).toBe(258); + expect(root_child4.getComputedTop()).toBe(95); + expect(root_child4.getComputedWidth()).toBe(250); + expect(root_child4.getComputedHeight()).toBe(90); + + expect(root_child5.getComputedLeft()).toBe(6); + expect(root_child5.getComputedTop()).toBe(95); + expect(root_child5.getComputedWidth()).toBe(230); + expect(root_child5.getComputedHeight()).toBe(95); + + expect(root_child6.getComputedLeft()).toBe(128); + expect(root_child6.getComputedTop()).toBe(200); + expect(root_child6.getComputedWidth()).toBe(380); + expect(root_child6.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('maximize_tracks_definite_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(110); + root_child2.setHeight(85); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(220); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(85); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(400); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(280); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(170); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(85); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('maximize_tracks_max_constraint', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMaxWidth(400); + root.setMaxHeight(250); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(160); + root_child1.setHeight(110); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(170); + root_child2.setHeight(105); + root.insertChild(root_child2, 2); + 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(110); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(160); + expect(root_child1.getComputedHeight()).toBe(110); + + expect(root_child2.getComputedLeft()).toBe(310); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(170); + expect(root_child2.getComputedHeight()).toBe(105); + + 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(110); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(160); + expect(root_child1.getComputedHeight()).toBe(110); + + expect(root_child2.getComputedLeft()).toBe(-80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(170); + expect(root_child2.getComputedHeight()).toBe(105); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('expand_flexible_definite_free_space', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(133); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(233); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(267); + expect(root_child2.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(500); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(367); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(133); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(267); + expect(root_child2.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('expand_flexible_min_constraint', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(600); + root.setMinHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(60); + root_child1.setHeight(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(55); + root_child2.setHeight(55); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(450); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(55); + expect(root_child2.getComputedHeight()).toBe(55); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(550); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(390); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(95); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(55); + expect(root_child2.getComputedHeight()).toBe(55); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('expand_flexible_max_constraint', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(800); + root.setMaxWidth(500); + root.setHeight(600); + root.setMaxHeight(350); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(350); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(125); + expect(root_child0.getComputedHeight()).toBe(175); + + expect(root_child1.getComputedLeft()).toBe(125); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(175); + + expect(root_child2.getComputedLeft()).toBe(375); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(125); + expect(root_child2.getComputedHeight()).toBe(175); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(350); + + expect(root_child0.getComputedLeft()).toBe(375); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(125); + expect(root_child0.getComputedHeight()).toBe(175); + + expect(root_child1.getComputedLeft()).toBe(125); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(175); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(125); + expect(root_child2.getComputedHeight()).toBe(175); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('expand_flexible_flex_less_than_one', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0.5}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0.3}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0.2}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 0.6}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 0.4}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(180); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(180); + + expect(root_child2.getComputedLeft()).toBe(320); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(80); + expect(root_child2.getComputedHeight()).toBe(180); + + 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(300); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(180); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(180); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(80); + expect(root_child2.getComputedHeight()).toBe(180); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('expand_flexible_spanning_items', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(450); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(450); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(450); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(200); + expect(root_child2.getComputedWidth()).toBe(225); + expect(root_child2.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(450); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(375); + expect(root_child2.getComputedTop()).toBe(200); + expect(root_child2.getComputedWidth()).toBe(225); + expect(root_child2.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('stretch_auto_justify_content_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(110); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(190); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(400); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(500); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(290); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('stretch_auto_align_content_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(600); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight(120); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight(110); + root.insertChild(root_child2, 2); + 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(600); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(120); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(243); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(110); + + 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(600); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(120); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(243); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(110); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('stretch_auto_both_axes', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Stretch); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(110); + root_child2.setHeight(85); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(190); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(400); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(85); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(500); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(290); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(85); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(300); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_space_between', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + 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); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(400); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(400); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(33); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(367); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(367); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(33); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_space_evenly', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(350); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(350); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Start); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(200); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(200); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.End); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(200); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(300); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(400); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(200); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(300); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(400); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(300); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(300); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_between', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(400); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(400); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(33); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(367); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(33); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(367); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(350); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(350); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_self_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Start); + root_child0.setWidth(100); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setJustifySelf(Justify.Start); + root_child1.setWidth(100); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + 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(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); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_self_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.End); + root_child0.setWidth(100); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setJustifySelf(Justify.End); + root_child1.setWidth(100); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(300); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_self_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Center); + root_child0.setWidth(100); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setJustifySelf(Justify.Center); + root_child1.setWidth(100); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_self_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Stretch); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setJustifySelf(Justify.Stretch); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_self_auto_margin_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setWidth(100); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Left, 'auto'); + root_child1.setWidth(100); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(300); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_self_auto_margin_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(100); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Right, 'auto'); + root_child1.setWidth(100); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + 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(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); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_self_auto_margin_both', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(100); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Left, 'auto'); + root_child1.setMargin(Edge.Right, 'auto'); + root_child1.setWidth(100); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_self_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Start); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setAlignSelf(Align.Start); + root_child1.setWidth("100%"); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_self_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.End); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setAlignSelf(Align.End); + root_child1.setWidth("100%"); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(300); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(300); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_align_self_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Center); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setAlignSelf(Align.Center); + root_child1.setWidth("100%"); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_align_self_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root.insertChild(root_child1, 1); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(200); + + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_self_auto_margin_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Top, 'auto'); + root_child1.setWidth("100%"); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(300); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(300); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_self_auto_margin_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Bottom, 'auto'); + root_child1.setWidth("100%"); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_self_auto_margin_both', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth("100%"); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Top, 'auto'); + root_child1.setMargin(Edge.Bottom, 'auto'); + root_child1.setWidth("100%"); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('minimum_contribution_auto', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(120); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(150); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(270); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(90); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(270); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(90); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('minimum_contribution_definite', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(120); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(150); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(270); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(90); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(270); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(90); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('minimum_contribution_percentage_definite', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("30%"); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("40%"); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(90); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(500); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(500); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(90); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('minimum_contribution_min_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(120); + root_child0.setMinWidth(150); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setMinWidth(180); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(330); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(180); + expect(root_child1.getComputedHeight()).toBe(90); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(330); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(180); + expect(root_child1.getComputedHeight()).toBe(90); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('content_based_min_definite_length', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(180); + root_child1.setHeight(120); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(330); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(180); + expect(root_child1.getComputedHeight()).toBe(120); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(330); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(180); + expect(root_child1.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('content_based_min_aspect_ratio', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setAspectRatio(2 / 1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(100); + root_child1.setAspectRatio(0.5 / 1); + root.insertChild(root_child1, 1); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.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(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('content_based_min_content_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 20); + root_child0.setPadding(Edge.Top, 20); + root_child0.setPadding(Edge.Right, 20); + root_child0.setPadding(Edge.Bottom, 20); + root_child0.setWidth(100); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 15); + root_child1.setPadding(Edge.Top, 15); + root_child1.setPadding(Edge.Right, 15); + root_child1.setPadding(Edge.Bottom, 15); + root_child1.setWidth(120); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(90); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(120); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(90); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('content_based_min_fixed_track_clamp', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(300); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(250); + root_child1.setHeight(120); + root.insertChild(root_child1, 1); + 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(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(120); + + 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(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(-50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('content_based_min_span_fixed_max', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(500); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(120); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(470); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(320); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(120); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(470); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(-30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('max_content_contribution_basic', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(180); + root_child1.setHeight(120); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(330); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(180); + expect(root_child1.getComputedHeight()).toBe(120); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(330); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(180); + expect(root_child1.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('max_content_contribution_margins', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 10); + root_child0.setMargin(Edge.Top, 10); + root_child0.setMargin(Edge.Right, 10); + root_child0.setMargin(Edge.Bottom, 10); + root_child0.setWidth(150); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Left, 15); + root_child1.setMargin(Edge.Top, 15); + root_child1.setMargin(Edge.Right, 15); + root_child1.setMargin(Edge.Bottom, 15); + root_child1.setWidth(180); + root_child1.setHeight(120); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(380); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(185); + expect(root_child1.getComputedTop()).toBe(15); + expect(root_child1.getComputedWidth()).toBe(180); + expect(root_child1.getComputedHeight()).toBe(120); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(380); + expect(root.getComputedHeight()).toBe(150); + + expect(root_child0.getComputedLeft()).toBe(220); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(15); + expect(root_child1.getComputedTop()).toBe(15); + expect(root_child1.getComputedWidth()).toBe(180); + expect(root_child1.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('limited_min_content_fixed_limit', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(120); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(310); + expect(root.getComputedHeight()).toBe(230); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(120); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(310); + expect(root.getComputedHeight()).toBe(230); + + expect(root_child0.getComputedLeft()).toBe(-90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(210); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('limited_min_content_no_limit', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(120); + root.insertChild(root_child1, 1); + 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(230); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(120); + + 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(230); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(300); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_tracks_definite_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 50}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 60}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(160); + + expect(root_child2.getComputedLeft()).toBe(250); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(250); + expect(root_child2.getComputedHeight()).toBe(160); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(400); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(160); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(250); + expect(root_child2.getComputedHeight()).toBe(160); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_tracks_indefinite_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(80); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(120); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(110); + root_child2.setHeight(85); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(330); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(66); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(165); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(85); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(330); + expect(root.getComputedHeight()).toBe(90); + + expect(root_child0.getComputedLeft()).toBe(230); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(144); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(55); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(85); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_tracks_mixed_fixed', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(400); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(250); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(80); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(400); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(250); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_gap_definite_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "20%"); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(210); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(420); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(150); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(450); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(240); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(150); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('spanning_items_span_2', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(250); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(110); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(480); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(260); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(370); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(480); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(230); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('spanning_items_span_3', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(380); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(490); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(380); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(390); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(490); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(110); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(380); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('spanning_items_overlapping', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(250); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(280); + root_child1.setHeight(120); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEnd(4); + root_child1.setGridRowStart(2); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(420); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(130); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(280); + expect(root_child1.getComputedHeight()).toBe(120); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(420); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(170); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(280); + expect(root_child1.getComputedHeight()).toBe(120); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('spanning_items_both_axes', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(250); + root_child0.setHeight(230); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(110); + root_child2.setHeight(110); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(370); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(230); + + expect(root_child1.getComputedLeft()).toBe(260); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(260); + expect(root_child2.getComputedTop()).toBe(115); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(110); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(370); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(120); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(230); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(115); + expect(root_child2.getComputedWidth()).toBe(110); + expect(root_child2.getComputedHeight()).toBe(110); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_margins_inline_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 300}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setWidth(150); + 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(300); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + 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(300); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_margins_inline_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 300}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(150); + 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(300); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + 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(300); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_margins_inline_both', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 300}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(150); + 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(300); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + 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(300); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_margins_block_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 300}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setWidth("100%"); + root_child0.setHeight(150); + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(150); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(150); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_margins_block_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 300}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth("100%"); + root_child0.setHeight(150); + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_margins_block_both', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 300}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth("100%"); + root_child0.setHeight(150); + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_margins_overrides_justify_self', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 300}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Start); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setWidth(150); + 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(300); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + 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(300); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_margins_overrides_align_self', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 300}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Start); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setWidth("100%"); + root_child0.setHeight(150); + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(150); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(150); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('min_max_constraints_min_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(80); + root_child0.setMinWidth(150); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(90); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(90); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(90); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('min_max_constraints_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setMaxWidth(120); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(280); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('min_max_constraints_min_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight(80); + root_child0.setMinHeight(150); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight(90); + root.insertChild(root_child1, 1); + 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(240); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(90); + + 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(240); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(90); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('min_max_constraints_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root_child0.setMaxHeight(120); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(200); + + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('min_max_constraints_both', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(80); + root_child0.setMinWidth(100); + root_child0.setMaxWidth(150); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(200); + root_child1.setMinWidth(100); + root_child1.setMaxWidth(130); + root_child1.setHeight(100); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(230); + 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); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(130); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(230); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(130); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(130); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('gaps_justify_space_between', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(100); + root.setGap(Gutter.Column, 20); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + 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); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(400); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(400); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('gaps_align_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(500); + root.setGap(Gutter.Row, 20); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(27); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(373); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(27); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(373); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('gaps_both_space_evenly', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceEvenly); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + root.setGap(Gutter.Column, 15); + root.setGap(Gutter.Row, 15); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(43); + expect(root_child0.getComputedTop()).toBe(43); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(43); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(358); + expect(root_child2.getComputedTop()).toBe(43); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(358); + expect(root_child0.getComputedTop()).toBe(43); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(43); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(43); + expect(root_child2.getComputedTop()).toBe(43); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('gaps_spanning_items', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 20); + root.setGap(Gutter.Row, 20); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(4); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(340); + expect(root.getComputedHeight()).toBe(340); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(220); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(240); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(120); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(220); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(340); + expect(root.getComputedHeight()).toBe(340); + + expect(root_child0.getComputedLeft()).toBe(120); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(220); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(240); + expect(root_child2.getComputedTop()).toBe(120); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(220); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('complex_flexible_min_max_distribution', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setMinWidth(400); + root.setMaxWidth(800); + root.setHeight(400); + root.setGap(Gutter.Column, 15); + root.setGap(Gutter.Row, 15); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + root_child0.setMinWidth(150); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("100%"); + root_child1.setMaxWidth(250); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight("100%"); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(193); + + expect(root_child1.getComputedLeft()).toBe(165); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(193); + + expect(root_child2.getComputedLeft()).toBe(460); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(140); + expect(root_child2.getComputedHeight()).toBe(193); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(450); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(193); + + expect(root_child1.getComputedLeft()).toBe(185); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + expect(root_child1.getComputedHeight()).toBe(193); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(140); + expect(root_child2.getComputedHeight()).toBe(193); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('complex_all_features_combined', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceEvenly); + root.setJustifyItems(Justify.Center); + root.setAlignContent(Align.SpaceBetween); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(800); + root.setHeight(600); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Start); + root_child0.setAlignSelf(Align.End); + root_child0.setMargin(Edge.Left, 20); + root_child0.setWidth(350); + root_child0.setHeight(180); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(150); + root_child1.setMaxHeight(100); + root_child1.setAspectRatio(2 / 1); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setMinWidth(200); + root_child2.setMaxWidth(300); + root_child2.setHeight("100%"); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(4); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setMargin(Edge.Left, 'auto'); + root_child3.setMargin(Edge.Top, 'auto'); + root_child3.setMargin(Edge.Right, 'auto'); + root_child3.setMargin(Edge.Bottom, 'auto'); + root_child3.setAspectRatio(1 / 1); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setJustifySelf(Justify.Stretch); + root_child4.setAlignSelf(Align.Stretch); + root_child4.setWidth("100%"); + root_child4.setHeight("100%"); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(800); + expect(root.getComputedHeight()).toBe(600); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(350); + expect(root_child0.getComputedHeight()).toBe(180); + + expect(root_child1.getComputedLeft()).toBe(390); + expect(root_child1.getComputedTop()).toBe(3); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(75); + + expect(root_child2.getComputedLeft()).toBe(110); + expect(root_child2.getComputedTop()).toBe(190); + expect(root_child2.getComputedWidth()).toBe(260); + expect(root_child2.getComputedHeight()).toBe(160); + + expect(root_child3.getComputedLeft()).toBe(465); + expect(root_child3.getComputedTop()).toBe(270); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(560); + expect(root_child4.getComputedTop()).toBe(190); + expect(root_child4.getComputedWidth()).toBe(240); + expect(root_child4.getComputedHeight()).toBe(160); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(800); + expect(root.getComputedHeight()).toBe(600); + + expect(root_child0.getComputedLeft()).toBe(450); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(350); + expect(root_child0.getComputedHeight()).toBe(180); + + expect(root_child1.getComputedLeft()).toBe(260); + expect(root_child1.getComputedTop()).toBe(3); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(75); + + expect(root_child2.getComputedLeft()).toBe(430); + expect(root_child2.getComputedTop()).toBe(190); + expect(root_child2.getComputedWidth()).toBe(260); + expect(root_child2.getComputedHeight()).toBe(160); + + expect(root_child3.getComputedLeft()).toBe(335); + expect(root_child3.getComputedTop()).toBe(270); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(190); + expect(root_child4.getComputedWidth()).toBe(240); + expect(root_child4.getComputedHeight()).toBe(160); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_absolute_position_items', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPositionType(PositionType.Absolute); + root_child2.setPosition(Edge.Left, 50); + root_child2.setPosition(Edge.Top, 10); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setPositionType(PositionType.Absolute); + root_child3.setPosition(Edge.Left, 80); + root_child3.setPosition(Edge.Top, 10); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_display_none_items', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root_child1.setDisplay(Display.None); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('grid_item_with_display_contents_items', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setBorder(Edge.Left, 2); + root_child1.setBorder(Edge.Top, 2); + root_child1.setBorder(Edge.Right, 2); + root_child1.setBorder(Edge.Bottom, 2); + root_child1.setDisplay(Display.Contents); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(100); + root_child1_child0.setHeight(100); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child1_child0.getComputedLeft()).toBe(100); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(100); + expect(root_child1_child0.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child1_child0.getComputedLeft()).toBe(100); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(100); + expect(root_child1_child0.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('text_wraps_in_fixed_sized_column_tracks', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur", flexDirection: FlexDirection.Column})); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + 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(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.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(50); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('text_wraps_in_fixed_sized_column_tracks_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMaxWidth(50); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur", flexDirection: FlexDirection.Column})); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + 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(60); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(60); + + 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(60); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('text_wraps_in_fixed_sized_column_tracks_min_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setMinWidth(180); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "Lorem ipsum dolor sit amet, consectetur", flexDirection: FlexDirection.Column})); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + 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(30); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(180); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(30); + + 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(30); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(180); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(30); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/YGIntrinsicSizeTest.test.ts b/javascript/tests/generated/YGIntrinsicSizeTest.test.ts index cb4e2740d4..25c0825c95 100644 --- a/javascript/tests/generated/YGIntrinsicSizeTest.test.ts +++ b/javascript/tests/generated/YGIntrinsicSizeTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3f04f55b43e5a47ed2f33485e63ac039>> + * @generated SignedSource<<2217aa3664092b73365855032e35f6a6>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGIntrinsicSizeTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGJustifyContentTest.test.ts b/javascript/tests/generated/YGJustifyContentTest.test.ts index 63f814f1a2..3c9588de78 100644 --- a/javascript/tests/generated/YGJustifyContentTest.test.ts +++ b/javascript/tests/generated/YGJustifyContentTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGJustifyContentTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGMarginTest.test.ts b/javascript/tests/generated/YGMarginTest.test.ts index 8046de55d0..8cce28e0e1 100644 --- a/javascript/tests/generated/YGMarginTest.test.ts +++ b/javascript/tests/generated/YGMarginTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3a4aaa192f950239104218a9666654c1>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMarginTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts b/javascript/tests/generated/YGMinMaxDimensionTest.test.ts index dfe3773f5e..66562577ad 100644 --- a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts +++ b/javascript/tests/generated/YGMinMaxDimensionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<1bd782301afbab34ed3c9a296c3ecaa6>> + * @generated SignedSource<<176c24534db638bb3cd82db0b622e46f>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGPaddingTest.test.ts b/javascript/tests/generated/YGPaddingTest.test.ts index 474a80821e..ba1076aed1 100644 --- a/javascript/tests/generated/YGPaddingTest.test.ts +++ b/javascript/tests/generated/YGPaddingTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<07e65137c3055db0090d46067ec69d5e>> + * @generated SignedSource<<5c511f68cad541d18b25ad5a13c4a332>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGPaddingTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGPercentageTest.test.ts b/javascript/tests/generated/YGPercentageTest.test.ts index 4f95fb28cb..222dd45933 100644 --- a/javascript/tests/generated/YGPercentageTest.test.ts +++ b/javascript/tests/generated/YGPercentageTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<091fb5c6d9004e40211bba58ac19d686>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGRoundingTest.test.ts b/javascript/tests/generated/YGRoundingTest.test.ts index ca653f138c..a7125a5e91 100644 --- a/javascript/tests/generated/YGRoundingTest.test.ts +++ b/javascript/tests/generated/YGRoundingTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<8119d2703019b25513720167cb4dea4e>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGRoundingTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGSizeOverflowTest.test.ts b/javascript/tests/generated/YGSizeOverflowTest.test.ts index 325dd26db1..f143d08b20 100644 --- a/javascript/tests/generated/YGSizeOverflowTest.test.ts +++ b/javascript/tests/generated/YGSizeOverflowTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGSizeOverflowTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/YGStaticPositionTest.test.ts b/javascript/tests/generated/YGStaticPositionTest.test.ts index 0c2bd37327..cee342889a 100644 --- a/javascript/tests/generated/YGStaticPositionTest.test.ts +++ b/javascript/tests/generated/YGStaticPositionTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html */ @@ -19,6 +19,7 @@ import { Errata, ExperimentalFeature, FlexDirection, + GridTrackType, Gutter, Justify, MeasureMode, diff --git a/javascript/tests/generated/absolute_correct_cross_child_size_with_percentage.test.ts b/javascript/tests/generated/absolute_correct_cross_child_size_with_percentage.test.ts new file mode 100644 index 0000000000..9f7017bc51 --- /dev/null +++ b/javascript/tests/generated/absolute_correct_cross_child_size_with_percentage.test.ts @@ -0,0 +1,137 @@ +/** + * 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 SignedSource<<08e1515e2ab2e361163fc0f34ba2de21>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/absolute_correct_cross_child_size_with_percentage.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('absolute_correct_cross_child_size_with_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setWidth(300); + root.setHeight(110); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 50); + root_child0.setPosition(Edge.Top, 40); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("100%"); + root_child0_child1.setHeight(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("100%"); + root_child0_child2.setHeight(10); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child2_child0.setWidth(10); + root_child0_child2_child0.setHeight(10); + root_child0_child2.insertChild(root_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(10); + expect(root_child0_child1.getComputedWidth()).toBe(200); + expect(root_child0_child1.getComputedHeight()).toBe(10); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(200); + expect(root_child0_child2.getComputedHeight()).toBe(10); + + expect(root_child0_child2_child0.getComputedLeft()).toBe(0); + expect(root_child0_child2_child0.getComputedTop()).toBe(0); + expect(root_child0_child2_child0.getComputedWidth()).toBe(10); + expect(root_child0_child2_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(10); + expect(root_child0_child1.getComputedWidth()).toBe(200); + expect(root_child0_child1.getComputedHeight()).toBe(10); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(200); + expect(root_child0_child2.getComputedHeight()).toBe(10); + + expect(root_child0_child2_child0.getComputedLeft()).toBe(190); + expect(root_child0_child2_child0.getComputedTop()).toBe(0); + expect(root_child0_child2_child0.getComputedWidth()).toBe(10); + expect(root_child0_child2_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/chrome_issue_325928327.test.ts b/javascript/tests/generated/chrome_issue_325928327.test.ts new file mode 100644 index 0000000000..08cec16eea --- /dev/null +++ b/javascript/tests/generated/chrome_issue_325928327.test.ts @@ -0,0 +1,105 @@ +/** + * 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 SignedSource<<30cb9af5c1c2eb5587e7addcfde42958>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/chrome_issue_325928327.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('chrome_issue_325928327_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyItems(Justify.Center); + root_child0.setWidth("100%"); + root_child0.setHeight(40); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + 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.setHeight("100%"); + root_child0_child0_child0.setAspectRatio(1 / 1); + 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(0); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_align_self_sized_all.test.ts b/javascript/tests/generated/grid_absolute_align_self_sized_all.test.ts new file mode 100644 index 0000000000..2bdde90611 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_align_self_sized_all.test.ts @@ -0,0 +1,206 @@ +/** + * 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 SignedSource<<1551b6410817b181d2978719201dedc3>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_align_self_sized_all.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_align_self_sized_all', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Start); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setAlignSelf(Align.Start); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setWidth(60); + root_child1.setHeight(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setAlignSelf(Align.End); + root_child2.setPositionType(PositionType.Absolute); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setAlignSelf(Align.End); + root_child3.setPositionType(PositionType.Absolute); + root_child3.setWidth(60); + root_child3.setHeight(60); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setAlignSelf(Align.Center); + root_child4.setPositionType(PositionType.Absolute); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setAlignSelf(Align.Center); + root_child5.setPositionType(PositionType.Absolute); + root_child5.setWidth(60); + root_child5.setHeight(60); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setPositionType(PositionType.Absolute); + root_child6.setWidth(20); + root_child6.setHeight(20); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root_child7.setPositionType(PositionType.Absolute); + root_child7.setWidth(60); + root_child7.setHeight(60); + root.insertChild(root_child7, 7); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(60); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(30); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(0); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(0); + expect(root_child7.getComputedTop()).toBe(0); + expect(root_child7.getComputedWidth()).toBe(60); + expect(root_child7.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(60); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(30); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(100); + expect(root_child6.getComputedTop()).toBe(0); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(60); + expect(root_child7.getComputedTop()).toBe(0); + expect(root_child7.getComputedWidth()).toBe(60); + expect(root_child7.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_bottom_left.test.ts b/javascript/tests/generated/grid_absolute_container_bottom_left.test.ts new file mode 100644 index 0000000000..7ccc53bc5c --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_bottom_left.test.ts @@ -0,0 +1,194 @@ +/** + * 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 SignedSource<<2c71efe87049ba9968052c0048e41905>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_bottom_left.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_bottom_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 0); + root_child0.setPosition(Edge.Bottom, 0); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(160); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(160); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_bottom_left_margin.test.ts b/javascript/tests/generated/grid_absolute_container_bottom_left_margin.test.ts new file mode 100644 index 0000000000..a546089473 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_bottom_left_margin.test.ts @@ -0,0 +1,200 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_bottom_left_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_bottom_left_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 0); + root_child0.setPosition(Edge.Bottom, 0); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 1); + root_child0.setMargin(Edge.Right, 2); + root_child0.setMargin(Edge.Bottom, 3); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(147); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(147); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_left_overrides_right.test.ts b/javascript/tests/generated/grid_absolute_container_left_overrides_right.test.ts new file mode 100644 index 0000000000..b19b8c8d71 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_left_overrides_right.test.ts @@ -0,0 +1,91 @@ +/** + * 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 SignedSource<<26259601cdb25f11f70489e4fdfd24ce>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_left_overrides_right.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_left_overrides_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 5); + root_child0.setPosition(Edge.Right, 2); + root_child0.setWidth(10); + 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(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(168); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_left_right.test.ts b/javascript/tests/generated/grid_absolute_container_left_right.test.ts new file mode 100644 index 0000000000..2987dbc94c --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_left_right.test.ts @@ -0,0 +1,194 @@ +/** + * 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 SignedSource<<83649b0121baf7360bc39a6f72ac7fe0>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_left_right.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_left_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 5); + root_child0.setPosition(Edge.Right, 2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(173); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(173); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_left_right_margin.test.ts b/javascript/tests/generated/grid_absolute_container_left_right_margin.test.ts new file mode 100644 index 0000000000..d628a9eb35 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_left_right_margin.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<<91077ca75c6050bb000768ddd6da3606>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_left_right_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_left_right_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 5); + root_child0.setPosition(Edge.Right, 2); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 1); + root_child0.setMargin(Edge.Right, 2); + root_child0.setMargin(Edge.Bottom, 3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(9); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(167); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(9); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(167); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_negative_position.test.ts b/javascript/tests/generated/grid_absolute_container_negative_position.test.ts new file mode 100644 index 0000000000..941057cf5b --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_negative_position.test.ts @@ -0,0 +1,197 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_negative_position.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_negative_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, -5); + root_child0.setPosition(Edge.Right, -15); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Left, -35); + root_child1.setPosition(Edge.Bottom, -25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(195); + expect(root_child0.getComputedTop()).toBe(-5); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(-35); + expect(root_child1.getComputedTop()).toBe(185); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(10); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(50); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(40); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(195); + expect(root_child0.getComputedTop()).toBe(-5); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(-35); + expect(root_child1.getComputedTop()).toBe(185); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(10); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(50); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(120); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_negative_position_margin.test.ts b/javascript/tests/generated/grid_absolute_container_negative_position_margin.test.ts new file mode 100644 index 0000000000..57c18d4a05 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_negative_position_margin.test.ts @@ -0,0 +1,205 @@ +/** + * 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 SignedSource<<24db92591a8df8140a6ba29b170f8209>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_negative_position_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_negative_position_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, -5); + root_child0.setPosition(Edge.Right, -15); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 1); + root_child0.setMargin(Edge.Right, 2); + root_child0.setMargin(Edge.Bottom, 3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Left, -35); + root_child1.setPosition(Edge.Bottom, -25); + root_child1.setMargin(Edge.Left, 4); + root_child1.setMargin(Edge.Top, 1); + root_child1.setMargin(Edge.Right, 2); + root_child1.setMargin(Edge.Bottom, 3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(193); + expect(root_child0.getComputedTop()).toBe(-4); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(-31); + expect(root_child1.getComputedTop()).toBe(182); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(10); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(50); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(40); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(193); + expect(root_child0.getComputedTop()).toBe(-4); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(-31); + expect(root_child1.getComputedTop()).toBe(182); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(10); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(50); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(120); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_top_bottom.test.ts b/javascript/tests/generated/grid_absolute_container_top_bottom.test.ts new file mode 100644 index 0000000000..685dd39cb3 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_top_bottom.test.ts @@ -0,0 +1,194 @@ +/** + * 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 SignedSource<<8f53fb8c54ef6c15a0a9d6a72b9c2ef5>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_bottom.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_top_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, 2); + root_child0.setPosition(Edge.Bottom, 5); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(153); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(153); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_top_bottom_margin.test.ts b/javascript/tests/generated/grid_absolute_container_top_bottom_margin.test.ts new file mode 100644 index 0000000000..b7d9796817 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_top_bottom_margin.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_bottom_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_top_bottom_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, 2); + root_child0.setPosition(Edge.Bottom, 5); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 1); + root_child0.setMargin(Edge.Right, 2); + root_child0.setMargin(Edge.Bottom, 3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(149); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(178); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(149); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_top_right.test.ts b/javascript/tests/generated/grid_absolute_container_top_right.test.ts new file mode 100644 index 0000000000..83bdf9ce60 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_top_right.test.ts @@ -0,0 +1,194 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_right.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_top_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, 0); + root_child0.setPosition(Edge.Right, 0); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_container_top_right_margin.test.ts b/javascript/tests/generated/grid_absolute_container_top_right_margin.test.ts new file mode 100644 index 0000000000..54c6f3308b --- /dev/null +++ b/javascript/tests/generated/grid_absolute_container_top_right_margin.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_right_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_container_top_right_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, 0); + root_child0.setPosition(Edge.Right, 0); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 1); + root_child0.setMargin(Edge.Right, 2); + root_child0.setMargin(Edge.Bottom, 3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(178); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(178); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_justify_self_sized_all.test.ts b/javascript/tests/generated/grid_absolute_justify_self_sized_all.test.ts new file mode 100644 index 0000000000..4b2b1e3332 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_justify_self_sized_all.test.ts @@ -0,0 +1,208 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_justify_self_sized_all.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_justify_self_sized_all', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Start); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setJustifySelf(Justify.Start); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setWidth(60); + root_child1.setHeight(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setJustifySelf(Justify.End); + root_child2.setPositionType(PositionType.Absolute); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setJustifySelf(Justify.End); + root_child3.setPositionType(PositionType.Absolute); + root_child3.setWidth(60); + root_child3.setHeight(60); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setJustifySelf(Justify.Center); + root_child4.setPositionType(PositionType.Absolute); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setJustifySelf(Justify.Center); + root_child5.setPositionType(PositionType.Absolute); + root_child5.setWidth(60); + root_child5.setHeight(60); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setJustifySelf(Justify.Stretch); + root_child6.setPositionType(PositionType.Absolute); + root_child6.setWidth(20); + root_child6.setHeight(20); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root_child7.setJustifySelf(Justify.Stretch); + root_child7.setPositionType(PositionType.Absolute); + root_child7.setWidth(60); + root_child7.setHeight(60); + root.insertChild(root_child7, 7); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(60); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(30); + expect(root_child5.getComputedTop()).toBe(0); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(0); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(0); + expect(root_child7.getComputedTop()).toBe(0); + expect(root_child7.getComputedWidth()).toBe(60); + expect(root_child7.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(60); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(30); + expect(root_child5.getComputedTop()).toBe(0); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(100); + expect(root_child6.getComputedTop()).toBe(0); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(60); + expect(root_child7.getComputedTop()).toBe(0); + expect(root_child7.getComputedWidth()).toBe(60); + expect(root_child7.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_layout_within_border.test.ts b/javascript/tests/generated/grid_absolute_layout_within_border.test.ts new file mode 100644 index 0000000000..683718113c --- /dev/null +++ b/javascript/tests/generated/grid_absolute_layout_within_border.test.ts @@ -0,0 +1,150 @@ +/** + * 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 SignedSource<<2dd54370948bc54b73a46fe9de972860>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_layout_within_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_layout_within_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 0); + root_child0.setPosition(Edge.Top, 0); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Right, 0); + root_child1.setPosition(Edge.Bottom, 0); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPositionType(PositionType.Absolute); + root_child2.setPosition(Edge.Left, 0); + root_child2.setPosition(Edge.Top, 0); + root_child2.setMargin(Edge.Left, 10); + root_child2.setMargin(Edge.Top, 10); + root_child2.setMargin(Edge.Right, 10); + root_child2.setMargin(Edge.Bottom, 10); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setPositionType(PositionType.Absolute); + root_child3.setPosition(Edge.Right, 0); + root_child3.setPosition(Edge.Bottom, 0); + root_child3.setMargin(Edge.Left, 10); + root_child3.setMargin(Edge.Top, 10); + root_child3.setMargin(Edge.Right, 10); + root_child3.setMargin(Edge.Bottom, 10); + root_child3.setWidth(50); + root_child3.setHeight(50); + root.insertChild(root_child3, 3); + 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(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(30); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + 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(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(30); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_layout_within_border_static.test.ts b/javascript/tests/generated/grid_absolute_layout_within_border_static.test.ts new file mode 100644 index 0000000000..f6fdc9e935 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_layout_within_border_static.test.ts @@ -0,0 +1,150 @@ +/** + * 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 SignedSource<<03f52f1a53ea4028bdbefc304012ddc7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_layout_within_border_static.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_layout_within_border_static', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Start); + root_child0.setAlignSelf(Align.Start); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setJustifySelf(Justify.End); + root_child1.setAlignSelf(Align.End); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setJustifySelf(Justify.Start); + root_child2.setAlignSelf(Align.Start); + root_child2.setPositionType(PositionType.Absolute); + root_child2.setMargin(Edge.Left, 10); + root_child2.setMargin(Edge.Top, 10); + root_child2.setMargin(Edge.Right, 10); + root_child2.setMargin(Edge.Bottom, 10); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setJustifySelf(Justify.End); + root_child3.setAlignSelf(Align.End); + root_child3.setPositionType(PositionType.Absolute); + root_child3.setMargin(Edge.Left, 10); + root_child3.setMargin(Edge.Top, 10); + root_child3.setMargin(Edge.Right, 10); + root_child3.setMargin(Edge.Bottom, 10); + root_child3.setWidth(50); + root_child3.setHeight(50); + root.insertChild(root_child3, 3); + 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(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(30); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + 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(40); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(30); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(20); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_resolved_insets.test.ts b/javascript/tests/generated/grid_absolute_resolved_insets.test.ts new file mode 100644 index 0000000000..179d68a0fb --- /dev/null +++ b/javascript/tests/generated/grid_absolute_resolved_insets.test.ts @@ -0,0 +1,304 @@ +/** + * 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 SignedSource<<02dea1e700265539c8ea06c4cf6cbcaf>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_resolved_insets.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_resolved_insets', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 15); + root_child0.setPadding(Edge.Top, 15); + root_child0.setPadding(Edge.Right, 15); + root_child0.setPadding(Edge.Bottom, 15); + root_child0.setBorder(Edge.Left, 20); + root_child0.setBorder(Edge.Top, 20); + root_child0.setBorder(Edge.Right, 20); + root_child0.setBorder(Edge.Bottom, 20); + root_child0.setWidth(200); + root_child0.setHeight(200); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPositionAuto(Edge.Left); + root_child0_child0.setPositionAuto(Edge.Top); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Absolute); + root_child0_child1.setPosition(Edge.Left, 0); + root_child0_child1.setPosition(Edge.Top, 0); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Absolute); + root_child0_child2.setPosition(Edge.Left, "100%"); + root_child0_child2.setPosition(Edge.Top, "100%"); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0_child3.setPositionType(PositionType.Absolute); + root_child0_child3.setPosition(Edge.Right, "100%"); + root_child0_child3.setPosition(Edge.Bottom, "100%"); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0_child4.setPositionType(PositionType.Absolute); + root_child0_child4.setPosition(Edge.Left, 30); + root_child0_child4.setPosition(Edge.Top, 30); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0_child5.setPositionType(PositionType.Absolute); + root_child0_child5.setPosition(Edge.Left, 0); + root_child0_child5.setPosition(Edge.Top, 0); + root_child0_child5.setWidth("100%"); + root_child0_child5.setHeight("100%"); + root_child0.insertChild(root_child0_child5, 5); + + const root_child1 = Yoga.Node.create(config); + root_child1.setOverflow(Overflow.Scroll); + root_child1.setPadding(Edge.Left, 15); + root_child1.setPadding(Edge.Top, 15); + root_child1.setPadding(Edge.Right, 15); + root_child1.setPadding(Edge.Bottom, 15); + root_child1.setBorder(Edge.Left, 20); + root_child1.setBorder(Edge.Top, 20); + root_child1.setBorder(Edge.Right, 20); + root_child1.setBorder(Edge.Bottom, 20); + root_child1.setWidth(200); + root_child1.setHeight(200); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setPositionType(PositionType.Absolute); + root_child1_child0.setPositionAuto(Edge.Left); + root_child1_child0.setPositionAuto(Edge.Top); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setPositionType(PositionType.Absolute); + root_child1_child1.setPosition(Edge.Left, 0); + root_child1_child1.setPosition(Edge.Top, 0); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setPositionType(PositionType.Absolute); + root_child1_child2.setPosition(Edge.Left, "100%"); + root_child1_child2.setPosition(Edge.Top, "100%"); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setPositionType(PositionType.Absolute); + root_child1_child3.setPosition(Edge.Right, "100%"); + root_child1_child3.setPosition(Edge.Bottom, "100%"); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setPositionType(PositionType.Absolute); + root_child1_child4.setPosition(Edge.Left, 30); + root_child1_child4.setPosition(Edge.Top, 30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child1_child5 = Yoga.Node.create(config); + root_child1_child5.setPositionType(PositionType.Absolute); + root_child1_child5.setPosition(Edge.Left, 0); + root_child1_child5.setPosition(Edge.Top, 0); + root_child1_child5.setWidth("100%"); + root_child1_child5.setHeight("100%"); + root_child1.insertChild(root_child1_child5, 5); + 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(400); + + 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(20); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(0); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(180); + expect(root_child0_child2.getComputedTop()).toBe(180); + expect(root_child0_child2.getComputedWidth()).toBe(0); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + expect(root_child0_child3.getComputedLeft()).toBe(20); + expect(root_child0_child3.getComputedTop()).toBe(20); + expect(root_child0_child3.getComputedWidth()).toBe(0); + expect(root_child0_child3.getComputedHeight()).toBe(0); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(0); + expect(root_child0_child4.getComputedHeight()).toBe(0); + + expect(root_child0_child5.getComputedLeft()).toBe(20); + expect(root_child0_child5.getComputedTop()).toBe(20); + expect(root_child0_child5.getComputedWidth()).toBe(160); + expect(root_child0_child5.getComputedHeight()).toBe(160); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child1_child0.getComputedLeft()).toBe(20); + expect(root_child1_child0.getComputedTop()).toBe(20); + expect(root_child1_child0.getComputedWidth()).toBe(0); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child1_child1.getComputedLeft()).toBe(20); + expect(root_child1_child1.getComputedTop()).toBe(20); + expect(root_child1_child1.getComputedWidth()).toBe(0); + expect(root_child1_child1.getComputedHeight()).toBe(0); + + expect(root_child1_child2.getComputedLeft()).toBe(180); + expect(root_child1_child2.getComputedTop()).toBe(180); + expect(root_child1_child2.getComputedWidth()).toBe(0); + expect(root_child1_child2.getComputedHeight()).toBe(0); + + expect(root_child1_child3.getComputedLeft()).toBe(20); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(0); + expect(root_child1_child3.getComputedHeight()).toBe(0); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(0); + expect(root_child1_child4.getComputedHeight()).toBe(0); + + expect(root_child1_child5.getComputedLeft()).toBe(20); + expect(root_child1_child5.getComputedTop()).toBe(20); + expect(root_child1_child5.getComputedWidth()).toBe(160); + expect(root_child1_child5.getComputedHeight()).toBe(160); + + 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(400); + + 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(180); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(0); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(180); + expect(root_child0_child2.getComputedTop()).toBe(180); + expect(root_child0_child2.getComputedWidth()).toBe(0); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + expect(root_child0_child3.getComputedLeft()).toBe(20); + expect(root_child0_child3.getComputedTop()).toBe(20); + expect(root_child0_child3.getComputedWidth()).toBe(0); + expect(root_child0_child3.getComputedHeight()).toBe(0); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(0); + expect(root_child0_child4.getComputedHeight()).toBe(0); + + expect(root_child0_child5.getComputedLeft()).toBe(20); + expect(root_child0_child5.getComputedTop()).toBe(20); + expect(root_child0_child5.getComputedWidth()).toBe(160); + expect(root_child0_child5.getComputedHeight()).toBe(160); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child1_child0.getComputedLeft()).toBe(180); + expect(root_child1_child0.getComputedTop()).toBe(20); + expect(root_child1_child0.getComputedWidth()).toBe(0); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child1_child1.getComputedLeft()).toBe(20); + expect(root_child1_child1.getComputedTop()).toBe(20); + expect(root_child1_child1.getComputedWidth()).toBe(0); + expect(root_child1_child1.getComputedHeight()).toBe(0); + + expect(root_child1_child2.getComputedLeft()).toBe(180); + expect(root_child1_child2.getComputedTop()).toBe(180); + expect(root_child1_child2.getComputedWidth()).toBe(0); + expect(root_child1_child2.getComputedHeight()).toBe(0); + + expect(root_child1_child3.getComputedLeft()).toBe(20); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(0); + expect(root_child1_child3.getComputedHeight()).toBe(0); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(0); + expect(root_child1_child4.getComputedHeight()).toBe(0); + + expect(root_child1_child5.getComputedLeft()).toBe(20); + expect(root_child1_child5.getComputedTop()).toBe(20); + expect(root_child1_child5.getComputedWidth()).toBe(160); + expect(root_child1_child5.getComputedHeight()).toBe(160); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_top_overrides_bottom.test.ts b/javascript/tests/generated/grid_absolute_top_overrides_bottom.test.ts new file mode 100644 index 0000000000..1ea12102bd --- /dev/null +++ b/javascript/tests/generated/grid_absolute_top_overrides_bottom.test.ts @@ -0,0 +1,195 @@ +/** + * 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 SignedSource<<1b3929de559ee32139fce5104009c98e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_top_overrides_bottom.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_top_overrides_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, 2); + root_child0.setPosition(Edge.Bottom, 5); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_with_padding.test.ts b/javascript/tests/generated/grid_absolute_with_padding.test.ts new file mode 100644 index 0000000000..23ce4bc638 --- /dev/null +++ b/javascript/tests/generated/grid_absolute_with_padding.test.ts @@ -0,0 +1,197 @@ +/** + * 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 SignedSource<<3e2b036f6c346a424905ab565bd4292c>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_with_padding.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_with_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, 0); + root_child0.setPosition(Edge.Right, 0); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Left, 10); + root_child1.setPosition(Edge.Bottom, 10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(10); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(50); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(40); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(180); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(10); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(50); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(120); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_absolute_with_padding_and_margin.test.ts b/javascript/tests/generated/grid_absolute_with_padding_and_margin.test.ts new file mode 100644 index 0000000000..dce4f6072c --- /dev/null +++ b/javascript/tests/generated/grid_absolute_with_padding_and_margin.test.ts @@ -0,0 +1,205 @@ +/** + * 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 SignedSource<<27928df0ac1f7fb939ed209d9afd7c62>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_with_padding_and_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_absolute_with_padding_and_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, 0); + root_child0.setPosition(Edge.Right, 0); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 1); + root_child0.setMargin(Edge.Right, 2); + root_child0.setMargin(Edge.Bottom, 3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Left, 10); + root_child1.setPosition(Edge.Bottom, 10); + root_child1.setMargin(Edge.Left, 4); + root_child1.setMargin(Edge.Top, 1); + root_child1.setMargin(Edge.Right, 2); + root_child1.setMargin(Edge.Bottom, 3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(178); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(14); + expect(root_child1.getComputedTop()).toBe(147); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(10); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(50); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(40); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(178); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(14); + expect(root_child1.getComputedTop()).toBe(147); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(10); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(50); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(120); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_center.test.ts b/javascript/tests/generated/grid_align_content_center.test.ts new file mode 100644 index 0000000000..4dbbece9e8 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_center.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_center.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(40); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(120); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(120); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(120); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(160); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(120); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(120); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(120); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_center_negative_space_gap.test.ts b/javascript/tests/generated/grid_align_content_center_negative_space_gap.test.ts new file mode 100644 index 0000000000..05125dede1 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_center_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_center_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_center_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.Center); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-10); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(-10); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(20); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(80); + expect(root_child0_child5.getComputedTop()).toBe(40); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(20); + expect(root_child0_child6.getComputedTop()).toBe(90); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(90); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(80); + expect(root_child0_child8.getComputedTop()).toBe(90); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(-10); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(-10); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(20); + expect(root_child0_child5.getComputedTop()).toBe(40); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(90); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(90); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(20); + expect(root_child0_child8.getComputedTop()).toBe(90); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_end.test.ts b/javascript/tests/generated/grid_align_content_end.test.ts new file mode 100644 index 0000000000..f090c37eef --- /dev/null +++ b/javascript/tests/generated/grid_align_content_end.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_end.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.End); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(80); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(120); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(120); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(120); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(160); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(160); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(160); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(160); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(120); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(120); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(120); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(160); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(160); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(160); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_end_negative_space_gap.test.ts b/javascript/tests/generated/grid_align_content_end_negative_space_gap.test.ts new file mode 100644 index 0000000000..a6a7890c89 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_end_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_end_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_end_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.End); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-20); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(-20); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(-20); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(20); + expect(root_child0_child3.getComputedTop()).toBe(30); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(30); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(80); + expect(root_child0_child5.getComputedTop()).toBe(30); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(20); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(80); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(-20); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(-20); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-20); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(30); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(30); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(20); + expect(root_child0_child5.getComputedTop()).toBe(30); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(20); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_end_with_padding_border.test.ts b/javascript/tests/generated/grid_align_content_end_with_padding_border.test.ts new file mode 100644 index 0000000000..38549ab759 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_end_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_end_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_end_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.End); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(48); + expect(root_child0.getComputedTop()).toBe(44); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(88); + expect(root_child1.getComputedTop()).toBe(44); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(128); + expect(root_child2.getComputedTop()).toBe(44); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(48); + expect(root_child3.getComputedTop()).toBe(84); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(88); + expect(root_child4.getComputedTop()).toBe(84); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(128); + expect(root_child5.getComputedTop()).toBe(84); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(48); + expect(root_child6.getComputedTop()).toBe(124); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(88); + expect(root_child7.getComputedTop()).toBe(124); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(128); + expect(root_child8.getComputedTop()).toBe(124); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(136); + expect(root_child0.getComputedTop()).toBe(44); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(96); + expect(root_child1.getComputedTop()).toBe(44); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(56); + expect(root_child2.getComputedTop()).toBe(44); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(136); + expect(root_child3.getComputedTop()).toBe(84); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(96); + expect(root_child4.getComputedTop()).toBe(84); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(56); + expect(root_child5.getComputedTop()).toBe(84); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(136); + expect(root_child6.getComputedTop()).toBe(124); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(96); + expect(root_child7.getComputedTop()).toBe(124); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(56); + expect(root_child8.getComputedTop()).toBe(124); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_space_around.test.ts b/javascript/tests/generated/grid_align_content_space_around.test.ts new file mode 100644 index 0000000000..d0669779aa --- /dev/null +++ b/javascript/tests/generated/grid_align_content_space_around.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_around.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(13); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(13); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(13); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(147); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(147); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(147); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(160); + expect(root_child0.getComputedTop()).toBe(13); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(13); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(13); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(147); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(147); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(147); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_space_around_negative_space_gap.test.ts b/javascript/tests/generated/grid_align_content_space_around_negative_space_gap.test.ts new file mode 100644 index 0000000000..2197b44d4f --- /dev/null +++ b/javascript/tests/generated/grid_align_content_space_around_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_around_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_space_around_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceAround); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(20); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(80); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(20); + expect(root_child0_child6.getComputedTop()).toBe(100); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(100); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(80); + expect(root_child0_child8.getComputedTop()).toBe(100); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(20); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(100); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(100); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(20); + expect(root_child0_child8.getComputedTop()).toBe(100); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_space_around_with_padding_border.test.ts b/javascript/tests/generated/grid_align_content_space_around_with_padding_border.test.ts new file mode 100644 index 0000000000..4c5961bf0b --- /dev/null +++ b/javascript/tests/generated/grid_align_content_space_around_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<<234677deef21cda97f88c5996caf42b2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_around_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_space_around_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(48); + expect(root_child0.getComputedTop()).toBe(17); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(88); + expect(root_child1.getComputedTop()).toBe(17); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(128); + expect(root_child2.getComputedTop()).toBe(17); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(48); + expect(root_child3.getComputedTop()).toBe(68); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(88); + expect(root_child4.getComputedTop()).toBe(68); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(128); + expect(root_child5.getComputedTop()).toBe(68); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(48); + expect(root_child6.getComputedTop()).toBe(119); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(88); + expect(root_child7.getComputedTop()).toBe(119); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(128); + expect(root_child8.getComputedTop()).toBe(119); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(136); + expect(root_child0.getComputedTop()).toBe(17); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(96); + expect(root_child1.getComputedTop()).toBe(17); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(56); + expect(root_child2.getComputedTop()).toBe(17); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(136); + expect(root_child3.getComputedTop()).toBe(68); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(96); + expect(root_child4.getComputedTop()).toBe(68); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(56); + expect(root_child5.getComputedTop()).toBe(68); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(136); + expect(root_child6.getComputedTop()).toBe(119); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(96); + expect(root_child7.getComputedTop()).toBe(119); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(56); + expect(root_child8.getComputedTop()).toBe(119); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_space_between.test.ts b/javascript/tests/generated/grid_align_content_space_between.test.ts new file mode 100644 index 0000000000..226008733b --- /dev/null +++ b/javascript/tests/generated/grid_align_content_space_between.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<<1c3e1dc7136c01825e1b80cdb83b05df>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_between.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_space_between', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(160); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(160); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(160); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(160); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(160); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(160); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_space_between_negative_space_gap.test.ts b/javascript/tests/generated/grid_align_content_space_between_negative_space_gap.test.ts new file mode 100644 index 0000000000..52e98f8fbb --- /dev/null +++ b/javascript/tests/generated/grid_align_content_space_between_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<<97858ad454e2c2726ee0630a52117d0f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_between_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_space_between_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceBetween); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(20); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(80); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(20); + expect(root_child0_child6.getComputedTop()).toBe(100); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(100); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(80); + expect(root_child0_child8.getComputedTop()).toBe(100); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(20); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(100); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(100); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(20); + expect(root_child0_child8.getComputedTop()).toBe(100); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_space_between_with_padding_border.test.ts b/javascript/tests/generated/grid_align_content_space_between_with_padding_border.test.ts new file mode 100644 index 0000000000..8e88429251 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_space_between_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<<0762248df7acc47843913839f91f2473>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_between_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_space_between_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(48); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(88); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(128); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(48); + expect(root_child3.getComputedTop()).toBe(68); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(88); + expect(root_child4.getComputedTop()).toBe(68); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(128); + expect(root_child5.getComputedTop()).toBe(68); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(48); + expect(root_child6.getComputedTop()).toBe(124); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(88); + expect(root_child7.getComputedTop()).toBe(124); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(128); + expect(root_child8.getComputedTop()).toBe(124); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(136); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(96); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(56); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(136); + expect(root_child3.getComputedTop()).toBe(68); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(96); + expect(root_child4.getComputedTop()).toBe(68); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(56); + expect(root_child5.getComputedTop()).toBe(68); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(136); + expect(root_child6.getComputedTop()).toBe(124); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(96); + expect(root_child7.getComputedTop()).toBe(124); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(56); + expect(root_child8.getComputedTop()).toBe(124); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_space_evenly.test.ts b/javascript/tests/generated/grid_align_content_space_evenly.test.ts new file mode 100644 index 0000000000..684c869f28 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_space_evenly.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_space_evenly', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(20); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(140); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(140); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(140); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(160); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(140); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(140); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(140); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_space_evenly_negative_space_gap.test.ts b/javascript/tests/generated/grid_align_content_space_evenly_negative_space_gap.test.ts new file mode 100644 index 0000000000..de7e4e1229 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_space_evenly_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<<4ffbdfeeaf7292d22d5356d54507f56a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_space_evenly_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceBetween); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(20); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(80); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(20); + expect(root_child0_child6.getComputedTop()).toBe(100); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(100); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(80); + expect(root_child0_child8.getComputedTop()).toBe(100); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(20); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(100); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(100); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(20); + expect(root_child0_child8.getComputedTop()).toBe(100); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_space_evenly_with_padding_border.test.ts b/javascript/tests/generated/grid_align_content_space_evenly_with_padding_border.test.ts new file mode 100644 index 0000000000..5ac1c437f7 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_space_evenly_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<<1469eaaae48ba8828b0c2dfc772f3aeb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_space_evenly_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(48); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(88); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(128); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(48); + expect(root_child3.getComputedTop()).toBe(68); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(88); + expect(root_child4.getComputedTop()).toBe(68); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(128); + expect(root_child5.getComputedTop()).toBe(68); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(48); + expect(root_child6.getComputedTop()).toBe(116); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(88); + expect(root_child7.getComputedTop()).toBe(116); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(128); + expect(root_child8.getComputedTop()).toBe(116); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(136); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(96); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(56); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(136); + expect(root_child3.getComputedTop()).toBe(68); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(96); + expect(root_child4.getComputedTop()).toBe(68); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(56); + expect(root_child5.getComputedTop()).toBe(68); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(136); + expect(root_child6.getComputedTop()).toBe(116); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(96); + expect(root_child7.getComputedTop()).toBe(116); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(56); + expect(root_child8.getComputedTop()).toBe(116); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_start.test.ts b/javascript/tests/generated/grid_align_content_start.test.ts new file mode 100644 index 0000000000..f889a08b9f --- /dev/null +++ b/javascript/tests/generated/grid_align_content_start.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<<88f835f08cdf280ffe55703b1f9e9b49>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_start.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Start); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_start_negative_space_gap.test.ts b/javascript/tests/generated/grid_align_content_start_negative_space_gap.test.ts new file mode 100644 index 0000000000..2121f3e338 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_start_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<<00e6d26427a1c0687f889371f40febe1>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_start_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_start_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.Start); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(20); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(80); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(20); + expect(root_child0_child6.getComputedTop()).toBe(100); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(100); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(80); + expect(root_child0_child8.getComputedTop()).toBe(100); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(20); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(20); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(20); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(20); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(100); + expect(root_child0_child6.getComputedWidth()).toBe(20); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(100); + expect(root_child0_child7.getComputedWidth()).toBe(20); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(20); + expect(root_child0_child8.getComputedTop()).toBe(100); + expect(root_child0_child8.getComputedWidth()).toBe(20); + expect(root_child0_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_content_start_with_padding_border.test.ts b/javascript/tests/generated/grid_align_content_start_with_padding_border.test.ts new file mode 100644 index 0000000000..4aa7104ad6 --- /dev/null +++ b/javascript/tests/generated/grid_align_content_start_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_start_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_content_start_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Start); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(48); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(88); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(128); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(48); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(88); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(128); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(48); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(88); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(128); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(136); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(96); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(56); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(136); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(96); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(56); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(136); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(96); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(56); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline.test.ts b/javascript/tests/generated/grid_align_items_baseline.test.ts new file mode 100644 index 0000000000..ef9a1619e3 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline.test.ts @@ -0,0 +1,95 @@ +/** + * 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 SignedSource<<8bf435390aad26a1803a9ca54569208f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + 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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_child.test.ts b/javascript/tests/generated/grid_align_items_baseline_child.test.ts new file mode 100644 index 0000000000..dc58bb3fad --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_child.test.ts @@ -0,0 +1,111 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_child_margin.test.ts b/javascript/tests/generated/grid_align_items_baseline_child_margin.test.ts new file mode 100644 index 0000000000..c1d647fc2a --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_child_margin.test.ts @@ -0,0 +1,119 @@ +/** + * 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 SignedSource<<7166bfdd2cd8fec8588d963e94b5b937>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_child_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 5); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 5); + root_child0.setMargin(Edge.Bottom, 5); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Left, 5); + root_child1_child0.setMargin(Edge.Top, 5); + root_child1_child0.setMargin(Edge.Right, 5); + root_child1_child0.setMargin(Edge.Bottom, 5); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_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(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(5); + expect(root_child1_child0.getComputedTop()).toBe(5); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + 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(45); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(-5); + expect(root_child1_child0.getComputedTop()).toBe(5); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_child_margin_percent.test.ts b/javascript/tests/generated/grid_align_items_baseline_child_margin_percent.test.ts new file mode 100644 index 0000000000..913b5d4013 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_child_margin_percent.test.ts @@ -0,0 +1,119 @@ +/** + * 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 SignedSource<<985e4609a4400b3b9445167b98f0304e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_margin_percent.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_child_margin_percent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, "5%"); + root_child0.setMargin(Edge.Top, "5%"); + root_child0.setMargin(Edge.Right, "5%"); + root_child0.setMargin(Edge.Bottom, "5%"); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Left, "1%"); + root_child1_child0.setMargin(Edge.Top, "1%"); + root_child1_child0.setMargin(Edge.Right, "1%"); + root_child1_child0.setMargin(Edge.Bottom, "1%"); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_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(3); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(1); + expect(root_child1_child0.getComputedTop()).toBe(1); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + 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(48); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(1); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_child_multiline.test.ts b/javascript/tests/generated/grid_align_items_baseline_child_multiline.test.ts new file mode 100644 index 0000000000..89fc7e7389 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_child_multiline.test.ts @@ -0,0 +1,162 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_multiline.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_child_multiline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setWidth(50); + root_child1.setDisplay(Display.Grid); + const root_child1GridTemplateColumns = []; + root_child1GridTemplateColumns.push({type: GridTrackType.Auto}); + root_child1GridTemplateColumns.push({type: GridTrackType.Auto}); + root_child1.setGridTemplateColumns(root_child1GridTemplateColumns); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(25); + root_child1_child0.setHeight(20); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setWidth(25); + root_child1_child1.setHeight(10); + root_child1_child1.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setWidth(25); + root_child1_child2.setHeight(20); + root_child1_child2.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setWidth(25); + root_child1_child3.setHeight(10); + root_child1_child3.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child3, 3); + 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(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(25); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(25); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child1_child0.getComputedLeft()).toBe(25); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(25); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.test.ts b/javascript/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.test.ts new file mode 100644 index 0000000000..c26ca015c2 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.test.ts @@ -0,0 +1,164 @@ +/** + * 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 SignedSource<<9d7dc9897d0c9885f14ad073aefac601>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_multiline_no_override_on_secondline.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_child_multiline_no_override_on_secondline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(25); + root_child1.setDisplay(Display.Grid); + const root_child1GridTemplateColumns = []; + root_child1GridTemplateColumns.push({type: GridTrackType.Auto}); + root_child1GridTemplateColumns.push({type: GridTrackType.Auto}); + root_child1.setGridTemplateColumns(root_child1GridTemplateColumns); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(25); + root_child1_child0.setHeight(20); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setWidth(25); + root_child1_child1.setHeight(10); + root_child1_child1.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setWidth(25); + root_child1_child2.setHeight(20); + root_child1_child2.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setAlignSelf(Align.Baseline); + root_child1_child3.setWidth(25); + root_child1_child3.setHeight(10); + root_child1_child3.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child3, 3); + 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(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(25); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(25); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(25); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(25); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_child_multiline_override.test.ts b/javascript/tests/generated/grid_align_items_baseline_child_multiline_override.test.ts new file mode 100644 index 0000000000..73555a27ae --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_child_multiline_override.test.ts @@ -0,0 +1,165 @@ +/** + * 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 SignedSource<<29b08d44a6f5d2528208a85e3494bc75>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_multiline_override.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_child_multiline_override', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(25); + root_child1.setDisplay(Display.Grid); + const root_child1GridTemplateColumns = []; + root_child1GridTemplateColumns.push({type: GridTrackType.Auto}); + root_child1GridTemplateColumns.push({type: GridTrackType.Auto}); + root_child1.setGridTemplateColumns(root_child1GridTemplateColumns); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(25); + root_child1_child0.setHeight(20); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setAlignSelf(Align.Baseline); + root_child1_child1.setWidth(25); + root_child1_child1.setHeight(10); + root_child1_child1.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setWidth(25); + root_child1_child2.setHeight(20); + root_child1_child2.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setAlignSelf(Align.Baseline); + root_child1_child3.setWidth(25); + root_child1_child3.setHeight(10); + root_child1_child3.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child3, 3); + 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(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(25); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(25); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child1_child0.getComputedLeft()).toBe(25); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child2.getComputedLeft()).toBe(25); + expect(root_child1_child2.getComputedTop()).toBe(20); + expect(root_child1_child2.getComputedWidth()).toBe(25); + expect(root_child1_child2.getComputedHeight()).toBe(20); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(20); + expect(root_child1_child3.getComputedWidth()).toBe(25); + expect(root_child1_child3.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_child_padding.test.ts b/javascript/tests/generated/grid_align_items_baseline_child_padding.test.ts new file mode 100644 index 0000000000..d58557d11f --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_child_padding.test.ts @@ -0,0 +1,119 @@ +/** + * 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 SignedSource<<3114d01b7b40c262debf4f092128711e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_padding.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_child_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 5); + root.setPadding(Edge.Top, 5); + root.setPadding(Edge.Right, 5); + root.setPadding(Edge.Bottom, 5); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 5); + root_child1.setPadding(Edge.Top, 5); + root_child1.setPadding(Edge.Right, 5); + root_child1.setPadding(Edge.Bottom, 5); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_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(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(5); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(5); + expect(root_child1_child0.getComputedTop()).toBe(5); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + 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(45); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(45); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(-5); + expect(root_child1_child0.getComputedTop()).toBe(5); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_child_top.test.ts b/javascript/tests/generated/grid_align_items_baseline_child_top.test.ts new file mode 100644 index 0000000000..aaee11cd3f --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_child_top.test.ts @@ -0,0 +1,112 @@ +/** + * 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 SignedSource<<76c87ef25bd922804d207d99ad4e7194>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_top.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_child_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Top, 10); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_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(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + 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(50); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_child_top2.test.ts b/javascript/tests/generated/grid_align_items_baseline_child_top2.test.ts new file mode 100644 index 0000000000..d8e116ba25 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_child_top2.test.ts @@ -0,0 +1,112 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_top2.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_child_top2', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPosition(Edge.Top, 5); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_complex.test.ts b/javascript/tests/generated/grid_align_items_baseline_complex.test.ts new file mode 100644 index 0000000000..4c294c4bdb --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_complex.test.ts @@ -0,0 +1,264 @@ +/** + * 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 SignedSource<<76e5cefad25baf0bae1f5304096d637d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_complex.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_complex', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child2_child0 = Yoga.Node.create(config); + root_child2_child0.setHeight(10); + root_child2.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root_child3.setHeight(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + root_child5.setHeight(20); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setWidth(20); + root_child6.setHeight(20); + root.insertChild(root_child6, 6); + + const root_child6_child0 = Yoga.Node.create(config); + root_child6_child0.setHeight(10); + root_child6.insertChild(root_child6_child0, 0); + + const root_child7 = Yoga.Node.create(config); + root_child7.setWidth(20); + root_child7.setHeight(20); + root.insertChild(root_child7, 7); + + const root_child7_child0 = Yoga.Node.create(config); + root_child7_child0.setHeight(5); + root_child7.insertChild(root_child7_child0, 0); + + const root_child8 = Yoga.Node.create(config); + root_child8.setWidth(20); + root_child8.setHeight(20); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(20); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(20); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(90); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child6_child0.getComputedLeft()).toBe(0); + expect(root_child6_child0.getComputedTop()).toBe(0); + expect(root_child6_child0.getComputedWidth()).toBe(20); + expect(root_child6_child0.getComputedHeight()).toBe(10); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(95); + expect(root_child7.getComputedWidth()).toBe(20); + expect(root_child7.getComputedHeight()).toBe(20); + + expect(root_child7_child0.getComputedLeft()).toBe(0); + expect(root_child7_child0.getComputedTop()).toBe(0); + expect(root_child7_child0.getComputedWidth()).toBe(20); + expect(root_child7_child0.getComputedHeight()).toBe(5); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(20); + expect(root_child8.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(20); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(20); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(60); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + expect(root_child6.getComputedLeft()).toBe(100); + expect(root_child6.getComputedTop()).toBe(90); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child6_child0.getComputedLeft()).toBe(0); + expect(root_child6_child0.getComputedTop()).toBe(0); + expect(root_child6_child0.getComputedWidth()).toBe(20); + expect(root_child6_child0.getComputedHeight()).toBe(10); + + expect(root_child7.getComputedLeft()).toBe(60); + expect(root_child7.getComputedTop()).toBe(95); + expect(root_child7.getComputedWidth()).toBe(20); + expect(root_child7.getComputedHeight()).toBe(20); + + expect(root_child7_child0.getComputedLeft()).toBe(0); + expect(root_child7_child0.getComputedTop()).toBe(0); + expect(root_child7_child0.getComputedWidth()).toBe(20); + expect(root_child7_child0.getComputedHeight()).toBe(5); + + expect(root_child8.getComputedLeft()).toBe(20); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(20); + expect(root_child8.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_double_nested_child.test.ts b/javascript/tests/generated/grid_align_items_baseline_double_nested_child.test.ts new file mode 100644 index 0000000000..447bf6e3b9 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_double_nested_child.test.ts @@ -0,0 +1,127 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_double_nested_child.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_double_nested_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(20); + root_child0_child0.setDisplay(Display.Grid); + root_child0.insertChild(root_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(15); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(15); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(15); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_multiline.test.ts b/javascript/tests/generated/grid_align_items_baseline_multiline.test.ts new file mode 100644 index 0000000000..4948d84936 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_multiline.test.ts @@ -0,0 +1,163 @@ +/** + * 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 SignedSource<<0f971d6bac3206c76c81e70828ae85ac>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_multiline.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_multiline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(20); + root_child2.setDisplay(Display.Grid); + root.insertChild(root_child2, 2); + + const root_child2_child0 = Yoga.Node.create(config); + root_child2_child0.setWidth(50); + root_child2_child0.setHeight(10); + root_child2_child0.setDisplay(Display.Grid); + root_child2.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(50); + root_child3.setDisplay(Display.Grid); + root.insertChild(root_child3, 3); + 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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(50); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(50); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_multiline_column.test.ts b/javascript/tests/generated/grid_align_items_baseline_multiline_column.test.ts new file mode 100644 index 0000000000..a2b9374750 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_multiline_column.test.ts @@ -0,0 +1,163 @@ +/** + * 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 SignedSource<<54e122b4a41b6eb773a65f6d476e8897>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_multiline_column.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_multiline_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(50); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(20); + root_child1_child0.setHeight(20); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root_child2.setHeight(70); + root_child2.setDisplay(Display.Grid); + root.insertChild(root_child2, 2); + + const root_child2_child0 = Yoga.Node.create(config); + root_child2_child0.setWidth(10); + root_child2_child0.setHeight(10); + root_child2_child0.setDisplay(Display.Grid); + root_child2.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(20); + root_child3.setDisplay(Display.Grid); + root.insertChild(root_child3, 3); + 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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(20); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(70); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(10); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(10); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(20); + expect(root_child1_child0.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(70); + + expect(root_child2_child0.getComputedLeft()).toBe(30); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(10); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_multiline_row_and_column.test.ts b/javascript/tests/generated/grid_align_items_baseline_multiline_row_and_column.test.ts new file mode 100644 index 0000000000..47f66b251b --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_multiline_row_and_column.test.ts @@ -0,0 +1,163 @@ +/** + * 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 SignedSource<<6d87a0ba3e4475ddf798d7e19dbed731>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_multiline_row_and_column.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_multiline_row_and_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(20); + root_child2.setDisplay(Display.Grid); + root.insertChild(root_child2, 2); + + const root_child2_child0 = Yoga.Node.create(config); + root_child2_child0.setWidth(50); + root_child2_child0.setHeight(10); + root_child2_child0.setDisplay(Display.Grid); + root_child2.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(20); + root_child3.setDisplay(Display.Grid); + root.insertChild(root_child3, 3); + 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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(50); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child2_child0.getComputedLeft()).toBe(0); + expect(root_child2_child0.getComputedTop()).toBe(0); + expect(root_child2_child0.getComputedWidth()).toBe(50); + expect(root_child2_child0.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_baseline_nested_column.test.ts b/javascript/tests/generated/grid_align_items_baseline_nested_column.test.ts new file mode 100644 index 0000000000..660ee96fe8 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_baseline_nested_column.test.ts @@ -0,0 +1,141 @@ +/** + * 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 SignedSource<<85f2ee0498bd9ba4eb622bd3586b7da2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_nested_column.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_baseline_nested_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setDisplay(Display.Grid); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(80); + root_child1_child0.setDisplay(Display.Grid); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child0_child0 = Yoga.Node.create(config); + root_child1_child0_child0.setWidth(50); + root_child1_child0_child0.setHeight(30); + root_child1_child0_child0.setDisplay(Display.Grid); + root_child1_child0.insertChild(root_child1_child0_child0, 0); + + const root_child1_child0_child1 = Yoga.Node.create(config); + root_child1_child0_child1.setWidth(50); + root_child1_child0_child1.setHeight(40); + root_child1_child0_child1.setDisplay(Display.Grid); + root_child1_child0.insertChild(root_child1_child0_child1, 1); + 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(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(80); + + expect(root_child1_child0_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0_child0.getComputedTop()).toBe(0); + expect(root_child1_child0_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child0_child1.getComputedLeft()).toBe(0); + expect(root_child1_child0_child1.getComputedTop()).toBe(30); + expect(root_child1_child0_child1.getComputedWidth()).toBe(50); + expect(root_child1_child0_child1.getComputedHeight()).toBe(40); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0.getComputedHeight()).toBe(80); + + expect(root_child1_child0_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0_child0.getComputedTop()).toBe(0); + expect(root_child1_child0_child0.getComputedWidth()).toBe(50); + expect(root_child1_child0_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child0_child1.getComputedLeft()).toBe(0); + expect(root_child1_child0_child1.getComputedTop()).toBe(30); + expect(root_child1_child0_child1.getComputedWidth()).toBe(50); + expect(root_child1_child0_child1.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_sized_center.test.ts b/javascript/tests/generated/grid_align_items_sized_center.test.ts new file mode 100644 index 0000000000..66ced82918 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_sized_center.test.ts @@ -0,0 +1,107 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_center.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_sized_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(60); + root_child1.setHeight(60); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(70); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(70); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_sized_end.test.ts b/javascript/tests/generated/grid_align_items_sized_end.test.ts new file mode 100644 index 0000000000..f1bf328987 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_sized_end.test.ts @@ -0,0 +1,107 @@ +/** + * 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 SignedSource<<0708978ba252893badae238d8e58efcb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_end.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_sized_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.End); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(60); + root_child1.setHeight(60); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_sized_start.test.ts b/javascript/tests/generated/grid_align_items_sized_start.test.ts new file mode 100644 index 0000000000..3a6218c974 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_sized_start.test.ts @@ -0,0 +1,107 @@ +/** + * 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 SignedSource<<39ffecfff4d9c56118a7787e4c6b9525>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_start.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_sized_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Start); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(60); + root_child1.setHeight(60); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_items_sized_stretch.test.ts b/javascript/tests/generated/grid_align_items_sized_stretch.test.ts new file mode 100644 index 0000000000..8266591781 --- /dev/null +++ b/javascript/tests/generated/grid_align_items_sized_stretch.test.ts @@ -0,0 +1,106 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_stretch.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_items_sized_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(60); + root_child1.setHeight(60); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_align_self_sized_all.test.ts b/javascript/tests/generated/grid_align_self_sized_all.test.ts new file mode 100644 index 0000000000..6de28ee3e5 --- /dev/null +++ b/javascript/tests/generated/grid_align_self_sized_all.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_self_sized_all.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_align_self_sized_all', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Start); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setAlignSelf(Align.Start); + root_child1.setWidth(60); + root_child1.setHeight(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setAlignSelf(Align.End); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setAlignSelf(Align.End); + root_child3.setWidth(60); + root_child3.setHeight(60); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setAlignSelf(Align.Center); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setAlignSelf(Align.Center); + root_child5.setWidth(60); + root_child5.setHeight(60); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setWidth(20); + root_child6.setHeight(20); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root_child7.setWidth(60); + root_child7.setHeight(60); + root.insertChild(root_child7, 7); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(20); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(60); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(30); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(60); + expect(root_child7.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(20); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(60); + + expect(root_child4.getComputedLeft()).toBe(60); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(-20); + expect(root_child5.getComputedTop()).toBe(30); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(100); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(20); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(60); + expect(root_child7.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.test.ts b/javascript/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.test.ts new file mode 100644 index 0000000000..84b99f9cb8 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.test.ts @@ -0,0 +1,81 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_absolute_width_overrides_inset.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_absolute_width_overrides_inset', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(300); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, "10%"); + root_child0.setPosition(Edge.Top, "5%"); + root_child0.setPosition(Edge.Right, "10%"); + root_child0.setWidth("40%"); + root_child0.setAspectRatio(3 / 1); + 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(400); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(160); + expect(root_child0.getComputedHeight()).toBe(53); + + 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(300); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(160); + expect(root_child0.getComputedHeight()).toBe(53); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_child_fill_content_height.test.ts b/javascript/tests/generated/grid_aspect_ratio_child_fill_content_height.test.ts new file mode 100644 index 0000000000..40e1c5e01d --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_child_fill_content_height.test.ts @@ -0,0 +1,89 @@ +/** + * 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 SignedSource<<4f1c6fde1b2d5d7d97bc2a5e6022ccdb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_child_fill_content_height.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_child_fill_content_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAspectRatio(0.5 / 1); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HHHH", flexDirection: FlexDirection.Column})); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(40); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(40); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_child_fill_content_width.test.ts b/javascript/tests/generated/grid_aspect_ratio_child_fill_content_width.test.ts new file mode 100644 index 0000000000..e82d27338e --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_child_fill_content_width.test.ts @@ -0,0 +1,89 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_child_fill_content_width.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_child_fill_content_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAspectRatio(2 / 1); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HHHH", flexDirection: FlexDirection.Column})); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(40); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(40); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_fill_child_height.test.ts b/javascript/tests/generated/grid_aspect_ratio_fill_child_height.test.ts new file mode 100644 index 0000000000..f33b3876a3 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_fill_child_height.test.ts @@ -0,0 +1,77 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_height.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_fill_child_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setAspectRatio(2 / 1); + 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(50); + expect(root_child0.getComputedHeight()).toBe(25); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_fill_child_max_height.test.ts b/javascript/tests/generated/grid_aspect_ratio_fill_child_max_height.test.ts new file mode 100644 index 0000000000..8bf19c2e45 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_fill_child_max_height.test.ts @@ -0,0 +1,78 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_max_height.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_fill_child_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMaxWidth(40); + root_child0.setAspectRatio(2 / 1); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH​HH​HH​HH​HH​HH", flexDirection: FlexDirection.Column})); + 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(40); + expect(root_child0.getComputedHeight()).toBe(20); + + 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(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_fill_child_max_width.test.ts b/javascript/tests/generated/grid_aspect_ratio_fill_child_max_width.test.ts new file mode 100644 index 0000000000..76735ddd3b --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_fill_child_max_width.test.ts @@ -0,0 +1,78 @@ +/** + * 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 SignedSource<<296836f3a5a254b95c5267daaac6d93f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_max_width.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_fill_child_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMaxHeight(20); + root_child0.setAspectRatio(2 / 1); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH HH HH HH", flexDirection: FlexDirection.Column})); + 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(40); + expect(root_child0.getComputedHeight()).toBe(20); + + 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(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_fill_child_min_height.test.ts b/javascript/tests/generated/grid_aspect_ratio_fill_child_min_height.test.ts new file mode 100644 index 0000000000..205c74c9e9 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_fill_child_min_height.test.ts @@ -0,0 +1,77 @@ +/** + * 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 SignedSource<<8af8427bc58c84a897debc11ceb7a72e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_min_height.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_fill_child_min_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMinWidth(50); + root_child0.setAspectRatio(2 / 1); + 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(50); + expect(root_child0.getComputedHeight()).toBe(25); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_fill_child_width.test.ts b/javascript/tests/generated/grid_aspect_ratio_fill_child_width.test.ts new file mode 100644 index 0000000000..f3949d7674 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_fill_child_width.test.ts @@ -0,0 +1,77 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_width.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_fill_child_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(50); + root_child0.setAspectRatio(2 / 1); + 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(50); + + 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(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_height_to_width.test.ts b/javascript/tests/generated/grid_aspect_ratio_height_to_width.test.ts new file mode 100644 index 0000000000..d9efdc2fa7 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_height_to_width.test.ts @@ -0,0 +1,98 @@ +/** + * 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 SignedSource<<3cf7ab40701f5ee05744338763a227c4>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_height_to_width.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_height_to_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 150}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(150); + root_child0.setAspectRatio(2 / 1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(150); + root_child1.setAspectRatio(0.5 / 1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(375); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(300); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(75); + expect(root_child1.getComputedHeight()).toBe(150); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(375); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(75); + expect(root_child1.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_min_max_constraints.test.ts b/javascript/tests/generated/grid_aspect_ratio_min_max_constraints.test.ts new file mode 100644 index 0000000000..edee7e12c4 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_min_max_constraints.test.ts @@ -0,0 +1,100 @@ +/** + * 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 SignedSource<<2ee3d8e08d9b783771696570179d832d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_min_max_constraints.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_min_max_constraints', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setMaxHeight(80); + root_child0.setAspectRatio(2 / 1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(200); + root_child1.setMinHeight(150); + root_child1.setAspectRatio(2 / 1); + root.insertChild(root_child1, 1); + 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(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(150); + + 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(150); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes.test.ts b/javascript/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes.test.ts new file mode 100644 index 0000000000..784a816c61 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes.test.ts @@ -0,0 +1,78 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_overridden_by_explicit_sizes.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_overridden_by_explicit_sizes', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setAspectRatio(2 / 1); + 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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes_flex.test.ts b/javascript/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes_flex.test.ts new file mode 100644 index 0000000000..c60a1097a0 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes_flex.test.ts @@ -0,0 +1,78 @@ +/** + * 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 SignedSource<<4862e8d5bfe68c31739cfead587fe50c>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_overridden_by_explicit_sizes_flex.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_overridden_by_explicit_sizes_flex', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setAspectRatio(2 / 1); + 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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_percentage_auto_margin.test.ts b/javascript/tests/generated/grid_aspect_ratio_percentage_auto_margin.test.ts new file mode 100644 index 0000000000..e11a6f4a4a --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_percentage_auto_margin.test.ts @@ -0,0 +1,120 @@ +/** + * 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 SignedSource<<2e666b145286fefa17a56e4ad00a8a5e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_percentage_auto_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_percentage_auto_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(120); + root_child0.setAspectRatio(16 / 9); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root_child1.setHeight(80); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Top, 'auto'); + root_child2.setMargin(Edge.Bottom, 'auto'); + root_child2.setAspectRatio(1 / 1); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(210); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(160); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(270); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(500); + expect(root.getComputedHeight()).toBe(210); + + expect(root_child0.getComputedLeft()).toBe(365); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(240); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_reresolution_auto_rows.test.ts b/javascript/tests/generated/grid_aspect_ratio_reresolution_auto_rows.test.ts new file mode 100644 index 0000000000..89a30a750c --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_reresolution_auto_rows.test.ts @@ -0,0 +1,96 @@ +/** + * 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 SignedSource<<8217fea9999842226f17128e5587b1a6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_reresolution_auto_rows.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_reresolution_auto_rows', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setAspectRatio(2 / 1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_spanning_items.test.ts b/javascript/tests/generated/grid_aspect_ratio_spanning_items.test.ts new file mode 100644 index 0000000000..81be590035 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_spanning_items.test.ts @@ -0,0 +1,102 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_spanning_items.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_spanning_items', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 150}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAspectRatio(3 / 1); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(150); + root_child1.setAspectRatio(1 / 1); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(470); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(450); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(320); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(150); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(470); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(450); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_spanning_with_content_distribution.test.ts b/javascript/tests/generated/grid_aspect_ratio_spanning_with_content_distribution.test.ts new file mode 100644 index 0000000000..ac4884b28d --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_spanning_with_content_distribution.test.ts @@ -0,0 +1,126 @@ +/** + * 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 SignedSource<<5ace2a39e07a7747c68c2f471bae8b45>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_spanning_with_content_distribution.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_spanning_with_content_distribution', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(2); + root_child0.setGridRowStart(1); + root_child0.setGridRowEnd(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(50); + root_child1.setGridColumnStart(1); + root_child1.setGridColumnEnd(2); + root_child1.setGridRowStart(2); + root_child1.setGridRowEnd(3); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setAspectRatio(2 / 1); + root_child2.setGridColumnStart(2); + root_child2.setGridColumnEnd(3); + root_child2.setGridRowStart(1); + root_child2.setGridRowEnd(3); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(450); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(400); + expect(root_child2.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(450); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(400); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(400); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(400); + expect(root_child2.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_triggers_reresolution.test.ts b/javascript/tests/generated/grid_aspect_ratio_triggers_reresolution.test.ts new file mode 100644 index 0000000000..f2ef3d1d47 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_triggers_reresolution.test.ts @@ -0,0 +1,81 @@ +/** + * 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 SignedSource<<1c3074b2cfba74f104aac038ee1110ad>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_triggers_reresolution.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_triggers_reresolution', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAspectRatio(2 / 1); + 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(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + 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(500); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_aspect_ratio_width_to_height.test.ts b/javascript/tests/generated/grid_aspect_ratio_width_to_height.test.ts new file mode 100644 index 0000000000..993392aa27 --- /dev/null +++ b/javascript/tests/generated/grid_aspect_ratio_width_to_height.test.ts @@ -0,0 +1,98 @@ +/** + * 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 SignedSource<<5a13752af8d9c9c4e7afee551939caf8>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_width_to_height.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_width_to_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 200}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setAspectRatio(2 / 1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(200); + root_child1.setAspectRatio(1.77 / 1); + root.insertChild(root_child1, 1); + 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(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(113); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(113); + + 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(113); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(113); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(113); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_auto_margin_overflow_block.test.ts b/javascript/tests/generated/grid_auto_margin_overflow_block.test.ts new file mode 100644 index 0000000000..c9576015dd --- /dev/null +++ b/javascript/tests/generated/grid_auto_margin_overflow_block.test.ts @@ -0,0 +1,82 @@ +/** + * 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 SignedSource<<9485428880cf366ae4749aa1a2b51296>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_margin_overflow_block.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_auto_margin_overflow_block', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(200); + 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(50); + expect(root_child0.getComputedHeight()).toBe(200); + + 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(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_auto_margin_overflow_inline.test.ts b/javascript/tests/generated/grid_auto_margin_overflow_inline.test.ts new file mode 100644 index 0000000000..3a891566bc --- /dev/null +++ b/javascript/tests/generated/grid_auto_margin_overflow_inline.test.ts @@ -0,0 +1,81 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_margin_overflow_inline.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_auto_margin_overflow_inline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(200); + 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(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + 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(50); + + expect(root_child0.getComputedLeft()).toBe(-100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_auto_rows.test.ts b/javascript/tests/generated/grid_auto_rows.test.ts new file mode 100644 index 0000000000..d3ed2a04fe --- /dev/null +++ b/javascript/tests/generated/grid_auto_rows.test.ts @@ -0,0 +1,176 @@ +/** + * 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 SignedSource<<384c95ae792134ec6fe50b85a961967e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_rows.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_auto_rows', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + const rootGridAutoRows = []; + rootGridAutoRows.push({type: GridTrackType.Points, value: 10}); + rootGridAutoRows.push({type: GridTrackType.Points, value: 20}); + rootGridAutoRows.push({type: GridTrackType.Points, value: 30}); + root.setGridAutoRows(rootGridAutoRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setGridRowStart(-4); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + 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(180); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(100); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(120); + expect(root_child5.getComputedWidth()).toBe(100); + expect(root_child5.getComputedHeight()).toBe(30); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(150); + expect(root_child6.getComputedWidth()).toBe(100); + expect(root_child6.getComputedHeight()).toBe(10); + + expect(root_child7.getComputedLeft()).toBe(0); + expect(root_child7.getComputedTop()).toBe(160); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(20); + + 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(180); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(100); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(120); + expect(root_child5.getComputedWidth()).toBe(100); + expect(root_child5.getComputedHeight()).toBe(30); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(150); + expect(root_child6.getComputedWidth()).toBe(100); + expect(root_child6.getComputedHeight()).toBe(10); + + expect(root_child7.getComputedLeft()).toBe(0); + expect(root_child7.getComputedTop()).toBe(160); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_auto_single_item.test.ts b/javascript/tests/generated/grid_auto_single_item.test.ts new file mode 100644 index 0000000000..ae90382b00 --- /dev/null +++ b/javascript/tests/generated/grid_auto_single_item.test.ts @@ -0,0 +1,188 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_single_item.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_auto_single_item', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(140); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(140); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(140); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(140); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(140); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(140); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_auto_single_item_fixed_width.test.ts b/javascript/tests/generated/grid_auto_single_item_fixed_width.test.ts new file mode 100644 index 0000000000..f224b0f777 --- /dev/null +++ b/javascript/tests/generated/grid_auto_single_item_fixed_width.test.ts @@ -0,0 +1,189 @@ +/** + * 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 SignedSource<<8aceadcb75c29d19a0312e4fd2d91dc1>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_single_item_fixed_width.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_auto_single_item_fixed_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMinWidth(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(140); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(140); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(0); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(140); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(0); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(120); + + expect(root_child0.getComputedLeft()).toBe(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(60); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(0); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(60); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(60); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(0); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.test.ts b/javascript/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.test.ts new file mode 100644 index 0000000000..535637c666 --- /dev/null +++ b/javascript/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.test.ts @@ -0,0 +1,189 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_single_item_fixed_width_with_definite_width.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_auto_single_item_fixed_width_with_definite_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(100); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(140); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(140); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(0); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(140); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(0); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(120); + + expect(root_child0.getComputedLeft()).toBe(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(60); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(0); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(60); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(60); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(0); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_auto_takes_precedence_over_fr.test.ts b/javascript/tests/generated/grid_auto_takes_precedence_over_fr.test.ts new file mode 100644 index 0000000000..40cf1057d9 --- /dev/null +++ b/javascript/tests/generated/grid_auto_takes_precedence_over_fr.test.ts @@ -0,0 +1,95 @@ +/** + * 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 SignedSource<<9269837c3188f4d2c2417287f1a03f58>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_takes_precedence_over_fr.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_auto_takes_precedence_over_fr', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + 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(0); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(40); + + 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(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_available_space_greater_than_max_content.test.ts b/javascript/tests/generated/grid_available_space_greater_than_max_content.test.ts new file mode 100644 index 0000000000..b256f50bb4 --- /dev/null +++ b/javascript/tests/generated/grid_available_space_greater_than_max_content.test.ts @@ -0,0 +1,106 @@ +/** + * 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 SignedSource<<8cbdb42a3daf3c2ec6622dcec0440bd3>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_available_space_greater_than_max_content.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_available_space_greater_than_max_content', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Auto}); + root_child0GridTemplateColumns.push({type: GridTrackType.Auto}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH HH HH HH", flexDirection: FlexDirection.Column})); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + root_child0_child1.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH HH HH HH", flexDirection: FlexDirection.Column})); + 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(10); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(110); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(110); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(110); + expect(root_child0_child1.getComputedHeight()).toBe(10); + + 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(10); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(290); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(110); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(180); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(110); + expect(root_child0_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_basic.test.ts b/javascript/tests/generated/grid_basic.test.ts new file mode 100644 index 0000000000..7da75d3285 --- /dev/null +++ b/javascript/tests/generated/grid_basic.test.ts @@ -0,0 +1,189 @@ +/** + * 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 SignedSource<<0a6d31f2460ae10279fd7f7b57e55cd5>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_basic', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_basic_implicit_tracks.test.ts b/javascript/tests/generated/grid_basic_implicit_tracks.test.ts new file mode 100644 index 0000000000..980fe110ca --- /dev/null +++ b/javascript/tests/generated/grid_basic_implicit_tracks.test.ts @@ -0,0 +1,94 @@ +/** + * 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 SignedSource<<2935643167f86f3d3387f18f50777655>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic_implicit_tracks.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_basic_implicit_tracks', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(35); + root_child1.setHeight(35); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(40); + expect(root.getComputedHeight()).toBe(75); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(35); + expect(root_child1.getComputedHeight()).toBe(35); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(40); + expect(root.getComputedHeight()).toBe(75); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(5); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(35); + expect(root_child1.getComputedHeight()).toBe(35); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_basic_with_overflow.test.ts b/javascript/tests/generated/grid_basic_with_overflow.test.ts new file mode 100644 index 0000000000..a312ec9970 --- /dev/null +++ b/javascript/tests/generated/grid_basic_with_overflow.test.ts @@ -0,0 +1,202 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic_with_overflow.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_basic_with_overflow', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + + const root_child9 = Yoga.Node.create(config); + root.insertChild(root_child9, 9); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + expect(root_child9.getComputedLeft()).toBe(0); + expect(root_child9.getComputedTop()).toBe(120); + expect(root_child9.getComputedWidth()).toBe(40); + expect(root_child9.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + expect(root_child9.getComputedLeft()).toBe(80); + expect(root_child9.getComputedTop()).toBe(120); + expect(root_child9.getComputedWidth()).toBe(40); + expect(root_child9.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_basic_with_padding.test.ts b/javascript/tests/generated/grid_basic_with_padding.test.ts new file mode 100644 index 0000000000..437ec7e1ff --- /dev/null +++ b/javascript/tests/generated/grid_basic_with_padding.test.ts @@ -0,0 +1,191 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic_with_padding.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_basic_with_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(90); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(120); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(120); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(90); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(40); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_complex_mixed_spanning_alignment.test.ts b/javascript/tests/generated/grid_complex_mixed_spanning_alignment.test.ts new file mode 100644 index 0000000000..ff8a793905 --- /dev/null +++ b/javascript/tests/generated/grid_complex_mixed_spanning_alignment.test.ts @@ -0,0 +1,128 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_complex_mixed_spanning_alignment.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('complex_mixed_spanning_alignment', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceBetween); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(600); + root.setHeight(400); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 10); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 100}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 80}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.End); + root_child0.setWidth(250); + root_child0.setHeight("100%"); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setAlignSelf(Align.Center); + root_child1.setWidth("100%"); + root_child1.setHeight(80); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("100%"); + root_child2.setHeight(200); + root_child2.setGridRowStart(2); + root_child2.setGridRowEnd(4); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(260); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(110); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(600); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(350); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(250); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(230); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(110); + expect(root_child1.getComputedHeight()).toBe(80); + + expect(root_child2.getComputedLeft()).toBe(500); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_display_none_fixed_size.test.ts b/javascript/tests/generated/grid_display_none_fixed_size.test.ts new file mode 100644 index 0000000000..ff7ea1bd6c --- /dev/null +++ b/javascript/tests/generated/grid_display_none_fixed_size.test.ts @@ -0,0 +1,92 @@ +/** + * 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 SignedSource<<6a59d9dae90925ca57c697a827c0ff7e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_display_none_fixed_size.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_display_none_fixed_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root_child1.setHeight(20); + root_child1.setDisplay(Display.None); + root.insertChild(root_child1, 1); + 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(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + 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(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_distribute_space_flex_auto.test.ts b/javascript/tests/generated/grid_distribute_space_flex_auto.test.ts new file mode 100644 index 0000000000..009d9e2e33 --- /dev/null +++ b/javascript/tests/generated/grid_distribute_space_flex_auto.test.ts @@ -0,0 +1,127 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_distribute_space_flex_auto.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_distribute_space_flex_auto', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(50); + root_child0.setGridColumnStart(1); + root_child0.setGridColumnEnd(4); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(30); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(30); + root.insertChild(root_child3, 3); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(250); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(30); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(30); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_expand_flexible_indefinite_free_space.test.ts b/javascript/tests/generated/grid_expand_flexible_indefinite_free_space.test.ts new file mode 100644 index 0000000000..6713cbc0c3 --- /dev/null +++ b/javascript/tests/generated/grid_expand_flexible_indefinite_free_space.test.ts @@ -0,0 +1,128 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_expand_flexible_indefinite_free_space.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_expand_flexible_indefinite_free_space_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root_child0GridTemplateRows.push({type: GridTrackType.Fr, value: 2}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(80); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(150); + root_child0_child1.setHeight(120); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(120); + root_child0_child2.setHeight(100); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(480); + expect(root.getComputedHeight()).toBe(360); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(480); + expect(root_child0.getComputedHeight()).toBe(360); + + 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(80); + + expect(root_child0_child1.getComputedLeft()).toBe(120); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(150); + expect(root_child0_child1.getComputedHeight()).toBe(120); + + expect(root_child0_child2.getComputedLeft()).toBe(360); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(120); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(480); + expect(root.getComputedHeight()).toBe(360); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(480); + expect(root_child0.getComputedHeight()).toBe(360); + + expect(root_child0_child0.getComputedLeft()).toBe(380); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(210); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(150); + expect(root_child0_child1.getComputedHeight()).toBe(120); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(120); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_fixed_size_no_content_proportions.test.ts b/javascript/tests/generated/grid_fr_fixed_size_no_content_proportions.test.ts new file mode 100644 index 0000000000..434e28917b --- /dev/null +++ b/javascript/tests/generated/grid_fr_fixed_size_no_content_proportions.test.ts @@ -0,0 +1,108 @@ +/** + * 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 SignedSource<<5dd307ee76eee3fd20c840f50c77b841>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_fixed_size_no_content_proportions.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_fixed_size_no_content_proportions', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 3}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + 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(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(33); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(33); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(67); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(40); + + 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(40); + + expect(root_child0.getComputedLeft()).toBe(167); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(33); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(67); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.test.ts b/javascript/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.test.ts new file mode 100644 index 0000000000..c6fb16d9a5 --- /dev/null +++ b/javascript/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.test.ts @@ -0,0 +1,94 @@ +/** + * 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 SignedSource<<728d6fe4183a88c6549d6f848801b193>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_fixed_size_no_content_proportions_sub_1_sum.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_fixed_size_no_content_proportions_sub_1_sum', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0.3}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0.2}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + 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(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + 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(40); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_fixed_size_single_item.test.ts b/javascript/tests/generated/grid_fr_fixed_size_single_item.test.ts new file mode 100644 index 0000000000..754838d5e3 --- /dev/null +++ b/javascript/tests/generated/grid_fr_fixed_size_single_item.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<<5a4126cbc01bb1f0025d4af717b2de48>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_fixed_size_single_item.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_fixed_size_single_item', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(140); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(60); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(80); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(80); + + expect(root_child5.getComputedLeft()).toBe(140); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(80); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(120); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(80); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(120); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(80); + + expect(root_child8.getComputedLeft()).toBe(140); + expect(root_child8.getComputedTop()).toBe(120); + expect(root_child8.getComputedWidth()).toBe(60); + expect(root_child8.getComputedHeight()).toBe(80); + + 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(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(60); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(80); + + expect(root_child4.getComputedLeft()).toBe(60); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(80); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(80); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(120); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(80); + + expect(root_child7.getComputedLeft()).toBe(60); + expect(root_child7.getComputedTop()).toBe(120); + expect(root_child7.getComputedWidth()).toBe(100); + expect(root_child7.getComputedHeight()).toBe(80); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(120); + expect(root_child8.getComputedWidth()).toBe(60); + expect(root_child8.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_no_sized_items_indefinite.test.ts b/javascript/tests/generated/grid_fr_no_sized_items_indefinite.test.ts new file mode 100644 index 0000000000..82a06b6285 --- /dev/null +++ b/javascript/tests/generated/grid_fr_no_sized_items_indefinite.test.ts @@ -0,0 +1,187 @@ +/** + * 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 SignedSource<<7d9356e59438f013b6c9d79cec01f720>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_no_sized_items_indefinite.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_no_sized_items_indefinite', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(40); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(0); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(0); + expect(root_child5.getComputedHeight()).toBe(0); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(40); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(0); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(40); + expect(root_child7.getComputedWidth()).toBe(0); + expect(root_child7.getComputedHeight()).toBe(0); + + expect(root_child8.getComputedLeft()).toBe(40); + expect(root_child8.getComputedTop()).toBe(40); + expect(root_child8.getComputedWidth()).toBe(0); + expect(root_child8.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(40); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(0); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(0); + expect(root_child5.getComputedHeight()).toBe(0); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(40); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(0); + + expect(root_child7.getComputedLeft()).toBe(0); + expect(root_child7.getComputedTop()).toBe(40); + expect(root_child7.getComputedWidth()).toBe(0); + expect(root_child7.getComputedHeight()).toBe(0); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(40); + expect(root_child8.getComputedWidth()).toBe(0); + expect(root_child8.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_single_item_indefinite.test.ts b/javascript/tests/generated/grid_fr_single_item_indefinite.test.ts new file mode 100644 index 0000000000..efc4a8e25b --- /dev/null +++ b/javascript/tests/generated/grid_fr_single_item_indefinite.test.ts @@ -0,0 +1,204 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_single_item_indefinite.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_single_item_indefinite', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth('auto'); + root_child0.setHeight('auto'); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root_child0GridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(240); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(40); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(140); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(100); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(0); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(0); + + expect(root_child0_child4.getComputedLeft()).toBe(40); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(100); + expect(root_child0_child4.getComputedHeight()).toBe(0); + + expect(root_child0_child5.getComputedLeft()).toBe(140); + expect(root_child0_child5.getComputedTop()).toBe(40); + expect(root_child0_child5.getComputedWidth()).toBe(100); + expect(root_child0_child5.getComputedHeight()).toBe(0); + + expect(root_child0_child6.getComputedLeft()).toBe(0); + expect(root_child0_child6.getComputedTop()).toBe(40); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(0); + + expect(root_child0_child7.getComputedLeft()).toBe(40); + expect(root_child0_child7.getComputedTop()).toBe(40); + expect(root_child0_child7.getComputedWidth()).toBe(100); + expect(root_child0_child7.getComputedHeight()).toBe(0); + + expect(root_child0_child8.getComputedLeft()).toBe(140); + expect(root_child0_child8.getComputedTop()).toBe(40); + expect(root_child0_child8.getComputedWidth()).toBe(100); + expect(root_child0_child8.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(240); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(100); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(100); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(200); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(0); + + expect(root_child0_child4.getComputedLeft()).toBe(100); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(100); + expect(root_child0_child4.getComputedHeight()).toBe(0); + + expect(root_child0_child5.getComputedLeft()).toBe(0); + expect(root_child0_child5.getComputedTop()).toBe(40); + expect(root_child0_child5.getComputedWidth()).toBe(100); + expect(root_child0_child5.getComputedHeight()).toBe(0); + + expect(root_child0_child6.getComputedLeft()).toBe(200); + expect(root_child0_child6.getComputedTop()).toBe(40); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(0); + + expect(root_child0_child7.getComputedLeft()).toBe(100); + expect(root_child0_child7.getComputedTop()).toBe(40); + expect(root_child0_child7.getComputedWidth()).toBe(100); + expect(root_child0_child7.getComputedHeight()).toBe(0); + + expect(root_child0_child8.getComputedLeft()).toBe(0); + expect(root_child0_child8.getComputedTop()).toBe(40); + expect(root_child0_child8.getComputedWidth()).toBe(100); + expect(root_child0_child8.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_span_2_proportion.test.ts b/javascript/tests/generated/grid_fr_span_2_proportion.test.ts new file mode 100644 index 0000000000..26faeffa48 --- /dev/null +++ b/javascript/tests/generated/grid_fr_span_2_proportion.test.ts @@ -0,0 +1,109 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_span_2_proportion', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(60); + root_child0.setGridColumnStartSpan(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_span_2_proportion_sub_1_sum.test.ts b/javascript/tests/generated/grid_fr_span_2_proportion_sub_1_sum.test.ts new file mode 100644 index 0000000000..e481e7a9ce --- /dev/null +++ b/javascript/tests/generated/grid_fr_span_2_proportion_sub_1_sum.test.ts @@ -0,0 +1,109 @@ +/** + * 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 SignedSource<<8aa33fec14cdfba458d25e0a529c1680>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_sub_1_sum.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_span_2_proportion_sub_1_sum', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0.2}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0.3}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(60); + root_child0.setGridColumnStartSpan(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(24); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(24); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(36); + expect(root_child2.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(36); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(24); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(36); + expect(root_child2.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.test.ts b/javascript/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.test.ts new file mode 100644 index 0000000000..493bc792a8 --- /dev/null +++ b/javascript/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.test.ts @@ -0,0 +1,150 @@ +/** + * 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 SignedSource<<114d23c5ae4a0f92d255b1ec81b96152>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_with_non_spanned_track.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_span_2_proportion_with_non_spanned_track', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 2}); + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 3}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(60); + root_child0_child0.setGridColumnStartSpan(2); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(60); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(60); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(60); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(20); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(60); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(60); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child0.getComputedLeft()).toBe(60); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(60); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(60); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(100); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(60); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(0); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(60); + expect(root_child0_child4.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_span_2_proportion_zero_sum.test.ts b/javascript/tests/generated/grid_fr_span_2_proportion_zero_sum.test.ts new file mode 100644 index 0000000000..a1f5195961 --- /dev/null +++ b/javascript/tests/generated/grid_fr_span_2_proportion_zero_sum.test.ts @@ -0,0 +1,109 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_zero_sum.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_span_2_proportion_zero_sum', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(60); + root_child0.setGridColumnStartSpan(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(30); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.test.ts b/javascript/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.test.ts new file mode 100644 index 0000000000..cbbd985d5e --- /dev/null +++ b/javascript/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.test.ts @@ -0,0 +1,136 @@ +/** + * 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 SignedSource<<8b1be10a7205461e5115de0f722080cf>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_span_2_proportion_zero_sum_with_non_spanned_track', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 0}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(60); + root_child0.setGridColumnStartSpan(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(30); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(60); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(0); + expect(root_child4.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(30); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(0); + expect(root_child4.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_gap.test.ts b/javascript/tests/generated/grid_gap.test.ts new file mode 100644 index 0000000000..edb9cbc08e --- /dev/null +++ b/javascript/tests/generated/grid_gap.test.ts @@ -0,0 +1,191 @@ +/** + * 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 SignedSource<<41e0c12d5637b151511b3e648546ff2d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setGap(Gutter.Column, 40); + root.setGap(Gutter.Row, 40); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(160); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(160); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(160); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(160); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(160); + expect(root_child8.getComputedTop()).toBe(160); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(160); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(160); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(160); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_hidden.test.ts b/javascript/tests/generated/grid_hidden.test.ts new file mode 100644 index 0000000000..d1b1b2ed23 --- /dev/null +++ b/javascript/tests/generated/grid_hidden.test.ts @@ -0,0 +1,192 @@ +/** + * 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 SignedSource<<1a52335e7e54a79c96db4327785143f1>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_hidden.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_hidden', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setDisplay(Display.None); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setDisplay(Display.None); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setDisplay(Display.None); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(0); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(0); + expect(root_child6.getComputedWidth()).toBe(0); + expect(root_child6.getComputedHeight()).toBe(0); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(40); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(40); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(0); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(0); + expect(root_child6.getComputedWidth()).toBe(0); + expect(root_child6.getComputedHeight()).toBe(0); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(40); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(40); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_center.test.ts b/javascript/tests/generated/grid_justify_content_center.test.ts new file mode 100644 index 0000000000..60a7d697d8 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_center.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_center.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(40); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(120); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(120); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(40); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_center_negative_space_gap.test.ts b/javascript/tests/generated/grid_justify_content_center_negative_space_gap.test.ts new file mode 100644 index 0000000000..fd683a6df6 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_center_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_center_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_center_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.Center); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(-10); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(40); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(-10); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(40); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(90); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(-10); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(40); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(90); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(40); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(-10); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(90); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(40); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(-10); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(90); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(40); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(-10); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_center_with_padding_border.test.ts b/javascript/tests/generated/grid_justify_content_center_with_padding_border.test.ts new file mode 100644 index 0000000000..36435e3c72 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_center_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<<23352a7b8f18b95235b603fb77cf7f96>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_center_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_center_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(52); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(92); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(132); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(52); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(92); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(132); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(52); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(92); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(132); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(132); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(92); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(52); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(132); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(92); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(52); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(132); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(92); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(52); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_end.test.ts b/javascript/tests/generated/grid_justify_content_end.test.ts new file mode 100644 index 0000000000..c514ad65d3 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_end.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<<85571d83bf47568f653bc6bb2b86a455>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_end.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.End); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(160); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(160); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(160); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_end_negative_space_gap.test.ts b/javascript/tests/generated/grid_justify_content_end_negative_space_gap.test.ts new file mode 100644 index 0000000000..d135ee1992 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_end_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<<003508e6b677c4ffacc189b166b9187a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_end_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_end_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.End); + root_child0.setAlignContent(Align.Center); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(-20); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(30); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(-20); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(30); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(80); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(-20); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(30); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(80); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(100); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(0); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(100); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(0); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_end_with_padding_border.test.ts b/javascript/tests/generated/grid_justify_content_end_with_padding_border.test.ts new file mode 100644 index 0000000000..89604748fe --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_end_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_end_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_end_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.End); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(56); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(96); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(136); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(56); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(96); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(136); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(56); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(96); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(136); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(128); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(88); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(48); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(128); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(88); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(48); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(128); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(88); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(48); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_space_around.test.ts b/javascript/tests/generated/grid_justify_content_space_around.test.ts new file mode 100644 index 0000000000..60a868f3e3 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_space_around.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<<4ca436bec77e0a2960b9f7d5be7c02b1>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_around.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(13); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(147); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(13); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(147); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(13); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(147); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(147); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(13); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(147); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(13); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(147); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(13); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_space_around_negative_space_gap.test.ts b/javascript/tests/generated/grid_justify_content_space_around_negative_space_gap.test.ts new file mode 100644 index 0000000000..6b1a4d1805 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_space_around_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<<3b76f62815656639b04e40396746708e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_around_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_space_around_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.SpaceAround); + root_child0.setAlignContent(Align.Center); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(100); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(0); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(100); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(0); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(100); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(30); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(-20); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(30); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(-20); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(30); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(-20); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_space_around_with_padding_border.test.ts b/javascript/tests/generated/grid_justify_content_space_around_with_padding_border.test.ts new file mode 100644 index 0000000000..fee9747d46 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_space_around_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<<9679843574a85d967105464390330190>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_around_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_space_around_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(49); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(92); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(135); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(49); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(92); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(135); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(49); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(92); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(135); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(135); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(92); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(49); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(135); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(92); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(49); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(135); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(92); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(49); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_space_between.test.ts b/javascript/tests/generated/grid_justify_content_space_between.test.ts new file mode 100644 index 0000000000..9bb30c5d3d --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_space_between.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<<58ab570c88a1bb2b1eecbc5afd58017b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_between.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_space_between', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(160); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(160); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(160); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_space_between_negative_space_gap.test.ts b/javascript/tests/generated/grid_justify_content_space_between_negative_space_gap.test.ts new file mode 100644 index 0000000000..3b76a123a1 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_space_between_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<<3c7863ba141281f2ad9bf2ca02a348e6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_between_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_space_between_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.SpaceBetween); + root_child0.setAlignContent(Align.Center); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(100); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(0); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(100); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(0); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(100); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(30); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(-20); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(30); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(-20); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(30); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(-20); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_space_between_with_padding_border.test.ts b/javascript/tests/generated/grid_justify_content_space_between_with_padding_border.test.ts new file mode 100644 index 0000000000..6df0c4af9e --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_space_between_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<<55734fb1c6287c2cdc454c127c57ae8b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_between_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_space_between_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(48); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(92); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(136); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(48); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(92); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(136); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(48); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(92); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(136); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(136); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(92); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(48); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(136); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(92); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(48); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(136); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(92); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(48); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_space_evenly.test.ts b/javascript/tests/generated/grid_justify_content_space_evenly.test.ts new file mode 100644 index 0000000000..111f36933d --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_space_evenly.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<<3bfd391de8e33a46dacd9d694b4706f7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_evenly.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_space_evenly', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(140); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(20); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(140); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(20); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(140); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(140); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(140); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(140); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(20); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_space_evenly_negative_space_gap.test.ts b/javascript/tests/generated/grid_justify_content_space_evenly_negative_space_gap.test.ts new file mode 100644 index 0000000000..9efd04cb33 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_space_evenly_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<<4e30c2ca23129b4e35dd5641ccce2924>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_evenly_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_space_evenly_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.SpaceEvenly); + root_child0.setAlignContent(Align.Center); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(100); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(0); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(100); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(0); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(100); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(30); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(-20); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(30); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(-20); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(30); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(-20); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_space_evenly_with_padding_border.test.ts b/javascript/tests/generated/grid_justify_content_space_evenly_with_padding_border.test.ts new file mode 100644 index 0000000000..d2aa4fa949 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_space_evenly_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_evenly_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_space_evenly_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(50); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(92); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(134); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(92); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(134); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(50); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(92); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(134); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(134); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(92); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(134); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(92); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(50); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(134); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(92); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(50); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_start.test.ts b/javascript/tests/generated/grid_justify_content_start.test.ts new file mode 100644 index 0000000000..a8d61fb43d --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_start.test.ts @@ -0,0 +1,190 @@ +/** + * 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 SignedSource<<5c82da12f9bd0daa12de1e2d3f7669ad>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_start.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Start); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(160); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(160); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(160); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(120); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_start_negative_space_gap.test.ts b/javascript/tests/generated/grid_justify_content_start_negative_space_gap.test.ts new file mode 100644 index 0000000000..16d8845f3e --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_start_negative_space_gap.test.ts @@ -0,0 +1,213 @@ +/** + * 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 SignedSource<<6cda9a3cbe99d6e34f08de6cd67ae6c5>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_start_negative_space_gap.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_start_negative_space_gap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 60); + root.setBorder(Edge.Top, 60); + root.setBorder(Edge.Right, 60); + root.setBorder(Edge.Bottom, 60); + root.setWidth(240); + root.setHeight(240); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Start); + root_child0.setAlignContent(Align.Center); + root_child0.setWidth(120); + root_child0.setHeight(120); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 20}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(100); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(0); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(50); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(100); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(0); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(50); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(100); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(240); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(30); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(-20); + expect(root_child0_child2.getComputedTop()).toBe(20); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(20); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(50); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(20); + + expect(root_child0_child4.getComputedLeft()).toBe(30); + expect(root_child0_child4.getComputedTop()).toBe(50); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(20); + + expect(root_child0_child5.getComputedLeft()).toBe(-20); + expect(root_child0_child5.getComputedTop()).toBe(50); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(20); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(20); + + expect(root_child0_child7.getComputedLeft()).toBe(30); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(20); + + expect(root_child0_child8.getComputedLeft()).toBe(-20); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_content_start_with_padding_border.test.ts b/javascript/tests/generated/grid_justify_content_start_with_padding_border.test.ts new file mode 100644 index 0000000000..c4a23adcd8 --- /dev/null +++ b/javascript/tests/generated/grid_justify_content_start_with_padding_border.test.ts @@ -0,0 +1,198 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_start_with_padding_border.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_content_start_with_padding_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Start); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 4); + root.setBorder(Edge.Bottom, 6); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + 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(48); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(88); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(128); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(48); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(88); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(128); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(48); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(88); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(128); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + 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(136); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(96); + expect(root_child1.getComputedTop()).toBe(12); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(56); + expect(root_child2.getComputedTop()).toBe(12); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(136); + expect(root_child3.getComputedTop()).toBe(52); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(96); + expect(root_child4.getComputedTop()).toBe(52); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(56); + expect(root_child5.getComputedTop()).toBe(52); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(136); + expect(root_child6.getComputedTop()).toBe(92); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(96); + expect(root_child7.getComputedTop()).toBe(92); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(56); + expect(root_child8.getComputedTop()).toBe(92); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_items_sized_center.test.ts b/javascript/tests/generated/grid_justify_items_sized_center.test.ts new file mode 100644 index 0000000000..a0c73c4bd3 --- /dev/null +++ b/javascript/tests/generated/grid_justify_items_sized_center.test.ts @@ -0,0 +1,107 @@ +/** + * 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 SignedSource<<67c88dfc7a858547561dd3c56113d1f0>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_center.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_items_sized_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyItems(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(60); + root_child1.setHeight(60); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(70); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(-10); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_items_sized_end.test.ts b/javascript/tests/generated/grid_justify_items_sized_end.test.ts new file mode 100644 index 0000000000..8c95c9892b --- /dev/null +++ b/javascript/tests/generated/grid_justify_items_sized_end.test.ts @@ -0,0 +1,107 @@ +/** + * 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 SignedSource<<3c8eb1c0352a1b4dc9d5b998dcc8888e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_end.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_items_sized_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyItems(Justify.End); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(60); + root_child1.setHeight(60); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_items_sized_start.test.ts b/javascript/tests/generated/grid_justify_items_sized_start.test.ts new file mode 100644 index 0000000000..a031304560 --- /dev/null +++ b/javascript/tests/generated/grid_justify_items_sized_start.test.ts @@ -0,0 +1,107 @@ +/** + * 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 SignedSource<<70ae19b586a68170b49e4c4a34984909>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_start.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_items_sized_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyItems(Justify.Start); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(60); + root_child1.setHeight(60); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_items_sized_stretch.test.ts b/javascript/tests/generated/grid_justify_items_sized_stretch.test.ts new file mode 100644 index 0000000000..6577c5c5c6 --- /dev/null +++ b/javascript/tests/generated/grid_justify_items_sized_stretch.test.ts @@ -0,0 +1,107 @@ +/** + * 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 SignedSource<<58d89f5eb77981d9f6d7517768db8e33>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_stretch.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_items_sized_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyItems(Justify.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(60); + root_child1.setHeight(60); + root_child1.setGridColumnStart(3); + root_child1.setGridRowStart(3); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_justify_self_sized_all.test.ts b/javascript/tests/generated/grid_justify_self_sized_all.test.ts new file mode 100644 index 0000000000..d29222d026 --- /dev/null +++ b/javascript/tests/generated/grid_justify_self_sized_all.test.ts @@ -0,0 +1,200 @@ +/** + * 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 SignedSource<<5e7ce6ad57f21334ef1546ae6d0bec7f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_self_sized_all.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_justify_self_sized_all', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Start); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setJustifySelf(Justify.Start); + root_child1.setWidth(60); + root_child1.setHeight(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setJustifySelf(Justify.End); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setJustifySelf(Justify.End); + root_child3.setWidth(60); + root_child3.setHeight(60); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setJustifySelf(Justify.Center); + root_child4.setWidth(20); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setJustifySelf(Justify.Center); + root_child5.setWidth(60); + root_child5.setHeight(60); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setJustifySelf(Justify.Stretch); + root_child6.setWidth(20); + root_child6.setHeight(20); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root_child7.setJustifySelf(Justify.Stretch); + root_child7.setWidth(60); + root_child7.setHeight(60); + root.insertChild(root_child7, 7); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(-20); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(60); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(70); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(60); + expect(root_child7.getComputedHeight()).toBe(60); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(60); + expect(root_child3.getComputedHeight()).toBe(60); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(-10); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(60); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(100); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(20); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(60); + expect(root_child7.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_auto_margins.test.ts b/javascript/tests/generated/grid_margins_auto_margins.test.ts new file mode 100644 index 0000000000..9ac3274481 --- /dev/null +++ b/javascript/tests/generated/grid_margins_auto_margins.test.ts @@ -0,0 +1,207 @@ +/** + * 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 SignedSource<<4dcebe8e2efcbca1a88c4f578e955fc2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_auto_margins.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_auto_margins', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setJustifySelf(Justify.Start); + root_child2.setMargin(Edge.Left, 'auto'); + root_child2.setMargin(Edge.Right, 'auto'); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setAlignSelf(Align.Start); + root_child4.setMargin(Edge.Top, 'auto'); + root_child4.setMargin(Edge.Bottom, 'auto'); + root_child4.setHeight(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setJustifySelf(Justify.Start); + root_child6.setAlignSelf(Align.Start); + root_child6.setMargin(Edge.Left, 'auto'); + root_child6.setMargin(Edge.Top, 'auto'); + root_child6.setMargin(Edge.Right, 'auto'); + root_child6.setMargin(Edge.Bottom, 'auto'); + root_child6.setWidth(20); + root_child6.setHeight(20); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(130); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(60); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(50); + expect(root_child6.getComputedTop()).toBe(100); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(120); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(120); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(60); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(130); + expect(root_child6.getComputedTop()).toBe(100); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(40); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_auto_margins_override_stretch.test.ts b/javascript/tests/generated/grid_margins_auto_margins_override_stretch.test.ts new file mode 100644 index 0000000000..118a047cc3 --- /dev/null +++ b/javascript/tests/generated/grid_margins_auto_margins_override_stretch.test.ts @@ -0,0 +1,197 @@ +/** + * 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 SignedSource<<92977a45aec28f1e0f3f52756ed628fb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_auto_margins_override_stretch.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_auto_margins_override_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root_child6.setJustifySelf(Justify.Stretch); + root_child6.setMargin(Edge.Left, 'auto'); + root_child6.setMargin(Edge.Top, 'auto'); + root_child6.setMargin(Edge.Right, 'auto'); + root_child6.setMargin(Edge.Bottom, 'auto'); + root.insertChild(root_child6, 6); + root_child6.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH​HH", flexDirection: FlexDirection.Column})); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(105); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(10); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(120); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(120); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(120); + expect(root_child6.getComputedTop()).toBe(105); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(10); + + expect(root_child7.getComputedLeft()).toBe(80); + expect(root_child7.getComputedTop()).toBe(90); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(40); + expect(root_child8.getComputedTop()).toBe(90); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_fixed_center.test.ts b/javascript/tests/generated/grid_margins_fixed_center.test.ts new file mode 100644 index 0000000000..487fab4611 --- /dev/null +++ b/javascript/tests/generated/grid_margins_fixed_center.test.ts @@ -0,0 +1,160 @@ +/** + * 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 SignedSource<<95b3a48ec95fc9aea8b0bc75cafd48e0>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_center.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_fixed_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Center); + root_child0.setAlignSelf(Align.Center); + root_child0.setMargin(Edge.Left, 8); + root_child0.setMargin(Edge.Top, 2); + root_child0.setMargin(Edge.Right, 4); + root_child0.setMargin(Edge.Bottom, 6); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(52); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(132); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_fixed_end.test.ts b/javascript/tests/generated/grid_margins_fixed_end.test.ts new file mode 100644 index 0000000000..cf3442b2a4 --- /dev/null +++ b/javascript/tests/generated/grid_margins_fixed_end.test.ts @@ -0,0 +1,160 @@ +/** + * 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 SignedSource<<0099a3dbd9c28b8604cc798237ab6d7d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_end.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_fixed_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.End); + root_child0.setAlignSelf(Align.End); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 1); + root_child0.setMargin(Edge.Right, 2); + root_child0.setMargin(Edge.Bottom, 3); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(58); + expect(root_child0.getComputedTop()).toBe(27); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(124); + expect(root_child0.getComputedTop()).toBe(27); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_fixed_start.test.ts b/javascript/tests/generated/grid_margins_fixed_start.test.ts new file mode 100644 index 0000000000..18f75c3f0b --- /dev/null +++ b/javascript/tests/generated/grid_margins_fixed_start.test.ts @@ -0,0 +1,160 @@ +/** + * 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 SignedSource<<27d3ff013df38b42c41be6e50c0fbcea>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_start.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_fixed_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Start); + root_child0.setAlignSelf(Align.Start); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 1); + root_child0.setMargin(Edge.Right, 2); + root_child0.setMargin(Edge.Bottom, 3); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(44); + expect(root_child0.getComputedTop()).toBe(11); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(138); + expect(root_child0.getComputedTop()).toBe(11); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_fixed_stretch.test.ts b/javascript/tests/generated/grid_margins_fixed_stretch.test.ts new file mode 100644 index 0000000000..f217f02855 --- /dev/null +++ b/javascript/tests/generated/grid_margins_fixed_stretch.test.ts @@ -0,0 +1,159 @@ +/** + * 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 SignedSource<<753fcb99cfa490b6f877869122250a07>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_stretch.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_fixed_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 40); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 30); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Stretch); + root_child0.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 1); + root_child0.setMargin(Edge.Right, 2); + root_child0.setMargin(Edge.Bottom, 3); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(44); + expect(root_child0.getComputedTop()).toBe(11); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(120); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(180); + expect(root.getComputedHeight()).toBe(160); + + expect(root_child0.getComputedLeft()).toBe(138); + expect(root_child0.getComputedTop()).toBe(11); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(120); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(80); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_percent_center.test.ts b/javascript/tests/generated/grid_margins_percent_center.test.ts new file mode 100644 index 0000000000..0dd31accf3 --- /dev/null +++ b/javascript/tests/generated/grid_margins_percent_center.test.ts @@ -0,0 +1,156 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_center.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_percent_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Center); + root_child0.setAlignSelf(Align.Center); + root_child0.setMargin(Edge.Left, "20%"); + root_child0.setMargin(Edge.Top, "5%"); + root_child0.setMargin(Edge.Right, "10%"); + root_child0.setMargin(Edge.Bottom, "15%"); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(1); + expect(root_child0.getComputedTop()).toBe(9); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(20); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(41); + expect(root_child0.getComputedTop()).toBe(9); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(20); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_percent_end.test.ts b/javascript/tests/generated/grid_margins_percent_end.test.ts new file mode 100644 index 0000000000..942d808feb --- /dev/null +++ b/javascript/tests/generated/grid_margins_percent_end.test.ts @@ -0,0 +1,156 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_end.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_percent_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.End); + root_child0.setAlignSelf(Align.End); + root_child0.setMargin(Edge.Left, "20%"); + root_child0.setMargin(Edge.Top, "5%"); + root_child0.setMargin(Edge.Right, "10%"); + root_child0.setMargin(Edge.Bottom, "15%"); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(-2); + expect(root_child0.getComputedTop()).toBe(17); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(20); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(44); + expect(root_child0.getComputedTop()).toBe(17); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(20); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_percent_start.test.ts b/javascript/tests/generated/grid_margins_percent_start.test.ts new file mode 100644 index 0000000000..d7b1e80c3e --- /dev/null +++ b/javascript/tests/generated/grid_margins_percent_start.test.ts @@ -0,0 +1,156 @@ +/** + * 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 SignedSource<<020ecd9495e36ea10f73094a67ab38a5>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_start.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_percent_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Start); + root_child0.setAlignSelf(Align.Start); + root_child0.setMargin(Edge.Left, "20%"); + root_child0.setMargin(Edge.Top, "5%"); + root_child0.setMargin(Edge.Right, "10%"); + root_child0.setMargin(Edge.Bottom, "15%"); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(20); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(38); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(20); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_margins_percent_stretch.test.ts b/javascript/tests/generated/grid_margins_percent_stretch.test.ts new file mode 100644 index 0000000000..7120da97ad --- /dev/null +++ b/javascript/tests/generated/grid_margins_percent_stretch.test.ts @@ -0,0 +1,155 @@ +/** + * 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 SignedSource<<5236f4dd05a4f3a15e9a4b153fc6f963>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_stretch.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_margins_percent_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 20}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Stretch); + root_child0.setMargin(Edge.Left, "20%"); + root_child0.setMargin(Edge.Top, "5%"); + root_child0.setMargin(Edge.Right, "10%"); + root_child0.setMargin(Edge.Bottom, "15%"); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(20); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(38); + expect(root_child0.getComputedTop()).toBe(1); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(20); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_minmax_auto_fixed_10px.test.ts b/javascript/tests/generated/grid_minmax_auto_fixed_10px.test.ts new file mode 100644 index 0000000000..f288a472ed --- /dev/null +++ b/javascript/tests/generated/grid_minmax_auto_fixed_10px.test.ts @@ -0,0 +1,80 @@ +/** + * 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 SignedSource<<73a2c7c3172247d89c1c21fa6e35c20f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_auto_fixed_10px.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_minmax_auto_fixed_10px', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Minmax, min: {type: GridTrackType.Auto}, max: {type: GridTrackType.Points, value: 10}}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH​HH", flexDirection: FlexDirection.Column})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(10); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(10); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_minmax_auto_percent_definite.test.ts b/javascript/tests/generated/grid_minmax_auto_percent_definite.test.ts new file mode 100644 index 0000000000..0a612b1d79 --- /dev/null +++ b/javascript/tests/generated/grid_minmax_auto_percent_definite.test.ts @@ -0,0 +1,81 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_auto_percent_definite.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_minmax_auto_percent_definite', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Minmax, min: {type: GridTrackType.Auto}, max: {type: GridTrackType.Percent, value: 20}}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH​HH", flexDirection: FlexDirection.Column})); + 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(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(40); + + 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(40); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_minmax_auto_percent_indefinite.test.ts b/javascript/tests/generated/grid_minmax_auto_percent_indefinite.test.ts new file mode 100644 index 0000000000..f201fb22eb --- /dev/null +++ b/javascript/tests/generated/grid_minmax_auto_percent_indefinite.test.ts @@ -0,0 +1,94 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_auto_percent_indefinite.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_minmax_auto_percent_indefinite', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Minmax, min: {type: GridTrackType.Auto}, max: {type: GridTrackType.Percent, value: 20}}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + root_child0_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH HH", flexDirection: FlexDirection.Column})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(40); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_minmax_column_fixed_width_above_range.test.ts b/javascript/tests/generated/grid_minmax_column_fixed_width_above_range.test.ts new file mode 100644 index 0000000000..e3c1c842db --- /dev/null +++ b/javascript/tests/generated/grid_minmax_column_fixed_width_above_range.test.ts @@ -0,0 +1,188 @@ +/** + * 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 SignedSource<<9686dc9a76656e337fbccb4fc57771f4>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_fixed_width_above_range.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_minmax_column_fixed_width_above_range', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Minmax, min: {type: GridTrackType.Points, value: 20}, max: {type: GridTrackType.Points, value: 40}}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(80); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(80); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(60); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(100); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(60); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(40); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(20); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_minmax_column_fixed_width_below_range.test.ts b/javascript/tests/generated/grid_minmax_column_fixed_width_below_range.test.ts new file mode 100644 index 0000000000..e8ffb6afc2 --- /dev/null +++ b/javascript/tests/generated/grid_minmax_column_fixed_width_below_range.test.ts @@ -0,0 +1,188 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_fixed_width_below_range.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_minmax_column_fixed_width_below_range', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(90); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Minmax, min: {type: GridTrackType.Points, value: 20}, max: {type: GridTrackType.Points, value: 40}}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(20); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(60); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(90); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(-10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(-10); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(50); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(30); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(20); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(-10); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_minmax_column_fixed_width_within_range.test.ts b/javascript/tests/generated/grid_minmax_column_fixed_width_within_range.test.ts new file mode 100644 index 0000000000..5de7615319 --- /dev/null +++ b/javascript/tests/generated/grid_minmax_column_fixed_width_within_range.test.ts @@ -0,0 +1,188 @@ +/** + * 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 SignedSource<<39f0b573558fec46f6619e35214c9203>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_fixed_width_within_range.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_minmax_column_fixed_width_within_range', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(110); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Minmax, min: {type: GridTrackType.Points, value: 20}, max: {type: GridTrackType.Points, value: 40}}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + + const root_child7 = Yoga.Node.create(config); + root.insertChild(root_child7, 7); + + const root_child8 = Yoga.Node.create(config); + root.insertChild(root_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(70); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(0); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(30); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(70); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(110); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(40); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(40); + + expect(root_child6.getComputedLeft()).toBe(70); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(40); + + expect(root_child7.getComputedLeft()).toBe(40); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(30); + expect(root_child7.getComputedHeight()).toBe(40); + + expect(root_child8.getComputedLeft()).toBe(0); + expect(root_child8.getComputedTop()).toBe(80); + expect(root_child8.getComputedWidth()).toBe(40); + expect(root_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_minmax_column_indefinite.test.ts b/javascript/tests/generated/grid_minmax_column_indefinite.test.ts new file mode 100644 index 0000000000..df5e366555 --- /dev/null +++ b/javascript/tests/generated/grid_minmax_column_indefinite.test.ts @@ -0,0 +1,201 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_indefinite.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_minmax_column_indefinite', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateColumns.push({type: GridTrackType.Minmax, min: {type: GridTrackType.Points, value: 20}, max: {type: GridTrackType.Points, value: 40}}); + root_child0GridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + + const root_child0_child5 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child5, 5); + + const root_child0_child6 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child6, 6); + + const root_child0_child7 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child7, 7); + + const root_child0_child8 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child8, 8); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(40); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(0); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(40); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(80); + expect(root_child0_child5.getComputedTop()).toBe(40); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(0); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(40); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(80); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(40); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(40); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(80); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(40); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(40); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(40); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + expect(root_child0_child5.getComputedLeft()).toBe(0); + expect(root_child0_child5.getComputedTop()).toBe(40); + expect(root_child0_child5.getComputedWidth()).toBe(40); + expect(root_child0_child5.getComputedHeight()).toBe(40); + + expect(root_child0_child6.getComputedLeft()).toBe(80); + expect(root_child0_child6.getComputedTop()).toBe(80); + expect(root_child0_child6.getComputedWidth()).toBe(40); + expect(root_child0_child6.getComputedHeight()).toBe(40); + + expect(root_child0_child7.getComputedLeft()).toBe(40); + expect(root_child0_child7.getComputedTop()).toBe(80); + expect(root_child0_child7.getComputedWidth()).toBe(40); + expect(root_child0_child7.getComputedHeight()).toBe(40); + + expect(root_child0_child8.getComputedLeft()).toBe(0); + expect(root_child0_child8.getComputedTop()).toBe(80); + expect(root_child0_child8.getComputedWidth()).toBe(40); + expect(root_child0_child8.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_minmax_column_with_auto_fixed.test.ts b/javascript/tests/generated/grid_minmax_column_with_auto_fixed.test.ts new file mode 100644 index 0000000000..d6a2a92665 --- /dev/null +++ b/javascript/tests/generated/grid_minmax_column_with_auto_fixed.test.ts @@ -0,0 +1,94 @@ +/** + * 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 SignedSource<<78d70802a24e03b6e329b7b4563267f7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_with_auto_fixed.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_minmax_column_with_auto_fixed', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(60); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Minmax, min: {type: GridTrackType.Points, value: 20}, max: {type: GridTrackType.Points, value: 40}}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_minmax_column_with_fr_fixed.test.ts b/javascript/tests/generated/grid_minmax_column_with_fr_fixed.test.ts new file mode 100644 index 0000000000..6b3d3a782d --- /dev/null +++ b/javascript/tests/generated/grid_minmax_column_with_fr_fixed.test.ts @@ -0,0 +1,94 @@ +/** + * 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 SignedSource<<6058093529cd1171fb239e5a072041bc>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_with_fr_fixed.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_minmax_column_with_fr_fixed', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(60); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Minmax, min: {type: GridTrackType.Points, value: 20}, max: {type: GridTrackType.Points, value: 40}}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(60); + expect(root.getComputedHeight()).toBe(40); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_overflow_inline_axis_hidden.test.ts b/javascript/tests/generated/grid_overflow_inline_axis_hidden.test.ts new file mode 100644 index 0000000000..8a55fe49fd --- /dev/null +++ b/javascript/tests/generated/grid_overflow_inline_axis_hidden.test.ts @@ -0,0 +1,77 @@ +/** + * 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 SignedSource<<69346ffe4af2d12ff0f16d9fbfa7f875>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_inline_axis_hidden.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_overflow_inline_axis_hidden', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setHeight(50); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setOverflow(Overflow.Hidden); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HHHHHHHHHH", flexDirection: FlexDirection.Column})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_overflow_inline_axis_scroll.test.ts b/javascript/tests/generated/grid_overflow_inline_axis_scroll.test.ts new file mode 100644 index 0000000000..21f93bee43 --- /dev/null +++ b/javascript/tests/generated/grid_overflow_inline_axis_scroll.test.ts @@ -0,0 +1,77 @@ +/** + * 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 SignedSource<<279e371031c76b1d6242dbd11632930b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_inline_axis_scroll.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_overflow_inline_axis_scroll', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setHeight(50); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setOverflow(Overflow.Scroll); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HHHHHHHHHH", flexDirection: FlexDirection.Column})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_overflow_inline_axis_visible.test.ts b/javascript/tests/generated/grid_overflow_inline_axis_visible.test.ts new file mode 100644 index 0000000000..07fc5c814d --- /dev/null +++ b/javascript/tests/generated/grid_overflow_inline_axis_visible.test.ts @@ -0,0 +1,76 @@ +/** + * 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 SignedSource<<18598f266c4e757225e0e7952ac76dc3>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_inline_axis_visible.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_overflow_inline_axis_visible', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setHeight(50); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HHHHHHHHHH", flexDirection: FlexDirection.Column})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(-50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_overflow_scrollbars_overridden_by_available_space.test.ts b/javascript/tests/generated/grid_overflow_scrollbars_overridden_by_available_space.test.ts new file mode 100644 index 0000000000..fcc521e716 --- /dev/null +++ b/javascript/tests/generated/grid_overflow_scrollbars_overridden_by_available_space.test.ts @@ -0,0 +1,90 @@ +/** + * 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 SignedSource<<275637b259bd22760b5d93d16570a661>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_overridden_by_available_space.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_overflow_scrollbars_overridden_by_available_space', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(2); + root.setHeight(4); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setOverflow(Overflow.Scroll); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + 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(2); + expect(root.getComputedHeight()).toBe(4); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2); + expect(root.getComputedHeight()).toBe(4); + + expect(root_child0.getComputedLeft()).toBe(2); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_overflow_scrollbars_overridden_by_max_size.test.ts b/javascript/tests/generated/grid_overflow_scrollbars_overridden_by_max_size.test.ts new file mode 100644 index 0000000000..35206f98bb --- /dev/null +++ b/javascript/tests/generated/grid_overflow_scrollbars_overridden_by_max_size.test.ts @@ -0,0 +1,76 @@ +/** + * 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 SignedSource<<05fa1986ab71c05c4df2765c97ec9260>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_overridden_by_max_size.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_overflow_scrollbars_overridden_by_max_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setOverflow(Overflow.Scroll); + root.setMaxWidth(2); + root.setMaxHeight(4); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + 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(0); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_overflow_scrollbars_overridden_by_size.test.ts b/javascript/tests/generated/grid_overflow_scrollbars_overridden_by_size.test.ts new file mode 100644 index 0000000000..d5365d56b7 --- /dev/null +++ b/javascript/tests/generated/grid_overflow_scrollbars_overridden_by_size.test.ts @@ -0,0 +1,76 @@ +/** + * 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 SignedSource<<4f6ee7de4ee4d287297b089fa973d902>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_overridden_by_size.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_overflow_scrollbars_overridden_by_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setOverflow(Overflow.Scroll); + root.setWidth(2); + root.setHeight(4); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + 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(2); + expect(root.getComputedHeight()).toBe(4); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2); + expect(root.getComputedHeight()).toBe(4); + + expect(root_child0.getComputedLeft()).toBe(2); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.test.ts b/javascript/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.test.ts new file mode 100644 index 0000000000..609cc62e35 --- /dev/null +++ b/javascript/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.test.ts @@ -0,0 +1,76 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_take_up_space_both_axis.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_overflow_scrollbars_take_up_space_both_axis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setOverflow(Overflow.Scroll); + root.setWidth(50); + root.setHeight(50); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + 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(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_padding_border_overrides_container_max_size.test.ts b/javascript/tests/generated/grid_padding_border_overrides_container_max_size.test.ts new file mode 100644 index 0000000000..0229039b1e --- /dev/null +++ b/javascript/tests/generated/grid_padding_border_overrides_container_max_size.test.ts @@ -0,0 +1,83 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_container_max_size.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_padding_border_overrides_container_max_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 8); + root.setPadding(Edge.Top, 2); + root.setPadding(Edge.Right, 4); + root.setPadding(Edge.Bottom, 6); + root.setBorder(Edge.Left, 7); + root.setBorder(Edge.Top, 1); + root.setBorder(Edge.Right, 3); + root.setBorder(Edge.Bottom, 5); + root.setMaxWidth(12); + root.setMaxHeight(12); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + 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(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_padding_border_overrides_container_size.test.ts b/javascript/tests/generated/grid_padding_border_overrides_container_size.test.ts new file mode 100644 index 0000000000..24dc7c4a39 --- /dev/null +++ b/javascript/tests/generated/grid_padding_border_overrides_container_size.test.ts @@ -0,0 +1,83 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_container_size.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_padding_border_overrides_container_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 8); + root.setPadding(Edge.Top, 2); + root.setPadding(Edge.Right, 4); + root.setPadding(Edge.Bottom, 6); + root.setBorder(Edge.Left, 7); + root.setBorder(Edge.Top, 1); + root.setBorder(Edge.Right, 3); + root.setBorder(Edge.Bottom, 5); + root.setWidth(12); + root.setHeight(12); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + 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(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_padding_border_overrides_max_size.test.ts b/javascript/tests/generated/grid_padding_border_overrides_max_size.test.ts new file mode 100644 index 0000000000..f271519b28 --- /dev/null +++ b/javascript/tests/generated/grid_padding_border_overrides_max_size.test.ts @@ -0,0 +1,83 @@ +/** + * 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 SignedSource<<2af8ab5954814878971abedfb991a534>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_max_size.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_padding_border_overrides_max_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 8); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 4); + root_child0.setPadding(Edge.Bottom, 6); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 1); + root_child0.setBorder(Edge.Right, 3); + root_child0.setBorder(Edge.Bottom, 5); + root_child0.setMaxWidth(12); + root_child0.setMaxHeight(12); + 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(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(22); + expect(root_child0.getComputedHeight()).toBe(14); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(22); + expect(root_child0.getComputedHeight()).toBe(14); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_padding_border_overrides_min_size.test.ts b/javascript/tests/generated/grid_padding_border_overrides_min_size.test.ts new file mode 100644 index 0000000000..c9658767e9 --- /dev/null +++ b/javascript/tests/generated/grid_padding_border_overrides_min_size.test.ts @@ -0,0 +1,81 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_min_size.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_padding_border_overrides_min_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 8); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 4); + root_child0.setPadding(Edge.Bottom, 6); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 1); + root_child0.setBorder(Edge.Right, 3); + root_child0.setBorder(Edge.Bottom, 5); + 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(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(22); + expect(root_child0.getComputedHeight()).toBe(14); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(22); + expect(root_child0.getComputedHeight()).toBe(14); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_padding_border_overrides_size.test.ts b/javascript/tests/generated/grid_padding_border_overrides_size.test.ts new file mode 100644 index 0000000000..b5e0b8f499 --- /dev/null +++ b/javascript/tests/generated/grid_padding_border_overrides_size.test.ts @@ -0,0 +1,83 @@ +/** + * 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 SignedSource<<3cf339ff63cfa6eb00f48b665d9271cd>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_size.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_padding_border_overrides_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 8); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 4); + root_child0.setPadding(Edge.Bottom, 6); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 1); + root_child0.setBorder(Edge.Right, 3); + root_child0.setBorder(Edge.Bottom, 5); + root_child0.setWidth(12); + root_child0.setHeight(12); + 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(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(22); + expect(root_child0.getComputedHeight()).toBe(14); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(22); + expect(root.getComputedHeight()).toBe(14); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(22); + expect(root_child0.getComputedHeight()).toBe(14); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_item_inside_stretch_item.test.ts b/javascript/tests/generated/grid_percent_item_inside_stretch_item.test.ts new file mode 100644 index 0000000000..5dd5656ea6 --- /dev/null +++ b/javascript/tests/generated/grid_percent_item_inside_stretch_item.test.ts @@ -0,0 +1,91 @@ +/** + * 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 SignedSource<<16994fd928cc7fe46eef12ce5d35a88e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_item_inside_stretch_item.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_item_inside_stretch_item', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("50%"); + root_child0_child0.setDisplay(Display.Grid); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + 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(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_items_nested_inside_stretch_alignment.test.ts b/javascript/tests/generated/grid_percent_items_nested_inside_stretch_alignment.test.ts new file mode 100644 index 0000000000..93b3957184 --- /dev/null +++ b/javascript/tests/generated/grid_percent_items_nested_inside_stretch_alignment.test.ts @@ -0,0 +1,90 @@ +/** + * 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 SignedSource<<08149101dd61750386ff1a19daf86ea4>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_inside_stretch_alignment.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_items_nested_inside_stretch_alignment', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Top, "20%"); + root_child0_child0.setDisplay(Display.Grid); + 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(200); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + 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(0); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_items_nested_moderate.test.ts b/javascript/tests/generated/grid_percent_items_nested_moderate.test.ts new file mode 100644 index 0000000000..45b0cf58ef --- /dev/null +++ b/javascript/tests/generated/grid_percent_items_nested_moderate.test.ts @@ -0,0 +1,110 @@ +/** + * 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 SignedSource<<604495a9f7c70a17db5c73227027d07e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_moderate.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_items_nested_moderate', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 3); + root.setPadding(Edge.Top, 3); + root.setPadding(Edge.Right, 3); + root.setPadding(Edge.Bottom, 3); + root.setWidth(200); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 5); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 5); + root_child0.setMargin(Edge.Bottom, 5); + root_child0.setPadding(Edge.Left, "3%"); + root_child0.setPadding(Edge.Top, "3%"); + root_child0.setPadding(Edge.Right, "3%"); + root_child0.setPadding(Edge.Bottom, "3%"); + root_child0.setWidth("50%"); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setMargin(Edge.Left, "5%"); + root_child0_child0.setMargin(Edge.Top, "5%"); + root_child0_child0.setMargin(Edge.Right, "5%"); + root_child0_child0.setMargin(Edge.Bottom, "5%"); + root_child0_child0.setPadding(Edge.Left, 3); + root_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0.setPadding(Edge.Right, 3); + root_child0_child0.setPadding(Edge.Bottom, 3); + root_child0_child0.setWidth("45%"); + 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(200); + expect(root.getComputedHeight()).toBe(24); + + expect(root_child0.getComputedLeft()).toBe(8); + expect(root_child0.getComputedTop()).toBe(8); + expect(root_child0.getComputedWidth()).toBe(8); + expect(root_child0.getComputedHeight()).toBe(8); + + expect(root_child0_child0.getComputedLeft()).toBe(1); + expect(root_child0_child0.getComputedTop()).toBe(1); + expect(root_child0_child0.getComputedWidth()).toBe(6); + expect(root_child0_child0.getComputedHeight()).toBe(6); + + 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(24); + + expect(root_child0.getComputedLeft()).toBe(184); + expect(root_child0.getComputedTop()).toBe(8); + expect(root_child0.getComputedWidth()).toBe(8); + expect(root_child0.getComputedHeight()).toBe(8); + + expect(root_child0_child0.getComputedLeft()).toBe(1); + expect(root_child0_child0.getComputedTop()).toBe(1); + expect(root_child0_child0.getComputedWidth()).toBe(6); + expect(root_child0_child0.getComputedHeight()).toBe(6); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_items_nested_with_margin.test.ts b/javascript/tests/generated/grid_percent_items_nested_with_margin.test.ts new file mode 100644 index 0000000000..067b377a2f --- /dev/null +++ b/javascript/tests/generated/grid_percent_items_nested_with_margin.test.ts @@ -0,0 +1,94 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_with_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_items_nested_with_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setMargin(Edge.Left, "5%"); + root_child0_child0.setMargin(Edge.Top, "5%"); + root_child0_child0.setMargin(Edge.Right, "5%"); + root_child0_child0.setMargin(Edge.Bottom, "5%"); + root_child0_child0.setWidth("45%"); + 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(200); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + 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(0); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_items_nested_with_padding_margin.test.ts b/javascript/tests/generated/grid_percent_items_nested_with_padding_margin.test.ts new file mode 100644 index 0000000000..5eb5044c8d --- /dev/null +++ b/javascript/tests/generated/grid_percent_items_nested_with_padding_margin.test.ts @@ -0,0 +1,147 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_with_padding_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_items_nested_with_padding_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 4}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 5); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 5); + root_child0.setMargin(Edge.Bottom, 5); + root_child0.setPadding(Edge.Left, 3); + root_child0.setPadding(Edge.Top, 3); + root_child0.setPadding(Edge.Right, 3); + root_child0.setPadding(Edge.Bottom, 3); + root_child0.setMinWidth("60%"); + root_child0.setDisplay(Display.Grid); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setMargin(Edge.Left, 5); + root_child0_child0.setMargin(Edge.Top, 5); + root_child0_child0.setMargin(Edge.Right, 5); + root_child0_child0.setMargin(Edge.Bottom, 5); + root_child0_child0.setPadding(Edge.Left, "3%"); + root_child0_child0.setPadding(Edge.Top, "3%"); + root_child0_child0.setPadding(Edge.Right, "3%"); + root_child0_child0.setPadding(Edge.Bottom, "3%"); + root_child0_child0.setWidth("50%"); + root_child0_child0.setDisplay(Display.Grid); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setMargin(Edge.Left, "5%"); + root_child0_child0_child0.setMargin(Edge.Top, "5%"); + root_child0_child0_child0.setMargin(Edge.Right, "5%"); + root_child0_child0_child0.setMargin(Edge.Bottom, "5%"); + root_child0_child0_child0.setPadding(Edge.Left, 3); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 3); + root_child0_child0_child0.setPadding(Edge.Bottom, 3); + root_child0_child0_child0.setWidth("45%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + 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(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(22); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(8); + expect(root_child0_child0.getComputedTop()).toBe(8); + expect(root_child0_child0.getComputedWidth()).toBe(8); + expect(root_child0_child0.getComputedHeight()).toBe(8); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(1); + expect(root_child0_child0_child0.getComputedTop()).toBe(1); + expect(root_child0_child0_child0.getComputedWidth()).toBe(6); + expect(root_child0_child0_child0.getComputedHeight()).toBe(6); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(32); + expect(root_child1.getComputedHeight()).toBe(160); + + 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(173); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(22); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child0_child0.getComputedLeft()).toBe(6); + expect(root_child0_child0.getComputedTop()).toBe(8); + expect(root_child0_child0.getComputedWidth()).toBe(8); + expect(root_child0_child0.getComputedHeight()).toBe(8); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(1); + expect(root_child0_child0_child0.getComputedTop()).toBe(1); + expect(root_child0_child0_child0.getComputedWidth()).toBe(6); + expect(root_child0_child0_child0.getComputedHeight()).toBe(6); + + expect(root_child1.getComputedLeft()).toBe(168); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(32); + expect(root_child1.getComputedHeight()).toBe(160); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_items_width_and_margin.test.ts b/javascript/tests/generated/grid_percent_items_width_and_margin.test.ts new file mode 100644 index 0000000000..033c01f6d1 --- /dev/null +++ b/javascript/tests/generated/grid_percent_items_width_and_margin.test.ts @@ -0,0 +1,87 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_width_and_margin.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_items_width_and_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 3); + root.setPadding(Edge.Top, 3); + root.setPadding(Edge.Right, 3); + root.setPadding(Edge.Bottom, 3); + root.setWidth(200); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, "5%"); + root_child0.setMargin(Edge.Top, "5%"); + root_child0.setMargin(Edge.Right, "5%"); + root_child0.setMargin(Edge.Bottom, "5%"); + root_child0.setPadding(Edge.Left, 3); + root_child0.setPadding(Edge.Top, 3); + root_child0.setPadding(Edge.Right, 3); + root_child0.setPadding(Edge.Bottom, 3); + root_child0.setWidth("45%"); + 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(200); + expect(root.getComputedHeight()).toBe(13); + + expect(root_child0.getComputedLeft()).toBe(3); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(6); + expect(root_child0.getComputedHeight()).toBe(6); + + 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(13); + + expect(root_child0.getComputedLeft()).toBe(191); + expect(root_child0.getComputedTop()).toBe(3); + expect(root_child0.getComputedWidth()).toBe(6); + expect(root_child0.getComputedHeight()).toBe(6); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_items_width_and_padding.test.ts b/javascript/tests/generated/grid_percent_items_width_and_padding.test.ts new file mode 100644 index 0000000000..867f6a41f5 --- /dev/null +++ b/javascript/tests/generated/grid_percent_items_width_and_padding.test.ts @@ -0,0 +1,79 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_width_and_padding.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_items_width_and_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, "3%"); + root_child0.setPadding(Edge.Top, "3%"); + root_child0.setPadding(Edge.Right, "3%"); + root_child0.setPadding(Edge.Bottom, "3%"); + root_child0.setWidth("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(200); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + 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(0); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_tracks_definite_overflow.test.ts b/javascript/tests/generated/grid_percent_tracks_definite_overflow.test.ts new file mode 100644 index 0000000000..7193cf168a --- /dev/null +++ b/javascript/tests/generated/grid_percent_tracks_definite_overflow.test.ts @@ -0,0 +1,149 @@ +/** + * 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 SignedSource<<6a6c290418c55a9afbcccfda918bd8d6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_definite_overflow.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_tracks_definite_overflow', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(60); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 80}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(48); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(48); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(48); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(96); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(48); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(48); + expect(root_child3.getComputedHeight()).toBe(48); + + expect(root_child4.getComputedLeft()).toBe(48); + expect(root_child4.getComputedTop()).toBe(30); + expect(root_child4.getComputedWidth()).toBe(48); + expect(root_child4.getComputedHeight()).toBe(48); + + expect(root_child5.getComputedLeft()).toBe(96); + expect(root_child5.getComputedTop()).toBe(30); + expect(root_child5.getComputedWidth()).toBe(48); + expect(root_child5.getComputedHeight()).toBe(48); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(72); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(48); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(24); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(48); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(-24); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(48); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(72); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(48); + expect(root_child3.getComputedHeight()).toBe(48); + + expect(root_child4.getComputedLeft()).toBe(24); + expect(root_child4.getComputedTop()).toBe(30); + expect(root_child4.getComputedWidth()).toBe(48); + expect(root_child4.getComputedHeight()).toBe(48); + + expect(root_child5.getComputedLeft()).toBe(-24); + expect(root_child5.getComputedTop()).toBe(30); + expect(root_child5.getComputedWidth()).toBe(48); + expect(root_child5.getComputedHeight()).toBe(48); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_tracks_definite_underflow.test.ts b/javascript/tests/generated/grid_percent_tracks_definite_underflow.test.ts new file mode 100644 index 0000000000..9518885c51 --- /dev/null +++ b/javascript/tests/generated/grid_percent_tracks_definite_underflow.test.ts @@ -0,0 +1,149 @@ +/** + * 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 SignedSource<<4d74106c79d79fc05fef8b7882fcbbcb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_definite_underflow.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_tracks_definite_underflow', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(60); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 10}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 30}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 60}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(12); + expect(root_child0.getComputedHeight()).toBe(18); + + expect(root_child1.getComputedLeft()).toBe(12); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(24); + expect(root_child1.getComputedHeight()).toBe(18); + + expect(root_child2.getComputedLeft()).toBe(36); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(36); + expect(root_child2.getComputedHeight()).toBe(18); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(18); + expect(root_child3.getComputedWidth()).toBe(12); + expect(root_child3.getComputedHeight()).toBe(36); + + expect(root_child4.getComputedLeft()).toBe(12); + expect(root_child4.getComputedTop()).toBe(18); + expect(root_child4.getComputedWidth()).toBe(24); + expect(root_child4.getComputedHeight()).toBe(36); + + expect(root_child5.getComputedLeft()).toBe(36); + expect(root_child5.getComputedTop()).toBe(18); + expect(root_child5.getComputedWidth()).toBe(36); + expect(root_child5.getComputedHeight()).toBe(36); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(108); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(12); + expect(root_child0.getComputedHeight()).toBe(18); + + expect(root_child1.getComputedLeft()).toBe(84); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(24); + expect(root_child1.getComputedHeight()).toBe(18); + + expect(root_child2.getComputedLeft()).toBe(48); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(36); + expect(root_child2.getComputedHeight()).toBe(18); + + expect(root_child3.getComputedLeft()).toBe(108); + expect(root_child3.getComputedTop()).toBe(18); + expect(root_child3.getComputedWidth()).toBe(12); + expect(root_child3.getComputedHeight()).toBe(36); + + expect(root_child4.getComputedLeft()).toBe(84); + expect(root_child4.getComputedTop()).toBe(18); + expect(root_child4.getComputedWidth()).toBe(24); + expect(root_child4.getComputedHeight()).toBe(36); + + expect(root_child5.getComputedLeft()).toBe(48); + expect(root_child5.getComputedTop()).toBe(18); + expect(root_child5.getComputedWidth()).toBe(36); + expect(root_child5.getComputedHeight()).toBe(36); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_tracks_indefinite_only.test.ts b/javascript/tests/generated/grid_percent_tracks_indefinite_only.test.ts new file mode 100644 index 0000000000..258a92a562 --- /dev/null +++ b/javascript/tests/generated/grid_percent_tracks_indefinite_only.test.ts @@ -0,0 +1,147 @@ +/** + * 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 SignedSource<<6e97b34401477b97f145bb5e6baf1ffc>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_indefinite_only.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_tracks_indefinite_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 10}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 30}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 60}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(0); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(0); + expect(root_child5.getComputedWidth()).toBe(0); + expect(root_child5.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(0); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(0); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(0); + expect(root_child5.getComputedWidth()).toBe(0); + expect(root_child5.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.test.ts b/javascript/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.test.ts new file mode 100644 index 0000000000..a3210fa407 --- /dev/null +++ b/javascript/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.test.ts @@ -0,0 +1,166 @@ +/** + * 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 SignedSource<<6adc52b9e2fe8712dca2fb4519745916>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_indefinite_with_content_overflow.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_tracks_indefinite_with_content_overflow', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 50}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 80}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setGridColumnStart(1); + root_child1.setGridRowStart(1); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + 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); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(80); + + expect(root_child5.getComputedLeft()).toBe(40); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(80); + + expect(root_child6.getComputedLeft()).toBe(80); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(80); + + 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); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(-20); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(40); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(60); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(40); + expect(root_child4.getComputedHeight()).toBe(80); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(50); + expect(root_child5.getComputedWidth()).toBe(40); + expect(root_child5.getComputedHeight()).toBe(80); + + expect(root_child6.getComputedLeft()).toBe(-20); + expect(root_child6.getComputedTop()).toBe(50); + expect(root_child6.getComputedWidth()).toBe(40); + expect(root_child6.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.test.ts b/javascript/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.test.ts new file mode 100644 index 0000000000..4375f1563d --- /dev/null +++ b/javascript/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.test.ts @@ -0,0 +1,166 @@ +/** + * 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 SignedSource<<646ac3eeeeeab3abcd1b6bf6cebbfada>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_indefinite_with_content_underflow.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_percent_tracks_indefinite_with_content_underflow', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 10}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 20}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 30}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 30}); + rootGridTemplateRows.push({type: GridTrackType.Percent, value: 60}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setGridColumnStart(1); + root_child1.setGridRowStart(1); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root.insertChild(root_child5, 5); + + const root_child6 = Yoga.Node.create(config); + root.insertChild(root_child6, 6); + 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); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(30); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(30); + expect(root_child4.getComputedWidth()).toBe(10); + expect(root_child4.getComputedHeight()).toBe(60); + + expect(root_child5.getComputedLeft()).toBe(10); + expect(root_child5.getComputedTop()).toBe(30); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(30); + expect(root_child6.getComputedTop()).toBe(30); + expect(root_child6.getComputedWidth()).toBe(30); + expect(root_child6.getComputedHeight()).toBe(60); + + 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); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(30); + expect(root_child4.getComputedWidth()).toBe(10); + expect(root_child4.getComputedHeight()).toBe(60); + + expect(root_child5.getComputedLeft()).toBe(70); + expect(root_child5.getComputedTop()).toBe(30); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(60); + + expect(root_child6.getComputedLeft()).toBe(40); + expect(root_child6.getComputedTop()).toBe(30); + expect(root_child6.getComputedWidth()).toBe(30); + expect(root_child6.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_placement_auto_negative.test.ts b/javascript/tests/generated/grid_placement_auto_negative.test.ts new file mode 100644 index 0000000000..0f701f5e7a --- /dev/null +++ b/javascript/tests/generated/grid_placement_auto_negative.test.ts @@ -0,0 +1,112 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_placement_auto_negative.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_placement_auto_negative', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setGridColumnStart(-5); + root_child0.setGridRowStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setGridRowStart(2); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(120); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.test.ts b/javascript/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.test.ts new file mode 100644 index 0000000000..3c98128a6a --- /dev/null +++ b/javascript/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.test.ts @@ -0,0 +1,113 @@ +/** + * 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 SignedSource<<049e296975d64f1e7b4babe77620bf13>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_placement_definite_in_secondary_axis_with_fully_definite_negative', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setGridRowStart(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setGridColumnStart(-4); + root_child1.setGridRowStart(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setGridRowStart(1); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_placement_definite_primary.test.ts b/javascript/tests/generated/grid_placement_definite_primary.test.ts new file mode 100644 index 0000000000..c5cef0458e --- /dev/null +++ b/javascript/tests/generated/grid_placement_definite_primary.test.ts @@ -0,0 +1,136 @@ +/** + * 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 SignedSource<<392120ef684752f27f0f77ebbbef1bee>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_placement_definite_primary.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_placement_definite_primary', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 33}); + rootGridTemplateColumns.push({type: GridTrackType.Percent, value: 74}); + root.setGridTemplateColumns(rootGridTemplateColumns); + + const root_child0 = Yoga.Node.create(config); + root_child0.setGridColumnStart(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setGridColumnStart(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setGridColumnStart(1); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setGridColumnStart(2); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setGridColumnStart(1); + root.insertChild(root_child4, 4); + 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(66); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(66); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(148); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(66); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(66); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(148); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(66); + expect(root_child4.getComputedHeight()).toBe(0); + + 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(134); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(66); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(-14); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(148); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(134); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(66); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(-14); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(148); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(134); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(66); + expect(root_child4.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_relative_all_sides.test.ts b/javascript/tests/generated/grid_relative_all_sides.test.ts new file mode 100644 index 0000000000..cc8f99198b --- /dev/null +++ b/javascript/tests/generated/grid_relative_all_sides.test.ts @@ -0,0 +1,80 @@ +/** + * 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 SignedSource<<4ee9a6d713f38638082c8d114b85960d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_relative_all_sides.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_relative_all_sides', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Left, 10); + root_child0.setPosition(Edge.Top, 10); + root_child0.setPosition(Edge.Right, 10); + root_child0.setPosition(Edge.Bottom, 10); + root_child0.setWidth(40); + 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(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(0); + + 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(50); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_size_child_fixed_tracks.test.ts b/javascript/tests/generated/grid_size_child_fixed_tracks.test.ts new file mode 100644 index 0000000000..5849145543 --- /dev/null +++ b/javascript/tests/generated/grid_size_child_fixed_tracks.test.ts @@ -0,0 +1,154 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_size_child_fixed_tracks.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_size_child_fixed_tracks', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(120); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateColumns.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + rootGridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifySelf(Justify.Start); + root_child0.setAlignSelf(Align.Start); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH HH HH HH", flexDirection: FlexDirection.Column})); + + const root_child1 = Yoga.Node.create(config); + root_child1.setJustifySelf(Justify.Start); + root_child1.setAlignSelf(Align.Start); + root.insertChild(root_child1, 1); + root_child1.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HHH HHH", flexDirection: FlexDirection.Column})); + + const root_child2 = Yoga.Node.create(config); + root_child2.setJustifySelf(Justify.Start); + root_child2.setAlignSelf(Align.Start); + root.insertChild(root_child2, 2); + root_child2.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH HHHH", flexDirection: FlexDirection.Column})); + + const root_child3 = Yoga.Node.create(config); + root_child3.setJustifySelf(Justify.Start); + root_child3.setAlignSelf(Align.Start); + root_child3.setWidth(20); + root.insertChild(root_child3, 3); + root_child3.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH HH HH HH", flexDirection: FlexDirection.Column})); + + const root_child4 = Yoga.Node.create(config); + root_child4.setJustifySelf(Justify.Start); + root_child4.setAlignSelf(Align.Start); + root_child4.setMaxWidth(30); + root.insertChild(root_child4, 4); + root_child4.setMeasureFunc(instrinsicSizeMeasureFunc.bind({text: "HH HH HH HH", flexDirection: FlexDirection.Column})); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(120); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/grid_taffy_issue_624.test.ts b/javascript/tests/generated/grid_taffy_issue_624.test.ts new file mode 100644 index 0000000000..0327712d40 --- /dev/null +++ b/javascript/tests/generated/grid_taffy_issue_624.test.ts @@ -0,0 +1,131 @@ +/** + * 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 SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_taffy_issue_624.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_taffy_issue_624', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Start); + root.setJustifyItems(Justify.Start); + root.setPositionType(PositionType.Absolute); + root.setWidth(320); + root.setHeight(640); + root.setDisplay(Display.Grid); + const rootGridTemplateColumns = []; + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Auto}); + rootGridTemplateColumns.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateColumns(rootGridTemplateColumns); + const rootGridTemplateRows = []; + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Auto}); + rootGridTemplateRows.push({type: GridTrackType.Fr, value: 1}); + root.setGridTemplateRows(rootGridTemplateRows); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(50); + root_child0.setGridColumnStart(1); + root_child0.setGridRowStart(1); + root_child0.setGridRowEndSpan(2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root_child1.setHeight(30); + root_child1.setGridColumnStart(2); + root_child1.setGridColumnEndSpan(2); + root_child1.setGridRowStart(1); + root_child1.setGridRowEndSpan(2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(120); + root_child2.setHeight(20); + root_child2.setGridColumnStart(1); + root_child2.setGridColumnEndSpan(2); + root_child2.setGridRowStart(3); + root_child2.setGridRowEndSpan(1); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(640); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(320); + expect(root.getComputedHeight()).toBe(640); + + expect(root_child0.getComputedLeft()).toBe(220); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(180); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(200); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/xgrid_aspect_ratio_fill_child_min_width.test.ts b/javascript/tests/generated/xgrid_aspect_ratio_fill_child_min_width.test.ts new file mode 100644 index 0000000000..57f2ef7dcb --- /dev/null +++ b/javascript/tests/generated/xgrid_aspect_ratio_fill_child_min_width.test.ts @@ -0,0 +1,77 @@ +/** + * 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 SignedSource<<81fd77d6a8dd1b1a1fcf59e1dcb2e81a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/xgrid_aspect_ratio_fill_child_min_width.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_aspect_ratio_fill_child_min_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setDisplay(Display.Grid); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMinHeight(50); + root_child0.setAspectRatio(2 / 1); + 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(50); + + 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(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/javascript/tests/generated/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.test.ts b/javascript/tests/generated/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.test.ts new file mode 100644 index 0000000000..2adc7c362a --- /dev/null +++ b/javascript/tests/generated/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.test.ts @@ -0,0 +1,150 @@ +/** + * 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 SignedSource<<816c3f3d56737626bcd7f39c0531759a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + GridTrackType, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('grid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth("max-content"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Grid); + const root_child0GridTemplateColumns = []; + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 0.2}); + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 0.3}); + root_child0GridTemplateColumns.push({type: GridTrackType.Fr, value: 0.5}); + root_child0.setGridTemplateColumns(root_child0GridTemplateColumns); + const root_child0GridTemplateRows = []; + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0GridTemplateRows.push({type: GridTrackType.Points, value: 40}); + root_child0.setGridTemplateRows(root_child0GridTemplateRows); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(60); + root_child0_child0.setGridColumnStartSpan(2); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child2, 2); + + const root_child0_child3 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child3, 3); + + const root_child0_child4 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(78); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(78); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(60); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(60); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(9); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(24); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(24); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(36); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(60); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(9); + expect(root_child0_child4.getComputedHeight()).toBe(40); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(78); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(78); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(60); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(9); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(9); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child2.getComputedLeft()).toBe(54); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(24); + expect(root_child0_child2.getComputedHeight()).toBe(40); + + expect(root_child0_child3.getComputedLeft()).toBe(18); + expect(root_child0_child3.getComputedTop()).toBe(40); + expect(root_child0_child3.getComputedWidth()).toBe(36); + expect(root_child0_child3.getComputedHeight()).toBe(40); + + expect(root_child0_child4.getComputedLeft()).toBe(9); + expect(root_child0_child4.getComputedTop()).toBe(40); + expect(root_child0_child4.getComputedWidth()).toBe(9); + expect(root_child0_child4.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/YGAlignBaselineTest.cpp b/tests/YGAlignBaselineTest.cpp index e8c896ce39..60a488c994 100644 --- a/tests/YGAlignBaselineTest.cpp +++ b/tests/YGAlignBaselineTest.cpp @@ -7,6 +7,7 @@ #include #include +#include static float _baselineFunc( YGNodeConstRef /*node*/, @@ -835,3 +836,169 @@ TEST( YGConfigFree(config); } + +TEST(YogaTest, grid_align_baseline_with_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeSetBaselineFunc(root_child0, _baselineFunc); + YGNodeInsertChild(root, root_child0, 0); + // child0 marginTop (10) + baseline (25) = 35 + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 30); + YGNodeSetBaselineFunc(root_child1, _baselineFunc); + YGNodeInsertChild(root, root_child1, 1); + // child1 baseline (15) + // child1 baselineShim = 35 - 15 = 20 + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_align_baseline_with_padding) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeTop, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 20); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 60); + YGNodeSetBaselineFunc(root_child0, _baselineFunc); + YGNodeInsertChild(root, root_child0, 0); + // child0 baseline (30) + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 40); + YGNodeSetBaselineFunc(root_child1, _baselineFunc); + YGNodeInsertChild(root, root_child1, 1); + // child1 baseline (20) + // child1 baselineShim = 30 - 20 = 10 + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + // container padding (20) + child0 baseline (0) = 20 + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + // container padding (20) + child1 baselineShim (10) = 30 + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_align_baseline_nested_child) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child0, 80); + YGNodeStyleSetHeight(root_child0_child0, 60); + YGNodeSetBaselineFunc(root_child0_child0, _baselineFunc); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + // child0 baseline (30) + marginTop (10) = 40 + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeSetBaselineFunc(root_child1, _baselineFunc); + YGNodeInsertChild(root, root_child1, 1); + // child1 baseline (10) + // child1 baselineShim = 40 - 10 = 30 + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + // baselineShim (30) + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/YGHadOverflowTest.cpp b/tests/YGHadOverflowTest.cpp index bbeefe7ee4..aed6f58277 100644 --- a/tests/YGHadOverflowTest.cpp +++ b/tests/YGHadOverflowTest.cpp @@ -133,3 +133,29 @@ TEST_F(YogaTest_HadOverflowTests, spacing_overflow_in_nested_nodes) { ASSERT_TRUE(YGNodeLayoutGetHadOverflow(root)); } + +TEST(YogaTest, grid_hadoverflow_when_content_exceeds_container) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 100); + + YGNodeRef child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(child0, 150); + YGNodeStyleSetHeight(child0, 80); + YGNodeInsertChild(root, child0, 0); + + YGNodeRef child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(child1, 150); + YGNodeStyleSetHeight(child1, 80); + YGNodeInsertChild(root, child1, 1); + + YGNodeCalculateLayout(root, 200, 100, YGDirectionLTR); + + ASSERT_TRUE(YGNodeLayoutGetHadOverflow(root)); + + YGNodeFreeRecursive(root); + YGConfigFree(config); +} diff --git a/tests/generated/YGGridTest.cpp b/tests/generated/YGGridTest.cpp new file mode 100644 index 0000000000..23cafd0f3e --- /dev/null +++ b/tests/generated/YGGridTest.cpp @@ -0,0 +1,4045 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGridTest.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_all_properties) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + auto root_gridAutoColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridAutoColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridAutoColumns, YGPoints(200)); + YGNodeStyleSetGridAutoColumns(root, root_gridAutoColumns); + YGGridTrackListFree(root_gridAutoColumns); + auto root_gridAutoRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridAutoRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridAutoRows, YGPoints(200)); + YGNodeStyleSetGridAutoRows(root, root_gridAutoRows); + YGGridTrackListFree(root_gridAutoRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 5); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 4); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_auto_tracks) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyStretch); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 220); + YGNodeStyleSetHeight(root, 160); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 10); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_auto_tracks_with_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 15); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 40); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 120); + YGNodeStyleSetHeight(root_child1, 40); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child2, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root_child2, YGEdgeTop, 40); + YGNodeStyleSetPadding(root_child2, YGEdgeRight, 40); + YGNodeStyleSetPadding(root_child2, YGEdgeBottom, 40); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(135, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(135, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_auto_tracks_with_margins) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 15); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 40); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child1, 120); + YGNodeStyleSetHeight(root_child1, 40); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child2, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root_child2, YGEdgeTop, 40); + YGNodeStyleSetPadding(root_child2, YGEdgeRight, 40); + YGNodeStyleSetPadding(root_child2, YGEdgeBottom, 40); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(415, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(215, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(415, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(215, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_spanning_items) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 6); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root_child1, YGEdgeTop, 40); + YGNodeStyleSetPadding(root_child1, YGEdgeRight, 40); + YGNodeStyleSetPadding(root_child1, YGEdgeBottom, 40); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_holy_grail) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(60)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 4); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 200); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridColumnEnd(root_child1, 2); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 2); + YGNodeStyleSetGridColumnEnd(root_child2, 3); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 3); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 200); + YGNodeStyleSetHeightPercent(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 3); + YGNodeStyleSetGridColumnEnd(root_child3, 4); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child4, 100); + YGNodeStyleSetHeight(root_child4, 60); + YGNodeStyleSetGridColumnStart(root_child4, 1); + YGNodeStyleSetGridColumnEnd(root_child4, 4); + YGNodeStyleSetGridRowStart(root_child4, 3); + YGNodeStyleSetGridRowEnd(root_child4, 4); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_sidebar_layout) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(250)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 250); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_header_content_footer) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridColumnEnd(root_child1, 2); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 80); + YGNodeStyleSetGridColumnStart(root_child2, 1); + YGNodeStyleSetGridColumnEnd(root_child2, 2); + YGNodeStyleSetGridRowStart(root_child2, 3); + YGNodeStyleSetGridRowEnd(root_child2, 4); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(520, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(520, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_card_layout) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetGap(root, YGGutterColumn, 20); + YGNodeStyleSetGap(root, YGGutterRow, 20); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(250)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(250)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 200); + YGNodeStyleSetHeight(root_child0, 250); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 200); + YGNodeStyleSetHeight(root_child1, 250); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 200); + YGNodeStyleSetHeight(root_child2, 250); + YGNodeStyleSetGridColumnStart(root_child2, 3); + YGNodeStyleSetGridColumnEnd(root_child2, 4); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeStyleSetGridRowEnd(root_child2, 2); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 200); + YGNodeStyleSetHeight(root_child3, 250); + YGNodeStyleSetGridColumnStart(root_child3, 1); + YGNodeStyleSetGridColumnEnd(root_child3, 2); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 200); + YGNodeStyleSetHeight(root_child4, 250); + YGNodeStyleSetGridColumnStart(root_child4, 2); + YGNodeStyleSetGridColumnEnd(root_child4, 3); + YGNodeStyleSetGridRowStart(root_child4, 2); + YGNodeStyleSetGridRowEnd(root_child4, 3); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child5, 200); + YGNodeStyleSetHeight(root_child5, 250); + YGNodeStyleSetGridColumnStart(root_child5, 3); + YGNodeStyleSetGridColumnEnd(root_child5, 4); + YGNodeStyleSetGridRowStart(root_child5, 2); + YGNodeStyleSetGridRowEnd(root_child5, 3); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(440, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(440, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(-40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(-40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_dashboard_layout) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(220)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(70)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 70); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 4); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 220); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridColumnEnd(root_child1, 2); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 4); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 2); + YGNodeStyleSetGridColumnEnd(root_child2, 3); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 3); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child3, 100); + YGNodeStyleSetHeightPercent(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 3); + YGNodeStyleSetGridColumnEnd(root_child3, 4); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child4, 100); + YGNodeStyleSetHeightPercent(root_child4, 100); + YGNodeStyleSetGridColumnStart(root_child4, 2); + YGNodeStyleSetGridColumnEnd(root_child4, 4); + YGNodeStyleSetGridRowStart(root_child4, 3); + YGNodeStyleSetGridRowEnd(root_child4, 4); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(520, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(255, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(370, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(255, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(345, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(255, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(280, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(520, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(255, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(255, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(345, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(255, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_magazine_layout) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 900); + YGNodeStyleSetHeight(root, 700); + YGNodeStyleSetGap(root, YGGutterColumn, 15); + YGNodeStyleSetGap(root, YGGutterRow, 15); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(300)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 300); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 200); + YGNodeStyleSetGridColumnStart(root_child2, 2); + YGNodeStyleSetGridColumnEnd(root_child2, 3); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 3); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child3, 100); + YGNodeStyleSetHeight(root_child3, 200); + YGNodeStyleSetGridColumnStart(root_child3, 1); + YGNodeStyleSetGridColumnEnd(root_child3, 3); + YGNodeStyleSetGridRowStart(root_child3, 3); + YGNodeStyleSetGridRowEnd(root_child3, 4); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(900, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(700, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(590, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(515, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(605, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(295, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(605, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(315, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(295, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(530, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(900, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(900, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(700, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(310, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(590, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(515, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(295, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(315, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(295, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(530, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(900, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_app_layout) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(60)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(60)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetHeight(root_child0, 60); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 60); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 1); + YGNodeStyleSetGridColumnEnd(root_child2, 2); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 3); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child3, 100); + YGNodeStyleSetHeightPercent(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 2); + YGNodeStyleSetGridColumnEnd(root_child3, 3); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child4, 100); + YGNodeStyleSetHeight(root_child4, 50); + YGNodeStyleSetGridColumnStart(root_child4, 1); + YGNodeStyleSetGridColumnEnd(root_child4, 3); + YGNodeStyleSetGridRowStart(root_child4, 3); + YGNodeStyleSetGridRowEnd(root_child4, 4); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(490, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(490, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(550, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(490, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(490, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(550, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_asymmetric_layout) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 200); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridColumnEnd(root_child1, 4); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 1); + YGNodeStyleSetGridColumnEnd(root_child2, 2); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 4); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child3, 100); + YGNodeStyleSetHeight(root_child3, 200); + YGNodeStyleSetGridColumnStart(root_child3, 2); + YGNodeStyleSetGridColumnEnd(root_child3, 3); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child4, 100); + YGNodeStyleSetHeight(root_child4, 200); + YGNodeStyleSetGridColumnStart(root_child4, 2); + YGNodeStyleSetGridColumnEnd(root_child4, 4); + YGNodeStyleSetGridRowStart(root_child4, 3); + YGNodeStyleSetGridRowEnd(root_child4, 4); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(397, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(407, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(410, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(410, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(203, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(194, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(203, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(397, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(203, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(397, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(410, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(407, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(410, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(203, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(194, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(397, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_with_percentage_tracks) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(20)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_percentage_tracks_with_definite_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetGapPercent(root, YGGutterColumn, 10); + YGNodeStyleSetGapPercent(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(20)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_spanning_items_with_span) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStartSpan(root_child0, 2); + YGNodeStyleSetGridRowStartSpan(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(310, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(310, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_mixed_units) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 80); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 4); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 80); + YGNodeStyleSetGridColumnStart(root_child2, 4); + YGNodeStyleSetGridColumnEnd(root_child2, 5); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeStyleSetGridRowEnd(root_child2, 2); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child3, 100); + YGNodeStyleSetHeightPercent(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 1); + YGNodeStyleSetGridColumnEnd(root_child3, 3); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child4, 100); + YGNodeStyleSetHeightPercent(root_child4, 100); + YGNodeStyleSetGridColumnStart(root_child4, 3); + YGNodeStyleSetGridColumnEnd(root_child4, 5); + YGNodeStyleSetGridRowStart(root_child4, 2); + YGNodeStyleSetGridRowEnd(root_child4, 3); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child5, 100); + YGNodeStyleSetHeight(root_child5, 80); + YGNodeStyleSetGridColumnStart(root_child5, 1); + YGNodeStyleSetGridColumnEnd(root_child5, 5); + YGNodeStyleSetGridRowStart(root_child5, 3); + YGNodeStyleSetGridRowEnd(root_child5, 4); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(380, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(233, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(243, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(357, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(380, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(367, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(233, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(357, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_overlapping_items) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 4); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 4); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_implicit_rows) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + auto root_gridAutoRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridAutoRows, YGPoints(80)); + YGNodeStyleSetGridAutoRows(root, root_gridAutoRows); + YGGridTrackListFree(root_gridAutoRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 80); + YGNodeStyleSetGridColumnStart(root_child2, 1); + YGNodeStyleSetGridColumnEnd(root_child2, 2); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 3); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 100); + YGNodeStyleSetHeight(root_child3, 80); + YGNodeStyleSetGridColumnStart(root_child3, 2); + YGNodeStyleSetGridColumnEnd(root_child3, 3); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 100); + YGNodeStyleSetHeight(root_child4, 80); + YGNodeStyleSetGridColumnStart(root_child4, 1); + YGNodeStyleSetGridColumnEnd(root_child4, 2); + YGNodeStyleSetGridRowStart(root_child4, 3); + YGNodeStyleSetGridRowEnd(root_child4, 4); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_implicit_columns) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + auto root_gridAutoColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridAutoColumns, YGPoints(80)); + YGNodeStyleSetGridAutoColumns(root, root_gridAutoColumns); + YGGridTrackListFree(root_gridAutoColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridColumnEnd(root_child1, 2); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 80); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 2); + YGNodeStyleSetGridColumnEnd(root_child2, 3); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeStyleSetGridRowEnd(root_child2, 2); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 80); + YGNodeStyleSetHeight(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 2); + YGNodeStyleSetGridColumnEnd(root_child3, 3); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 80); + YGNodeStyleSetHeight(root_child4, 100); + YGNodeStyleSetGridColumnStart(root_child4, 3); + YGNodeStyleSetGridColumnEnd(root_child4, 4); + YGNodeStyleSetGridRowStart(root_child4, 1); + YGNodeStyleSetGridRowEnd(root_child4, 2); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_complex_spanning) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetGap(root, YGGutterColumn, 5); + YGNodeStyleSetGap(root, YGGutterRow, 5); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridColumnEnd(root_child1, 5); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 3); + YGNodeStyleSetGridColumnEnd(root_child2, 4); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 4); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 100); + YGNodeStyleSetHeight(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 4); + YGNodeStyleSetGridColumnEnd(root_child3, 5); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 100); + YGNodeStyleSetHeightPercent(root_child4, 100); + YGNodeStyleSetGridColumnStart(root_child4, 1); + YGNodeStyleSetGridColumnEnd(root_child4, 2); + YGNodeStyleSetGridRowStart(root_child4, 3); + YGNodeStyleSetGridRowEnd(root_child4, 5); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child5, 100); + YGNodeStyleSetHeight(root_child5, 100); + YGNodeStyleSetGridColumnStart(root_child5, 2); + YGNodeStyleSetGridColumnEnd(root_child5, 3); + YGNodeStyleSetGridRowStart(root_child5, 3); + YGNodeStyleSetGridRowEnd(root_child5, 4); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child6, 100); + YGNodeStyleSetHeight(root_child6, 100); + YGNodeStyleSetGridColumnStart(root_child6, 2); + YGNodeStyleSetGridColumnEnd(root_child6, 5); + YGNodeStyleSetGridRowStart(root_child6, 4); + YGNodeStyleSetGridRowEnd(root_child6, 5); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child7, 100); + YGNodeStyleSetHeight(root_child7, 100); + YGNodeStyleSetGridColumnStart(root_child7, 4); + YGNodeStyleSetGridColumnEnd(root_child7, 5); + YGNodeStyleSetGridRowStart(root_child7, 3); + YGNodeStyleSetGridRowEnd(root_child7, 4); + YGNodeInsertChild(root, root_child7, 7); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(315, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(315, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(310, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(315, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child7)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(195, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-15, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(-15, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(205, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(195, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(-15, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(315, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(310, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(-15, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child7)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_sparse_placement) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridColumnEnd(root_child1, 4); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 2); + YGNodeStyleSetGridColumnEnd(root_child2, 3); + YGNodeStyleSetGridRowStart(root_child2, 3); + YGNodeStyleSetGridRowEnd(root_child2, 4); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 100); + YGNodeStyleSetHeight(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 4); + YGNodeStyleSetGridColumnEnd(root_child3, 5); + YGNodeStyleSetGridRowStart(root_child3, 1); + YGNodeStyleSetGridRowEnd(root_child3, 2); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_negative_line_numbers) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, -1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridColumnEnd(root_child1, -2); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, -2); + YGNodeStyleSetGridColumnEnd(root_child2, -1); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, -1); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 100); + YGNodeStyleSetHeight(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 1); + YGNodeStyleSetGridColumnEnd(root_child3, 2); + YGNodeStyleSetGridRowStart(root_child3, -2); + YGNodeStyleSetGridRowEnd(root_child3, -1); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_all_fractional_units) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(3)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(2)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 3); + YGNodeStyleSetGridColumnEnd(root_child2, 4); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeStyleSetGridRowEnd(root_child2, 4); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child3, 100); + YGNodeStyleSetHeightPercent(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 1); + YGNodeStyleSetGridColumnEnd(root_child3, 3); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child4, 100); + YGNodeStyleSetHeightPercent(root_child4, 100); + YGNodeStyleSetGridColumnStart(root_child4, 1); + YGNodeStyleSetGridColumnEnd(root_child4, 2); + YGNodeStyleSetGridRowStart(root_child4, 3); + YGNodeStyleSetGridRowEnd(root_child4, 4); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child5, 100); + YGNodeStyleSetHeightPercent(root_child5, 100); + YGNodeStyleSetGridColumnStart(root_child5, 2); + YGNodeStyleSetGridColumnEnd(root_child5, 3); + YGNodeStyleSetGridRowStart(root_child5, 3); + YGNodeStyleSetGridRowEnd(root_child5, 4); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_uniform_cells) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 3); + YGNodeStyleSetGridColumnEnd(root_child2, 4); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeStyleSetGridRowEnd(root_child2, 2); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child3, 100); + YGNodeStyleSetHeightPercent(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 4); + YGNodeStyleSetGridColumnEnd(root_child3, 5); + YGNodeStyleSetGridRowStart(root_child3, 1); + YGNodeStyleSetGridRowEnd(root_child3, 2); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child4, 100); + YGNodeStyleSetHeightPercent(root_child4, 100); + YGNodeStyleSetGridColumnStart(root_child4, 1); + YGNodeStyleSetGridColumnEnd(root_child4, 2); + YGNodeStyleSetGridRowStart(root_child4, 2); + YGNodeStyleSetGridRowEnd(root_child4, 3); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child5, 100); + YGNodeStyleSetHeightPercent(root_child5, 100); + YGNodeStyleSetGridColumnStart(root_child5, 2); + YGNodeStyleSetGridColumnEnd(root_child5, 3); + YGNodeStyleSetGridRowStart(root_child5, 2); + YGNodeStyleSetGridRowEnd(root_child5, 3); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child6, 100); + YGNodeStyleSetHeightPercent(root_child6, 100); + YGNodeStyleSetGridColumnStart(root_child6, 3); + YGNodeStyleSetGridColumnEnd(root_child6, 4); + YGNodeStyleSetGridRowStart(root_child6, 2); + YGNodeStyleSetGridRowEnd(root_child6, 3); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child7, 100); + YGNodeStyleSetHeightPercent(root_child7, 100); + YGNodeStyleSetGridColumnStart(root_child7, 4); + YGNodeStyleSetGridColumnEnd(root_child7, 5); + YGNodeStyleSetGridRowStart(root_child7, 2); + YGNodeStyleSetGridRowEnd(root_child7, 3); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child8, 100); + YGNodeStyleSetHeightPercent(root_child8, 100); + YGNodeStyleSetGridColumnStart(root_child8, 1); + YGNodeStyleSetGridColumnEnd(root_child8, 2); + YGNodeStyleSetGridRowStart(root_child8, 3); + YGNodeStyleSetGridRowEnd(root_child8, 4); + YGNodeInsertChild(root, root_child8, 8); + + YGNodeRef root_child9 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child9, 100); + YGNodeStyleSetHeightPercent(root_child9, 100); + YGNodeStyleSetGridColumnStart(root_child9, 2); + YGNodeStyleSetGridColumnEnd(root_child9, 3); + YGNodeStyleSetGridRowStart(root_child9, 3); + YGNodeStyleSetGridRowEnd(root_child9, 4); + YGNodeInsertChild(root, root_child9, 9); + + YGNodeRef root_child10 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child10, 100); + YGNodeStyleSetHeightPercent(root_child10, 100); + YGNodeStyleSetGridColumnStart(root_child10, 3); + YGNodeStyleSetGridColumnEnd(root_child10, 4); + YGNodeStyleSetGridRowStart(root_child10, 3); + YGNodeStyleSetGridRowEnd(root_child10, 4); + YGNodeInsertChild(root, root_child10, 10); + + YGNodeRef root_child11 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child11, 100); + YGNodeStyleSetHeightPercent(root_child11, 100); + YGNodeStyleSetGridColumnStart(root_child11, 4); + YGNodeStyleSetGridColumnEnd(root_child11, 5); + YGNodeStyleSetGridRowStart(root_child11, 3); + YGNodeStyleSetGridRowEnd(root_child11, 4); + YGNodeInsertChild(root, root_child11, 11); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child8)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child9)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child9)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child9)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child9)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child10)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child10)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child10)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child10)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child11)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child11)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child11)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child11)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child8)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child9)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child9)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child9)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child9)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child10)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child10)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child10)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child10)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child11)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child11)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child11)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child11)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_auto_placement_row) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 100); + YGNodeStyleSetHeight(root_child3, 100); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_large_spans) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 250); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 6); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 5); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 3); + YGNodeStyleSetGridColumnEnd(root_child2, 6); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 5); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_unequal_fractions) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(3)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 3); + YGNodeStyleSetGridColumnEnd(root_child2, 4); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeStyleSetGridRowEnd(root_child2, 3); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child3, 100); + YGNodeStyleSetHeightPercent(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 1); + YGNodeStyleSetGridColumnEnd(root_child3, 3); + YGNodeStyleSetGridRowStart(root_child3, 2); + YGNodeStyleSetGridRowEnd(root_child3, 3); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_single_cell) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(300)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 300); + YGNodeStyleSetHeight(root_child0, 200); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_single_column) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 470); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(120)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 200); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 200); + YGNodeStyleSetHeight(root_child1, 150); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridColumnEnd(root_child1, 2); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 200); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 1); + YGNodeStyleSetGridColumnEnd(root_child2, 2); + YGNodeStyleSetGridRowStart(root_child2, 3); + YGNodeStyleSetGridRowEnd(root_child2, 4); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 200); + YGNodeStyleSetHeight(root_child3, 120); + YGNodeStyleSetGridColumnStart(root_child3, 1); + YGNodeStyleSetGridColumnEnd(root_child3, 2); + YGNodeStyleSetGridRowStart(root_child3, 4); + YGNodeStyleSetGridRowEnd(root_child3, 5); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(470, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(470, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_single_row) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 470); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(120)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 200); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 150); + YGNodeStyleSetHeight(root_child1, 200); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 200); + YGNodeStyleSetGridColumnStart(root_child2, 3); + YGNodeStyleSetGridColumnEnd(root_child2, 4); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeStyleSetGridRowEnd(root_child2, 2); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 120); + YGNodeStyleSetHeight(root_child3, 200); + YGNodeStyleSetGridColumnStart(root_child3, 4); + YGNodeStyleSetGridColumnEnd(root_child3, 5); + YGNodeStyleSetGridRowStart(root_child3, 1); + YGNodeStyleSetGridRowEnd(root_child3, 2); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(470, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(470, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(370, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_tall_narrow) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(50)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 5); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 50); + YGNodeStyleSetGridColumnStart(root_child2, 2); + YGNodeStyleSetGridColumnEnd(root_child2, 3); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 3); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 100); + YGNodeStyleSetHeight(root_child3, 50); + YGNodeStyleSetGridColumnStart(root_child3, 2); + YGNodeStyleSetGridColumnEnd(root_child3, 3); + YGNodeStyleSetGridRowStart(root_child3, 3); + YGNodeStyleSetGridRowEnd(root_child3, 4); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 100); + YGNodeStyleSetHeight(root_child4, 50); + YGNodeStyleSetGridColumnStart(root_child4, 2); + YGNodeStyleSetGridColumnEnd(root_child4, 3); + YGNodeStyleSetGridRowStart(root_child4, 4); + YGNodeStyleSetGridRowEnd(root_child4, 5); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child5, 100); + YGNodeStyleSetHeightPercent(root_child5, 100); + YGNodeStyleSetGridColumnStart(root_child5, 1); + YGNodeStyleSetGridColumnEnd(root_child5, 3); + YGNodeStyleSetGridRowStart(root_child5, 5); + YGNodeStyleSetGridRowEnd(root_child5, 9); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_wide_short) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(50)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 5); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeStyleSetGridColumnStart(root_child1, 5); + YGNodeStyleSetGridColumnEnd(root_child1, 6); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 6); + YGNodeStyleSetGridColumnEnd(root_child2, 7); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeStyleSetGridRowEnd(root_child2, 2); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 100); + YGNodeStyleSetGridColumnStart(root_child3, 7); + YGNodeStyleSetGridColumnEnd(root_child3, 8); + YGNodeStyleSetGridRowStart(root_child3, 1); + YGNodeStyleSetGridRowEnd(root_child3, 2); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 50); + YGNodeStyleSetHeight(root_child4, 100); + YGNodeStyleSetGridColumnStart(root_child4, 8); + YGNodeStyleSetGridColumnEnd(root_child4, 9); + YGNodeStyleSetGridRowStart(root_child4, 1); + YGNodeStyleSetGridRowEnd(root_child4, 2); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child5, 100); + YGNodeStyleSetHeight(root_child5, 100); + YGNodeStyleSetGridColumnStart(root_child5, 1); + YGNodeStyleSetGridColumnEnd(root_child5, 5); + YGNodeStyleSetGridRowStart(root_child5, 2); + YGNodeStyleSetGridRowEnd(root_child5, 3); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child6, 100); + YGNodeStyleSetHeight(root_child6, 100); + YGNodeStyleSetGridColumnStart(root_child6, 6); + YGNodeStyleSetGridColumnEnd(root_child6, 9); + YGNodeStyleSetGridRowStart(root_child6, 2); + YGNodeStyleSetGridRowEnd(root_child6, 3); + YGNodeInsertChild(root, root_child6, 6); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child6)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child6)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_gap_percentage_definite_size_2) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 1); + YGNodeStyleSetBorder(root, YGEdgeTop, 1); + YGNodeStyleSetBorder(root, YGEdgeRight, 1); + YGNodeStyleSetBorder(root, YGEdgeBottom, 1); + YGNodeStyleSetGapPercent(root, YGGutterColumn, 70); + YGNodeStyleSetGapPercent(root, YGGutterRow, 40); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(10)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(10)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(10)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 20); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 4); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 20); + YGNodeStyleSetPadding(root_child1, YGEdgeTop, 20); + YGNodeStyleSetPadding(root_child1, YGEdgeRight, 20); + YGNodeStyleSetPadding(root_child1, YGEdgeBottom, 20); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child2, YGEdgeLeft, 20); + YGNodeStyleSetPadding(root_child2, YGEdgeTop, 20); + YGNodeStyleSetPadding(root_child2, YGEdgeRight, 20); + YGNodeStyleSetPadding(root_child2, YGEdgeBottom, 20); + YGNodeStyleSetGridColumnStart(root_child2, 2); + YGNodeStyleSetGridColumnEnd(root_child2, 5); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(185, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(57, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(73, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(-47, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-143, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(-111, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(73, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/YGGridTestFlows.cpp b/tests/generated/YGGridTestFlows.cpp new file mode 100644 index 0000000000..070b25bc29 --- /dev/null +++ b/tests/generated/YGGridTestFlows.cpp @@ -0,0 +1,6916 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGridTestFlows.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_indefinite_container_size_percentage_tracks) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(80)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child2, YGEdgeLeft, 30); + YGNodeStyleSetPadding(root_child2, YGEdgeTop, 30); + YGNodeStyleSetPadding(root_child2, YGEdgeRight, 30); + YGNodeStyleSetPadding(root_child2, YGEdgeBottom, 30); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetMinWidth(root_child3, 40); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetBorder(root_child4, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root_child4, YGEdgeTop, 10); + YGNodeStyleSetBorder(root_child4, YGEdgeRight, 10); + YGNodeStyleSetBorder(root_child4, YGEdgeBottom, 10); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(104, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(234, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(104, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(104, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(-234, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(156, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(104, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(26, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_definite_container_size_percentage_tracks) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetGapPercent(root, YGGutterColumn, 20); + YGNodeStyleSetGapPercent(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(50)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(80)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMinWidth(root_child0, 40); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child2, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root_child2, YGEdgeTop, 40); + YGNodeStyleSetPadding(root_child2, YGEdgeRight, 40); + YGNodeStyleSetPadding(root_child2, YGEdgeBottom, 40); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginPercent(root_child3, YGEdgeLeft, 10); + YGNodeStyleSetMarginPercent(root_child3, YGEdgeTop, 10); + YGNodeStyleSetMarginPercent(root_child3, YGEdgeRight, 10); + YGNodeStyleSetMarginPercent(root_child3, YGEdgeBottom, 10); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(390, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(122, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(216, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-30, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(-390, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(192, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(122, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(216, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, init_track_fixed_sizing) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(120)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, init_track_intrinsic_sizing) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 150); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 120); + YGNodeStyleSetHeight(root_child2, 70); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, init_track_flexible_sizing) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, init_track_mixed_sizing) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 80); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(280, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, resolve_intrinsic_single_span) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 140); + YGNodeStyleSetHeight(root_child2, 70); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 110); + YGNodeStyleSetHeight(root_child3, 85); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 130); + YGNodeStyleSetHeight(root_child4, 95); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(390, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(185, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(390, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(185, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(280, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, resolve_intrinsic_multi_span) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 250); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 80); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 110); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 300); + YGNodeStyleSetHeight(root_child3, 120); + YGNodeStyleSetGridColumnStart(root_child3, 2); + YGNodeStyleSetGridColumnEnd(root_child3, 4); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, resolve_intrinsic_flexible_tracks) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 300); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 120); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(280, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, resolve_intrinsic_progressive_spans) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 110); + YGNodeStyleSetHeight(root_child1, 85); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 90); + YGNodeStyleSetHeight(root_child2, 75); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 105); + YGNodeStyleSetHeight(root_child3, 82); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 250); + YGNodeStyleSetHeight(root_child4, 90); + YGNodeStyleSetGridColumnStart(root_child4, 1); + YGNodeStyleSetGridColumnEnd(root_child4, 3); + YGNodeStyleSetGridRowStart(root_child4, 2); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child5, 230); + YGNodeStyleSetHeight(root_child5, 95); + YGNodeStyleSetGridColumnStart(root_child5, 3); + YGNodeStyleSetGridColumnEnd(root_child5, 5); + YGNodeStyleSetGridRowStart(root_child5, 2); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child6, 380); + YGNodeStyleSetHeight(root_child6, 100); + YGNodeStyleSetGridColumnStart(root_child6, 1); + YGNodeStyleSetGridColumnEnd(root_child6, 4); + YGNodeStyleSetGridRowStart(root_child6, 3); + YGNodeInsertChild(root, root_child6, 6); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(508, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(131, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(272, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(390, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(272, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(380, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child6)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(508, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(408, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(267, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(146, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(82, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(258, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(380, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child6)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, maximize_tracks_definite_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 120); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 110); + YGNodeStyleSetHeight(root_child2, 85); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(280, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, maximize_tracks_max_constraint) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetMaxWidth(root, 400); + YGNodeStyleSetMaxHeight(root, 250); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 150); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 160); + YGNodeStyleSetHeight(root_child1, 110); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 170); + YGNodeStyleSetHeight(root_child2, 105); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(310, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(-80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, expand_flexible_definite_free_space) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(133, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(233, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(267, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(367, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(133, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(267, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, expand_flexible_min_constraint) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetMinWidth(root, 600); + YGNodeStyleSetMinHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 55); + YGNodeStyleSetHeight(root_child2, 55); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(550, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(390, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, expand_flexible_max_constraint) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 800); + YGNodeStyleSetMaxWidth(root, 500); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetMaxHeight(root, 350); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(175, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(175, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(375, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(175, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(375, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(175, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(175, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(125, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(175, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, expand_flexible_flex_less_than_one) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0.5f)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0.3f)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0.2f)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(0.6f)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(0.4f)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, expand_flexible_spanning_items) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 450); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(225, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(375, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(225, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, stretch_auto_justify_content_stretch) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyStretch); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 120); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 110); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(290, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, stretch_auto_align_content_stretch) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignStretch); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 120); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 110); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(243, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(243, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, stretch_auto_both_axes) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyStretch); + YGNodeStyleSetAlignContent(root, YGAlignStretch); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 120); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 110); + YGNodeStyleSetHeight(root_child2, 85); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(290, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_content_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyCenter); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_content_space_between) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_content_space_around) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(367, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(367, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_content_space_evenly) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceEvenly); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_content_start) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignStart); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_content_end) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignEnd); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_content_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignCenter); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_content_space_between) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceBetween); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_content_space_around) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceAround); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(367, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(367, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_content_space_evenly) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceEvenly); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_self_start) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStart); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child1, YGJustifyStart); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_self_end) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyEnd); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child1, YGJustifyEnd); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_self_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyCenter); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child1, YGJustifyCenter); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_self_stretch) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStretch); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child1, YGJustifyStretch); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_self_auto_margin_left) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child1, YGEdgeLeft); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_self_auto_margin_right) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child1, YGEdgeRight); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, justify_self_auto_margin_both) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child1, YGEdgeLeft); + YGNodeStyleSetMarginAuto(root_child1, YGEdgeRight); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_self_start) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child0, YGAlignStart); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child1, YGAlignStart); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_self_end) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child0, YGAlignEnd); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child1, YGAlignEnd); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_align_self_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child1, YGAlignCenter); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_align_self_stretch) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_self_auto_margin_top) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child1, YGEdgeTop); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_self_auto_margin_bottom) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child1, YGEdgeBottom); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_self_auto_margin_both) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child1, YGEdgeTop); + YGNodeStyleSetMarginAuto(root_child1, YGEdgeBottom); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, minimum_contribution_auto) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 150); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, minimum_contribution_definite) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 150); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, minimum_contribution_percentage_definite) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 30); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 40); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, minimum_contribution_min_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetMinWidth(root_child0, 150); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetMinWidth(root_child1, 180); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, content_based_min_definite_length) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 150); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 180); + YGNodeStyleSetHeight(root_child1, 120); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, content_based_min_aspect_ratio) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 150); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeStyleSetAspectRatio(root_child1, 0.5 / 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, content_based_min_content_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 20); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 15); + YGNodeStyleSetPadding(root_child1, YGEdgeTop, 15); + YGNodeStyleSetPadding(root_child1, YGEdgeRight, 15); + YGNodeStyleSetPadding(root_child1, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child1, 120); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, content_based_min_fixed_track_clamp) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 300); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 250); + YGNodeStyleSetHeight(root_child1, 120); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, content_based_min_span_fixed_max) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 500); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 120); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(470, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(470, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(-30, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, max_content_contribution_basic) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 150); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 180); + YGNodeStyleSetHeight(root_child1, 120); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, max_content_contribution_margins) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 10); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0, 150); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1, YGEdgeLeft, 15); + YGNodeStyleSetMargin(root_child1, YGEdgeTop, 15); + YGNodeStyleSetMargin(root_child1, YGEdgeRight, 15); + YGNodeStyleSetMargin(root_child1, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child1, 180); + YGNodeStyleSetHeight(root_child1, 120); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(380, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(185, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(380, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, limited_min_content_fixed_limit) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 400); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 120); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(310, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(310, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(-90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, limited_min_content_no_limit) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 400); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 120); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, percentage_tracks_definite_container) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(30)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(50)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(60)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, percentage_tracks_indefinite_container) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(30)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 120); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 110); + YGNodeStyleSetHeight(root_child2, 85); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(66, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(165, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(144, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(85, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, percentage_tracks_mixed_fixed) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(30)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, percentage_gap_definite_container) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetGapPercent(root, YGGutterColumn, 10); + YGNodeStyleSetGapPercent(root, YGGutterRow, 20); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, spanning_items_span_2) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 250); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 110); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(480, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(370, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(480, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, spanning_items_span_3) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 380); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 4); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(490, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(380, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(390, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(490, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(380, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, spanning_items_overlapping) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 250); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 280); + YGNodeStyleSetHeight(root_child1, 120); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEnd(root_child1, 4); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(280, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(420, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(280, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, spanning_items_both_axes) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 250); + YGNodeStyleSetHeight(root_child0, 230); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 110); + YGNodeStyleSetHeight(root_child2, 110); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(370, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(115, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(370, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(115, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, auto_margins_inline_left) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(300)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); + YGNodeStyleSetWidth(root_child0, 150); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, auto_margins_inline_right) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(300)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); + YGNodeStyleSetWidth(root_child0, 150); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, auto_margins_inline_both) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(300)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); + YGNodeStyleSetWidth(root_child0, 150); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, auto_margins_block_top) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(300)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 150); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, auto_margins_block_bottom) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(300)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 150); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, auto_margins_block_both) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(300)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 150); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, auto_margins_overrides_justify_self) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(300)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStart); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); + YGNodeStyleSetWidth(root_child0, 150); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, auto_margins_overrides_align_self) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(300)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child0, YGAlignStart); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 150); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, min_max_constraints_min_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 80); + YGNodeStyleSetMinWidth(root_child0, 150); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 90); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, min_max_constraints_max_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetMaxWidth(root_child0, 120); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(280, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, min_max_constraints_min_height) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 80); + YGNodeStyleSetMinHeight(root_child0, 150); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 90); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, min_max_constraints_max_height) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(200)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetMaxHeight(root_child0, 120); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, min_max_constraints_both) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 80); + YGNodeStyleSetMinWidth(root_child0, 100); + YGNodeStyleSetMaxWidth(root_child0, 150); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 200); + YGNodeStyleSetMinWidth(root_child1, 100); + YGNodeStyleSetMaxWidth(root_child1, 130); + YGNodeStyleSetHeight(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, gaps_justify_space_between) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetGap(root, YGGutterColumn, 20); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, gaps_align_space_around) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceAround); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetGap(root, YGGutterRow, 20); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(27, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(373, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(27, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(373, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, gaps_both_space_evenly) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceEvenly); + YGNodeStyleSetAlignContent(root, YGAlignSpaceEvenly); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetGap(root, YGGutterColumn, 15); + YGNodeStyleSetGap(root, YGGutterRow, 15); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(358, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(358, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(43, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, gaps_spanning_items) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 20); + YGNodeStyleSetGap(root, YGGutterRow, 20); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 4); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(340, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, complex_flexible_min_max_distribution) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetMinWidth(root, 400); + YGNodeStyleSetMaxWidth(root, 800); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetGap(root, YGGutterColumn, 15); + YGNodeStyleSetGap(root, YGGutterRow, 15); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetMinWidth(root_child0, 150); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetMaxWidth(root_child1, 250); + YGNodeStyleSetHeightPercent(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(165, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(460, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(185, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, complex_all_features_combined) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceEvenly); + YGNodeStyleSetJustifyItems(root, YGJustifyCenter); + YGNodeStyleSetAlignContent(root, YGAlignSpaceBetween); + YGNodeStyleSetAlignItems(root, YGAlignCenter); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 800); + YGNodeStyleSetHeight(root, 600); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(30)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child0, YGAlignEnd); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetWidth(root_child0, 350); + YGNodeStyleSetHeight(root_child0, 180); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 4); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 150); + YGNodeStyleSetMaxHeight(root_child1, 100); + YGNodeStyleSetAspectRatio(root_child1, 2 / 1); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetMinWidth(root_child2, 200); + YGNodeStyleSetMaxWidth(root_child2, 300); + YGNodeStyleSetHeightPercent(root_child2, 100); + YGNodeStyleSetGridColumnStart(root_child2, 2); + YGNodeStyleSetGridColumnEnd(root_child2, 4); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child3, YGEdgeLeft); + YGNodeStyleSetMarginAuto(root_child3, YGEdgeTop); + YGNodeStyleSetMarginAuto(root_child3, YGEdgeRight); + YGNodeStyleSetMarginAuto(root_child3, YGEdgeBottom); + YGNodeStyleSetAspectRatio(root_child3, 1 / 1); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child4, YGJustifyStretch); + YGNodeStyleSetAlignSelf(root_child4, YGAlignStretch); + YGNodeStyleSetWidthPercent(root_child4, 100); + YGNodeStyleSetHeightPercent(root_child4, 100); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(800, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(390, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(465, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(560, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(800, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(430, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(335, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_absolute_position_items) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child2, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child2, YGEdgeLeft, 50); + YGNodeStyleSetPosition(root_child2, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child3, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child3, YGEdgeLeft, 80); + YGNodeStyleSetPosition(root_child3, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child3, 100); + YGNodeStyleSetHeight(root_child3, 100); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_display_none_items) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetDisplay(root_child1, YGDisplayNone); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, grid_item_with_display_contents_items) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetBorder(root_child1, YGEdgeLeft, 2); + YGNodeStyleSetBorder(root_child1, YGEdgeTop, 2); + YGNodeStyleSetBorder(root_child1, YGEdgeRight, 2); + YGNodeStyleSetBorder(root_child1, YGEdgeBottom, 2); + YGNodeStyleSetDisplay(root_child1, YGDisplayContents); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 100); + YGNodeStyleSetHeight(root_child1_child0, 100); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 100); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, text_wraps_in_fixed_sized_column_tracks) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"Lorem ipsum dolor sit amet, consectetur"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, text_wraps_in_fixed_sized_column_tracks_max_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMaxWidth(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"Lorem ipsum dolor sit amet, consectetur"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, text_wraps_in_fixed_sized_column_tracks_min_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetMinWidth(root_child0, 180); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"Lorem ipsum dolor sit amet, consectetur"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/absolute_correct_cross_child_size_with_percentage.cpp b/tests/generated/absolute_correct_cross_child_size_with_percentage.cpp new file mode 100644 index 0000000000..d9a6d59234 --- /dev/null +++ b/tests/generated/absolute_correct_cross_child_size_with_percentage.cpp @@ -0,0 +1,116 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<15d08c3e3891359c972f6da433b15772>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/absolute_correct_cross_child_size_with_percentage.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, absolute_correct_cross_child_size_with_percentage) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetHeight(root, 110); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 50); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 40); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child0, 200); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0_child1, 100); + YGNodeStyleSetHeight(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0_child2, 100); + YGNodeStyleSetHeight(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child2_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child2_child0, 10); + YGNodeStyleSetHeight(root_child0_child2_child0, 10); + YGNodeInsertChild(root_child0_child2, root_child0_child2_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child2_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(190, YGNodeLayoutGetLeft(root_child0_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child2_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/chrome_issue_325928327.cpp b/tests/generated/chrome_issue_325928327.cpp new file mode 100644 index 0000000000..b06150f601 --- /dev/null +++ b/tests/generated/chrome_issue_325928327.cpp @@ -0,0 +1,84 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<70665dfbde26a5257cc392f46dbe840e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/chrome_issue_325928327.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, chrome_issue_325928327_container) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyItems(root_child0, YGJustifyCenter); + YGNodeStyleSetWidthPercent(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 40); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeightPercent(root_child0_child0, 100); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeightPercent(root_child0_child0_child0, 100); + YGNodeStyleSetAspectRatio(root_child0_child0_child0, 1 / 1); + YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_align_self_sized_all.cpp b/tests/generated/grid_absolute_align_self_sized_all.cpp new file mode 100644 index 0000000000..ac9a0de864 --- /dev/null +++ b/tests/generated/grid_absolute_align_self_sized_all.cpp @@ -0,0 +1,187 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<9cfd1a88d4e990dc25302a657b96a60f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_align_self_sized_all.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_align_self_sized_all) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child0, YGAlignStart); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child1, YGAlignStart); + YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child2, YGAlignEnd); + YGNodeStyleSetPositionType(root_child2, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child2, 20); + YGNodeStyleSetHeight(root_child2, 20); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child3, YGAlignEnd); + YGNodeStyleSetPositionType(root_child3, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child3, 60); + YGNodeStyleSetHeight(root_child3, 60); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child4, YGAlignCenter); + YGNodeStyleSetPositionType(root_child4, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child4, 20); + YGNodeStyleSetHeight(root_child4, 20); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child5, YGAlignCenter); + YGNodeStyleSetPositionType(root_child5, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child5, 60); + YGNodeStyleSetHeight(root_child5, 60); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child6, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child6, 20); + YGNodeStyleSetHeight(root_child6, 20); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child7, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child7, 60); + YGNodeStyleSetHeight(root_child7, 60); + YGNodeInsertChild(root, root_child7, 7); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child7)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child7)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_bottom_left.cpp b/tests/generated/grid_absolute_container_bottom_left.cpp new file mode 100644 index 0000000000..8e7bb5fe69 --- /dev/null +++ b/tests/generated/grid_absolute_container_bottom_left.cpp @@ -0,0 +1,175 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_bottom_left.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_bottom_left) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 0); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_bottom_left_margin.cpp b/tests/generated/grid_absolute_container_bottom_left_margin.cpp new file mode 100644 index 0000000000..099fa7096e --- /dev/null +++ b/tests/generated/grid_absolute_container_bottom_left_margin.cpp @@ -0,0 +1,181 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<9cdeaac6eefaa9516ebbc181e4e05c9b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_bottom_left_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_bottom_left_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 0); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(4, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(4, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_left_overrides_right.cpp b/tests/generated/grid_absolute_container_left_overrides_right.cpp new file mode 100644 index 0000000000..a78e647505 --- /dev/null +++ b/tests/generated/grid_absolute_container_left_overrides_right.cpp @@ -0,0 +1,72 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<015fcb88c5b1eec9a18c0070f48f0b7c>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_left_overrides_right.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_left_overrides_right) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 2); + YGNodeStyleSetWidth(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(168, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_left_right.cpp b/tests/generated/grid_absolute_container_left_right.cpp new file mode 100644 index 0000000000..f10b5a4cd5 --- /dev/null +++ b/tests/generated/grid_absolute_container_left_right.cpp @@ -0,0 +1,175 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<3039b355aca8c41b57c7d4890e4c3d6f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_left_right.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_left_right) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(173, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(173, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_left_right_margin.cpp b/tests/generated/grid_absolute_container_left_right_margin.cpp new file mode 100644 index 0000000000..6be0f83174 --- /dev/null +++ b/tests/generated/grid_absolute_container_left_right_margin.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<83e63e18daf57e1dcf1df8e75b090296>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_left_right_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_left_right_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(167, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(167, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_negative_position.cpp b/tests/generated/grid_absolute_container_negative_position.cpp new file mode 100644 index 0000000000..9b5089508f --- /dev/null +++ b/tests/generated/grid_absolute_container_negative_position.cpp @@ -0,0 +1,178 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_negative_position.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_negative_position) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, -5); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, -15); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child1, YGEdgeLeft, -35); + YGNodeStyleSetPosition(root_child1, YGEdgeBottom, -25); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(195, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(-5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-35, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(185, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(195, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(-5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-35, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(185, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_negative_position_margin.cpp b/tests/generated/grid_absolute_container_negative_position_margin.cpp new file mode 100644 index 0000000000..5f2793f0af --- /dev/null +++ b/tests/generated/grid_absolute_container_negative_position_margin.cpp @@ -0,0 +1,186 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<8090f8a18eb87949ef066af9fb4e8300>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_negative_position_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_negative_position_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, -5); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, -15); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child1, YGEdgeLeft, -35); + YGNodeStyleSetPosition(root_child1, YGEdgeBottom, -25); + YGNodeStyleSetMargin(root_child1, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child1, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child1, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child1, YGEdgeBottom, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(-4, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-31, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(182, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(193, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(-4, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-31, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(182, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_top_bottom.cpp b/tests/generated/grid_absolute_container_top_bottom.cpp new file mode 100644 index 0000000000..0c8c07790a --- /dev/null +++ b/tests/generated/grid_absolute_container_top_bottom.cpp @@ -0,0 +1,175 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<26524e8c31632dd286228f9b0571b06b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_bottom.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_top_bottom) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 5); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(153, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(153, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_top_bottom_margin.cpp b/tests/generated/grid_absolute_container_top_bottom_margin.cpp new file mode 100644 index 0000000000..9a7c6835d4 --- /dev/null +++ b/tests/generated/grid_absolute_container_top_bottom_margin.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<1c26b2335fe9fb08342b23f810819941>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_bottom_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_top_bottom_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(4, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(149, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(178, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(149, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_top_right.cpp b/tests/generated/grid_absolute_container_top_right.cpp new file mode 100644 index 0000000000..a93df48bfe --- /dev/null +++ b/tests/generated/grid_absolute_container_top_right.cpp @@ -0,0 +1,175 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<67cb72aa84bb2cdfa297bb6162937ea3>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_right.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_top_right) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 0); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_container_top_right_margin.cpp b/tests/generated/grid_absolute_container_top_right_margin.cpp new file mode 100644 index 0000000000..6dfa23464a --- /dev/null +++ b/tests/generated/grid_absolute_container_top_right_margin.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<172aa1081d9c350e37024733a835288f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_container_top_right_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_container_top_right_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 0); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(178, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(178, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_justify_self_sized_all.cpp b/tests/generated/grid_absolute_justify_self_sized_all.cpp new file mode 100644 index 0000000000..2e1ec153d7 --- /dev/null +++ b/tests/generated/grid_absolute_justify_self_sized_all.cpp @@ -0,0 +1,189 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<77e1e9d9b91604f3cbb67c6cfd9dad27>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_justify_self_sized_all.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_justify_self_sized_all) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStart); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child1, YGJustifyStart); + YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child2, YGJustifyEnd); + YGNodeStyleSetPositionType(root_child2, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child2, 20); + YGNodeStyleSetHeight(root_child2, 20); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child3, YGJustifyEnd); + YGNodeStyleSetPositionType(root_child3, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child3, 60); + YGNodeStyleSetHeight(root_child3, 60); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child4, YGJustifyCenter); + YGNodeStyleSetPositionType(root_child4, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child4, 20); + YGNodeStyleSetHeight(root_child4, 20); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child5, YGJustifyCenter); + YGNodeStyleSetPositionType(root_child5, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child5, 60); + YGNodeStyleSetHeight(root_child5, 60); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child6, YGJustifyStretch); + YGNodeStyleSetPositionType(root_child6, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child6, 20); + YGNodeStyleSetHeight(root_child6, 20); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child7, YGJustifyStretch); + YGNodeStyleSetPositionType(root_child7, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child7, 60); + YGNodeStyleSetHeight(root_child7, 60); + YGNodeInsertChild(root, root_child7, 7); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child7)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child7)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_layout_within_border.cpp b/tests/generated/grid_absolute_layout_within_border.cpp new file mode 100644 index 0000000000..201bfcb40b --- /dev/null +++ b/tests/generated/grid_absolute_layout_within_border.cpp @@ -0,0 +1,129 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_layout_within_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_layout_within_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child1, YGEdgeRight, 0); + YGNodeStyleSetPosition(root_child1, YGEdgeBottom, 0); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child2, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child2, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child2, YGEdgeTop, 0); + YGNodeStyleSetMargin(root_child2, YGEdgeLeft, 10); + YGNodeStyleSetMargin(root_child2, YGEdgeTop, 10); + YGNodeStyleSetMargin(root_child2, YGEdgeRight, 10); + YGNodeStyleSetMargin(root_child2, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child3, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child3, YGEdgeRight, 0); + YGNodeStyleSetPosition(root_child3, YGEdgeBottom, 0); + YGNodeStyleSetMargin(root_child3, YGEdgeLeft, 10); + YGNodeStyleSetMargin(root_child3, YGEdgeTop, 10); + YGNodeStyleSetMargin(root_child3, YGEdgeRight, 10); + YGNodeStyleSetMargin(root_child3, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 50); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_layout_within_border_static.cpp b/tests/generated/grid_absolute_layout_within_border_static.cpp new file mode 100644 index 0000000000..9922f83206 --- /dev/null +++ b/tests/generated/grid_absolute_layout_within_border_static.cpp @@ -0,0 +1,129 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<47d54aa569c6e39b9cad301bc0babc6d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_layout_within_border_static.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_layout_within_border_static) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 10); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 10); + YGNodeStyleSetPadding(root, YGEdgeBottom, 10); + YGNodeStyleSetBorder(root, YGEdgeLeft, 10); + YGNodeStyleSetBorder(root, YGEdgeTop, 10); + YGNodeStyleSetBorder(root, YGEdgeRight, 10); + YGNodeStyleSetBorder(root, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child0, YGAlignStart); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child1, YGJustifyEnd); + YGNodeStyleSetAlignSelf(root_child1, YGAlignEnd); + YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child2, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child2, YGAlignStart); + YGNodeStyleSetPositionType(root_child2, YGPositionTypeAbsolute); + YGNodeStyleSetMargin(root_child2, YGEdgeLeft, 10); + YGNodeStyleSetMargin(root_child2, YGEdgeTop, 10); + YGNodeStyleSetMargin(root_child2, YGEdgeRight, 10); + YGNodeStyleSetMargin(root_child2, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child3, YGJustifyEnd); + YGNodeStyleSetAlignSelf(root_child3, YGAlignEnd); + YGNodeStyleSetPositionType(root_child3, YGPositionTypeAbsolute); + YGNodeStyleSetMargin(root_child3, YGEdgeLeft, 10); + YGNodeStyleSetMargin(root_child3, YGEdgeTop, 10); + YGNodeStyleSetMargin(root_child3, YGEdgeRight, 10); + YGNodeStyleSetMargin(root_child3, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 50); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_resolved_insets.cpp b/tests/generated/grid_absolute_resolved_insets.cpp new file mode 100644 index 0000000000..39ff8131a4 --- /dev/null +++ b/tests/generated/grid_absolute_resolved_insets.cpp @@ -0,0 +1,283 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<1f74616c1d0b3c0ac0dfc35b954ec196>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_resolved_insets.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_resolved_insets) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 15); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 15); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 15); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 20); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 20); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root_child0, 200); + YGNodeStyleSetHeight(root_child0, 200); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPositionAuto(root_child0_child0, YGEdgeLeft); + YGNodeStyleSetPositionAuto(root_child0_child0, YGEdgeTop); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0_child1, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0_child1, YGEdgeTop, 0); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeAbsolute); + YGNodeStyleSetPositionPercent(root_child0_child2, YGEdgeLeft, 100); + YGNodeStyleSetPositionPercent(root_child0_child2, YGEdgeTop, 100); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child3, YGPositionTypeAbsolute); + YGNodeStyleSetPositionPercent(root_child0_child3, YGEdgeRight, 100); + YGNodeStyleSetPositionPercent(root_child0_child3, YGEdgeBottom, 100); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child4, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0_child4, YGEdgeLeft, 30); + YGNodeStyleSetPosition(root_child0_child4, YGEdgeTop, 30); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child5, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0_child5, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child0_child5, YGEdgeTop, 0); + YGNodeStyleSetWidthPercent(root_child0_child5, 100); + YGNodeStyleSetHeightPercent(root_child0_child5, 100); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetOverflow(root_child1, YGOverflowScroll); + YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 15); + YGNodeStyleSetPadding(root_child1, YGEdgeTop, 15); + YGNodeStyleSetPadding(root_child1, YGEdgeRight, 15); + YGNodeStyleSetPadding(root_child1, YGEdgeBottom, 15); + YGNodeStyleSetBorder(root_child1, YGEdgeLeft, 20); + YGNodeStyleSetBorder(root_child1, YGEdgeTop, 20); + YGNodeStyleSetBorder(root_child1, YGEdgeRight, 20); + YGNodeStyleSetBorder(root_child1, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root_child1, 200); + YGNodeStyleSetHeight(root_child1, 200); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPositionAuto(root_child1_child0, YGEdgeLeft); + YGNodeStyleSetPositionAuto(root_child1_child0, YGEdgeTop); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1_child1, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child1_child1, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child1_child1, YGEdgeTop, 0); + YGNodeInsertChild(root_child1, root_child1_child1, 1); + + YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1_child2, YGPositionTypeAbsolute); + YGNodeStyleSetPositionPercent(root_child1_child2, YGEdgeLeft, 100); + YGNodeStyleSetPositionPercent(root_child1_child2, YGEdgeTop, 100); + YGNodeInsertChild(root_child1, root_child1_child2, 2); + + YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1_child3, YGPositionTypeAbsolute); + YGNodeStyleSetPositionPercent(root_child1_child3, YGEdgeRight, 100); + YGNodeStyleSetPositionPercent(root_child1_child3, YGEdgeBottom, 100); + YGNodeInsertChild(root_child1, root_child1_child3, 3); + + YGNodeRef root_child1_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1_child4, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child1_child4, YGEdgeLeft, 30); + YGNodeStyleSetPosition(root_child1_child4, YGEdgeTop, 30); + YGNodeInsertChild(root_child1, root_child1_child4, 4); + + YGNodeRef root_child1_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1_child5, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child1_child5, YGEdgeLeft, 0); + YGNodeStyleSetPosition(root_child1_child5, YGEdgeTop, 0); + YGNodeStyleSetWidthPercent(root_child1_child5, 100); + YGNodeStyleSetHeightPercent(root_child1_child5, 100); + YGNodeInsertChild(root_child1, root_child1_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child5)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child1_child5)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child1_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child5)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child1_child5)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child1_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_top_overrides_bottom.cpp b/tests/generated/grid_absolute_top_overrides_bottom.cpp new file mode 100644 index 0000000000..5329165079 --- /dev/null +++ b/tests/generated/grid_absolute_top_overrides_bottom.cpp @@ -0,0 +1,176 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<18baea4e05b6312136a1385bc2b20d91>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_top_overrides_bottom.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_top_overrides_bottom) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetHeight(root_child0, 10); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_with_padding.cpp b/tests/generated/grid_absolute_with_padding.cpp new file mode 100644 index 0000000000..84a1b21004 --- /dev/null +++ b/tests/generated/grid_absolute_with_padding.cpp @@ -0,0 +1,178 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_with_padding.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_with_padding) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 0); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child1, YGEdgeLeft, 10); + YGNodeStyleSetPosition(root_child1, YGEdgeBottom, 10); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_absolute_with_padding_and_margin.cpp b/tests/generated/grid_absolute_with_padding_and_margin.cpp new file mode 100644 index 0000000000..1a9f9665ca --- /dev/null +++ b/tests/generated/grid_absolute_with_padding_and_margin.cpp @@ -0,0 +1,186 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_absolute_with_padding_and_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_absolute_with_padding_and_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 0); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child1, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child1, YGEdgeLeft, 10); + YGNodeStyleSetPosition(root_child1, YGEdgeBottom, 10); + YGNodeStyleSetMargin(root_child1, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child1, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child1, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child1, YGEdgeBottom, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(178, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(178, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_center.cpp b/tests/generated/grid_align_content_center.cpp new file mode 100644 index 0000000000..c24afe748e --- /dev/null +++ b/tests/generated/grid_align_content_center.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<73b5d5b5d600ab712130e916aa667292>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_center.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignCenter); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_center_negative_space_gap.cpp b/tests/generated/grid_align_content_center_negative_space_gap.cpp new file mode 100644 index 0000000000..38fa7af7c3 --- /dev/null +++ b/tests/generated/grid_align_content_center_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_center_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_center_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifyCenter); + YGNodeStyleSetAlignContent(root_child0, YGAlignCenter); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_end.cpp b/tests/generated/grid_align_content_end.cpp new file mode 100644 index 0000000000..b064796fbd --- /dev/null +++ b/tests/generated/grid_align_content_end.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<18ed969e9a9f4d03262566f14881d071>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_end.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_end) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignEnd); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_end_negative_space_gap.cpp b/tests/generated/grid_align_content_end_negative_space_gap.cpp new file mode 100644 index 0000000000..0e281927ca --- /dev/null +++ b/tests/generated/grid_align_content_end_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_end_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_end_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifyCenter); + YGNodeStyleSetAlignContent(root_child0, YGAlignEnd); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_end_with_padding_border.cpp b/tests/generated/grid_align_content_end_with_padding_border.cpp new file mode 100644 index 0000000000..82c4428802 --- /dev/null +++ b/tests/generated/grid_align_content_end_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_end_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_end_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignEnd); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(44, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(44, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(44, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(84, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(84, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(84, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(44, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(44, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(44, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(84, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(84, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(84, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_space_around.cpp b/tests/generated/grid_align_content_space_around.cpp new file mode 100644 index 0000000000..ecd65705ef --- /dev/null +++ b/tests/generated/grid_align_content_space_around.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_around.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_space_around) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceAround); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_space_around_negative_space_gap.cpp b/tests/generated/grid_align_content_space_around_negative_space_gap.cpp new file mode 100644 index 0000000000..1d766877f1 --- /dev/null +++ b/tests/generated/grid_align_content_space_around_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_around_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_space_around_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifyCenter); + YGNodeStyleSetAlignContent(root_child0, YGAlignSpaceAround); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_space_around_with_padding_border.cpp b/tests/generated/grid_align_content_space_around_with_padding_border.cpp new file mode 100644 index 0000000000..a6a1798412 --- /dev/null +++ b/tests/generated/grid_align_content_space_around_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<8c0c613e668ce5fcb8c96a5d476dac47>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_around_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_space_around_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceAround); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(17, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(17, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(17, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(119, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(119, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(119, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(17, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(17, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(17, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(119, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(119, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(119, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_space_between.cpp b/tests/generated/grid_align_content_space_between.cpp new file mode 100644 index 0000000000..a342607178 --- /dev/null +++ b/tests/generated/grid_align_content_space_between.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<10bbc526bb2c7de51f75ffc5313748b0>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_between.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_space_between) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceBetween); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_space_between_negative_space_gap.cpp b/tests/generated/grid_align_content_space_between_negative_space_gap.cpp new file mode 100644 index 0000000000..367b201192 --- /dev/null +++ b/tests/generated/grid_align_content_space_between_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<4bde5dfc0d10277cecbcdbb97d1cbeeb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_between_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_space_between_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifyCenter); + YGNodeStyleSetAlignContent(root_child0, YGAlignSpaceBetween); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_space_between_with_padding_border.cpp b/tests/generated/grid_align_content_space_between_with_padding_border.cpp new file mode 100644 index 0000000000..021bad20ca --- /dev/null +++ b/tests/generated/grid_align_content_space_between_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7611c93e80eb5b38e0e412e3bc90ab5e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_between_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_space_between_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceBetween); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_space_evenly.cpp b/tests/generated/grid_align_content_space_evenly.cpp new file mode 100644 index 0000000000..52047f5a1e --- /dev/null +++ b/tests/generated/grid_align_content_space_evenly.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_space_evenly) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceEvenly); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_space_evenly_negative_space_gap.cpp b/tests/generated/grid_align_content_space_evenly_negative_space_gap.cpp new file mode 100644 index 0000000000..2f0175264c --- /dev/null +++ b/tests/generated/grid_align_content_space_evenly_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<6b3abd45d00403b360007a23a10fd270>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_space_evenly_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifyCenter); + YGNodeStyleSetAlignContent(root_child0, YGAlignSpaceBetween); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_space_evenly_with_padding_border.cpp b/tests/generated/grid_align_content_space_evenly_with_padding_border.cpp new file mode 100644 index 0000000000..82146bccc8 --- /dev/null +++ b/tests/generated/grid_align_content_space_evenly_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<6b88a0a6cf624db999774479b84ff227>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_space_evenly_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_space_evenly_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceEvenly); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(116, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(116, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(116, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(68, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(116, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(116, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(116, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_start.cpp b/tests/generated/grid_align_content_start.cpp new file mode 100644 index 0000000000..f7f02d89df --- /dev/null +++ b/tests/generated/grid_align_content_start.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<462cd5e4db5cacd97ccd11a4c14573ea>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_start.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_start) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignStart); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_start_negative_space_gap.cpp b/tests/generated/grid_align_content_start_negative_space_gap.cpp new file mode 100644 index 0000000000..4b66fe2fe6 --- /dev/null +++ b/tests/generated/grid_align_content_start_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_start_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_start_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifyCenter); + YGNodeStyleSetAlignContent(root_child0, YGAlignStart); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_content_start_with_padding_border.cpp b/tests/generated/grid_align_content_start_with_padding_border.cpp new file mode 100644 index 0000000000..640a2b7f45 --- /dev/null +++ b/tests/generated/grid_align_content_start_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_content_start_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_content_start_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignStart); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline.cpp b/tests/generated/grid_align_items_baseline.cpp new file mode 100644 index 0000000000..746540e971 --- /dev/null +++ b/tests/generated/grid_align_items_baseline.cpp @@ -0,0 +1,74 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_child.cpp b/tests/generated/grid_align_items_baseline_child.cpp new file mode 100644 index 0000000000..fd84248c7d --- /dev/null +++ b/tests/generated/grid_align_items_baseline_child.cpp @@ -0,0 +1,90 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<8d934580029a57f81e798e4f1759597d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_child) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 10); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_child_margin.cpp b/tests/generated/grid_align_items_baseline_child_margin.cpp new file mode 100644 index 0000000000..19863c11de --- /dev/null +++ b/tests/generated/grid_align_items_baseline_child_margin.cpp @@ -0,0 +1,98 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_child_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child0, YGEdgeLeft, 5); + YGNodeStyleSetMargin(root_child1_child0, YGEdgeTop, 5); + YGNodeStyleSetMargin(root_child1_child0, YGEdgeRight, 5); + YGNodeStyleSetMargin(root_child1_child0, YGEdgeBottom, 5); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 10); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(-5, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_child_margin_percent.cpp b/tests/generated/grid_align_items_baseline_child_margin_percent.cpp new file mode 100644 index 0000000000..e687040404 --- /dev/null +++ b/tests/generated/grid_align_items_baseline_child_margin_percent.cpp @@ -0,0 +1,98 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<6ff8d37b619fe67faea6b8fe036b72aa>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_margin_percent.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_child_margin_percent) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginPercent(root_child1_child0, YGEdgeLeft, 1); + YGNodeStyleSetMarginPercent(root_child1_child0, YGEdgeTop, 1); + YGNodeStyleSetMarginPercent(root_child1_child0, YGEdgeRight, 1); + YGNodeStyleSetMarginPercent(root_child1_child0, YGEdgeBottom, 1); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 10); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_child_multiline.cpp b/tests/generated/grid_align_items_baseline_child_multiline.cpp new file mode 100644 index 0000000000..b5a7bdd894 --- /dev/null +++ b/tests/generated/grid_align_items_baseline_child_multiline.cpp @@ -0,0 +1,142 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_multiline.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_child_multiline) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 60); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + auto root_child1_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child1_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_child1_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root_child1, root_child1_gridTemplateColumns); + YGGridTrackListFree(root_child1_gridTemplateColumns); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 25); + YGNodeStyleSetHeight(root_child1_child0, 20); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child1, 25); + YGNodeStyleSetHeight(root_child1_child1, 10); + YGNodeStyleSetDisplay(root_child1_child1, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child1, 1); + + YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child2, 25); + YGNodeStyleSetHeight(root_child1_child2, 20); + YGNodeStyleSetDisplay(root_child1_child2, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child2, 2); + + YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child3, 25); + YGNodeStyleSetHeight(root_child1_child3, 10); + YGNodeStyleSetDisplay(root_child1_child3, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.cpp b/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.cpp new file mode 100644 index 0000000000..b320c01695 --- /dev/null +++ b/tests/generated/grid_align_items_baseline_child_multiline_no_override_on_secondline.cpp @@ -0,0 +1,144 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_multiline_no_override_on_secondline.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_child_multiline_no_override_on_secondline) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 60); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + auto root_child1_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child1_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_child1_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root_child1, root_child1_gridTemplateColumns); + YGGridTrackListFree(root_child1_gridTemplateColumns); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 25); + YGNodeStyleSetHeight(root_child1_child0, 20); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child1, 25); + YGNodeStyleSetHeight(root_child1_child1, 10); + YGNodeStyleSetDisplay(root_child1_child1, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child1, 1); + + YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child2, 25); + YGNodeStyleSetHeight(root_child1_child2, 20); + YGNodeStyleSetDisplay(root_child1_child2, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child2, 2); + + YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child1_child3, YGAlignBaseline); + YGNodeStyleSetWidth(root_child1_child3, 25); + YGNodeStyleSetHeight(root_child1_child3, 10); + YGNodeStyleSetDisplay(root_child1_child3, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_child_multiline_override.cpp b/tests/generated/grid_align_items_baseline_child_multiline_override.cpp new file mode 100644 index 0000000000..c9c080c9c9 --- /dev/null +++ b/tests/generated/grid_align_items_baseline_child_multiline_override.cpp @@ -0,0 +1,145 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<6bb365c29ba524d79ef519da3c93d80d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_multiline_override.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_child_multiline_override) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 60); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 25); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + auto root_child1_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child1_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_child1_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root_child1, root_child1_gridTemplateColumns); + YGGridTrackListFree(root_child1_gridTemplateColumns); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 25); + YGNodeStyleSetHeight(root_child1_child0, 20); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child1_child1, YGAlignBaseline); + YGNodeStyleSetWidth(root_child1_child1, 25); + YGNodeStyleSetHeight(root_child1_child1, 10); + YGNodeStyleSetDisplay(root_child1_child1, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child1, 1); + + YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child2, 25); + YGNodeStyleSetHeight(root_child1_child2, 20); + YGNodeStyleSetDisplay(root_child1_child2, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child2, 2); + + YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child1_child3, YGAlignBaseline); + YGNodeStyleSetWidth(root_child1_child3, 25); + YGNodeStyleSetHeight(root_child1_child3, 10); + YGNodeStyleSetDisplay(root_child1_child3, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_child_padding.cpp b/tests/generated/grid_align_items_baseline_child_padding.cpp new file mode 100644 index 0000000000..e7b253334e --- /dev/null +++ b/tests/generated/grid_align_items_baseline_child_padding.cpp @@ -0,0 +1,98 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<35cc5e2dfbedbd180606fafaa20d6c2e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_padding.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_child_padding) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root, YGEdgeTop, 5); + YGNodeStyleSetPadding(root, YGEdgeRight, 5); + YGNodeStyleSetPadding(root, YGEdgeBottom, 5); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child1, YGEdgeLeft, 5); + YGNodeStyleSetPadding(root_child1, YGEdgeTop, 5); + YGNodeStyleSetPadding(root_child1, YGEdgeRight, 5); + YGNodeStyleSetPadding(root_child1, YGEdgeBottom, 5); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 10); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(-5, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_child_top.cpp b/tests/generated/grid_align_items_baseline_child_top.cpp new file mode 100644 index 0000000000..d7e45674c3 --- /dev/null +++ b/tests/generated/grid_align_items_baseline_child_top.cpp @@ -0,0 +1,91 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7f6fc344ce0112164815fdd9e1d82bcf>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_top.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_child_top) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 10); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_child_top2.cpp b/tests/generated/grid_align_items_baseline_child_top2.cpp new file mode 100644 index 0000000000..d0d2b9780f --- /dev/null +++ b/tests/generated/grid_align_items_baseline_child_top2.cpp @@ -0,0 +1,91 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7e6c279c31ac54bf7c1c8e1139a485de>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_child_top2.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_child_top2) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPosition(root_child1, YGEdgeTop, 5); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 10); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(55, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_complex.cpp b/tests/generated/grid_align_items_baseline_complex.cpp new file mode 100644 index 0000000000..cfbb2adedc --- /dev/null +++ b/tests/generated/grid_align_items_baseline_complex.cpp @@ -0,0 +1,245 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<1d9c85ccced63582e359801a6548d955>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_complex.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_complex) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 20); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child1_child0, 10); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 20); + YGNodeStyleSetHeight(root_child2, 20); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child2_child0, 10); + YGNodeInsertChild(root_child2, root_child2_child0, 0); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 20); + YGNodeStyleSetHeight(root_child3, 20); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 20); + YGNodeStyleSetHeight(root_child4, 20); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child5, 20); + YGNodeStyleSetHeight(root_child5, 20); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child6, 20); + YGNodeStyleSetHeight(root_child6, 20); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child6_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child6_child0, 10); + YGNodeInsertChild(root_child6, root_child6_child0, 0); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child7, 20); + YGNodeStyleSetHeight(root_child7, 20); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child7_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child7_child0, 5); + YGNodeInsertChild(root_child7, root_child7_child0, 0); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child8, 20); + YGNodeStyleSetHeight(root_child8, 20); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child6_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child6_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child7_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child7_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child7_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetHeight(root_child7_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child6_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child6_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(95, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child7_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child7_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child7_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetHeight(root_child7_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_double_nested_child.cpp b/tests/generated/grid_align_items_baseline_double_nested_child.cpp new file mode 100644 index 0000000000..978f51bdbc --- /dev/null +++ b/tests/generated/grid_align_items_baseline_double_nested_child.cpp @@ -0,0 +1,106 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<086eb3b456a496cdcb30b1144194b838>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_double_nested_child.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_double_nested_child) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child0, 50); + YGNodeStyleSetHeight(root_child0_child0, 20); + YGNodeStyleSetDisplay(root_child0_child0, YGDisplayGrid); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 15); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetHeight(root_child1_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_multiline.cpp b/tests/generated/grid_align_items_baseline_multiline.cpp new file mode 100644 index 0000000000..987f075dc8 --- /dev/null +++ b/tests/generated/grid_align_items_baseline_multiline.cpp @@ -0,0 +1,143 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_multiline.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_multiline) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 10); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 20); + YGNodeStyleSetDisplay(root_child2, YGDisplayGrid); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2_child0, 50); + YGNodeStyleSetHeight(root_child2_child0, 10); + YGNodeStyleSetDisplay(root_child2_child0, YGDisplayGrid); + YGNodeInsertChild(root_child2, root_child2_child0, 0); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 50); + YGNodeStyleSetDisplay(root_child3, YGDisplayGrid); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_multiline_column.cpp b/tests/generated/grid_align_items_baseline_multiline_column.cpp new file mode 100644 index 0000000000..5270ccdc00 --- /dev/null +++ b/tests/generated/grid_align_items_baseline_multiline_column.cpp @@ -0,0 +1,143 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<22c425e023844736f3bc325382d6f9c6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_multiline_column.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_multiline_column) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 30); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 20); + YGNodeStyleSetHeight(root_child1_child0, 20); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 40); + YGNodeStyleSetHeight(root_child2, 70); + YGNodeStyleSetDisplay(root_child2, YGDisplayGrid); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2_child0, 10); + YGNodeStyleSetHeight(root_child2_child0, 10); + YGNodeStyleSetDisplay(root_child2_child0, YGDisplayGrid); + YGNodeInsertChild(root_child2, root_child2_child0, 0); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 20); + YGNodeStyleSetDisplay(root_child3, YGDisplayGrid); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_multiline_row_and_column.cpp b/tests/generated/grid_align_items_baseline_multiline_row_and_column.cpp new file mode 100644 index 0000000000..569cf06ce8 --- /dev/null +++ b/tests/generated/grid_align_items_baseline_multiline_row_and_column.cpp @@ -0,0 +1,143 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<5940d4b7387ee4cdf01082e6481c4705>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_multiline_row_and_column.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_multiline_row_and_column) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 10); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 20); + YGNodeStyleSetDisplay(root_child2, YGDisplayGrid); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child2_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2_child0, 50); + YGNodeStyleSetHeight(root_child2_child0, 10); + YGNodeStyleSetDisplay(root_child2_child0, YGDisplayGrid); + YGNodeInsertChild(root_child2, root_child2_child0, 0); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 20); + YGNodeStyleSetDisplay(root_child3, YGDisplayGrid); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child2_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_baseline_nested_column.cpp b/tests/generated/grid_align_items_baseline_nested_column.cpp new file mode 100644 index 0000000000..e9012724ea --- /dev/null +++ b/tests/generated/grid_align_items_baseline_nested_column.cpp @@ -0,0 +1,120 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_baseline_nested_column.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_baseline_nested_column) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignBaseline); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 60); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child1, YGDisplayGrid); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0, 50); + YGNodeStyleSetHeight(root_child1_child0, 80); + YGNodeStyleSetDisplay(root_child1_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + YGNodeRef root_child1_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0_child0, 50); + YGNodeStyleSetHeight(root_child1_child0_child0, 30); + YGNodeStyleSetDisplay(root_child1_child0_child0, YGDisplayGrid); + YGNodeInsertChild(root_child1_child0, root_child1_child0_child0, 0); + + YGNodeRef root_child1_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1_child0_child1, 50); + YGNodeStyleSetHeight(root_child1_child0_child1, 40); + YGNodeStyleSetDisplay(root_child1_child0_child1, YGDisplayGrid); + YGNodeInsertChild(root_child1_child0, root_child1_child0_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1_child0_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1_child0_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1_child0_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1_child0_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_sized_center.cpp b/tests/generated/grid_align_items_sized_center.cpp new file mode 100644 index 0000000000..01c7d66df9 --- /dev/null +++ b/tests/generated/grid_align_items_sized_center.cpp @@ -0,0 +1,88 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_center.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_sized_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignCenter); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_sized_end.cpp b/tests/generated/grid_align_items_sized_end.cpp new file mode 100644 index 0000000000..72631703f9 --- /dev/null +++ b/tests/generated/grid_align_items_sized_end.cpp @@ -0,0 +1,88 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7d7fa7d937eed2993f824562aeefaec8>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_end.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_sized_end) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignEnd); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_sized_start.cpp b/tests/generated/grid_align_items_sized_start.cpp new file mode 100644 index 0000000000..60c04dc2ea --- /dev/null +++ b/tests/generated/grid_align_items_sized_start.cpp @@ -0,0 +1,88 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<0306d1901d0121d30c489608be3c6db7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_start.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_sized_start) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignItems(root, YGAlignStart); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_items_sized_stretch.cpp b/tests/generated/grid_align_items_sized_stretch.cpp new file mode 100644 index 0000000000..eefe48eb79 --- /dev/null +++ b/tests/generated/grid_align_items_sized_stretch.cpp @@ -0,0 +1,87 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_items_sized_stretch.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_items_sized_stretch) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_align_self_sized_all.cpp b/tests/generated/grid_align_self_sized_all.cpp new file mode 100644 index 0000000000..f72b79fb91 --- /dev/null +++ b/tests/generated/grid_align_self_sized_all.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<5fa2b6e737274a1e9e06352596d74b1b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_align_self_sized_all.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_align_self_sized_all) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child0, YGAlignStart); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child1, YGAlignStart); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child2, YGAlignEnd); + YGNodeStyleSetWidth(root_child2, 20); + YGNodeStyleSetHeight(root_child2, 20); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child3, YGAlignEnd); + YGNodeStyleSetWidth(root_child3, 60); + YGNodeStyleSetHeight(root_child3, 60); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child4, YGAlignCenter); + YGNodeStyleSetWidth(root_child4, 20); + YGNodeStyleSetHeight(root_child4, 20); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child5, YGAlignCenter); + YGNodeStyleSetWidth(root_child5, 60); + YGNodeStyleSetHeight(root_child5, 60); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child6, 20); + YGNodeStyleSetHeight(root_child6, 20); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child7, 60); + YGNodeStyleSetHeight(root_child7, 60); + YGNodeInsertChild(root, root_child7, 7); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child7)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child7)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.cpp b/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.cpp new file mode 100644 index 0000000000..141caeb507 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.cpp @@ -0,0 +1,60 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<5060394152124f8d73ca84e8d2a92cc6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_absolute_width_overrides_inset.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_absolute_width_overrides_inset) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + YGNodeStyleSetHeight(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeTop, 5); + YGNodeStyleSetPositionPercent(root_child0, YGEdgeRight, 10); + YGNodeStyleSetWidthPercent(root_child0, 40); + YGNodeStyleSetAspectRatio(root_child0, 3 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(53, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(53, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_child_fill_content_height.cpp b/tests/generated/grid_aspect_ratio_child_fill_content_height.cpp new file mode 100644 index 0000000000..845f888d34 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_child_fill_content_height.cpp @@ -0,0 +1,69 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<2a68846d7fc6b92f83f6d976cd8e267f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_child_fill_content_height.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_child_fill_content_height) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAspectRatio(root_child0, 0.5 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HHHH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_child_fill_content_width.cpp b/tests/generated/grid_aspect_ratio_child_fill_content_width.cpp new file mode 100644 index 0000000000..0675971b20 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_child_fill_content_width.cpp @@ -0,0 +1,69 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<5ad77675bb088bfb8c9313dcb981c6e4>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_child_fill_content_width.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_child_fill_content_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HHHH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_height.cpp b/tests/generated/grid_aspect_ratio_fill_child_height.cpp new file mode 100644 index 0000000000..8878b7a732 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_height.cpp @@ -0,0 +1,56 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<44c16666dc851136ca33fe387c7e6d68>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_height.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_fill_child_height) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_max_height.cpp b/tests/generated/grid_aspect_ratio_fill_child_max_height.cpp new file mode 100644 index 0000000000..0e0bf8d4ec --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_max_height.cpp @@ -0,0 +1,58 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_max_height.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_fill_child_max_height) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMaxWidth(root_child0, 40); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HH​HH​HH​HH​HH​HH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_max_width.cpp b/tests/generated/grid_aspect_ratio_fill_child_max_width.cpp new file mode 100644 index 0000000000..5818cb31de --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_max_width.cpp @@ -0,0 +1,58 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<93d4214d86324aae2fd1ba76ba8b4b6f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_max_width.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_fill_child_max_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMaxHeight(root_child0, 20); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HH HH HH HH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_min_height.cpp b/tests/generated/grid_aspect_ratio_fill_child_min_height.cpp new file mode 100644 index 0000000000..e655fc45ff --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_min_height.cpp @@ -0,0 +1,56 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_min_height.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_fill_child_min_height) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMinWidth(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(25, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_width.cpp b/tests/generated/grid_aspect_ratio_fill_child_width.cpp new file mode 100644 index 0000000000..04e3a76635 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_width.cpp @@ -0,0 +1,56 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<3f50fb60bacd44ef42d9874ac4a363d7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_fill_child_width.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_fill_child_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_height_to_width.cpp b/tests/generated/grid_aspect_ratio_height_to_width.cpp new file mode 100644 index 0000000000..a4d1444117 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_height_to_width.cpp @@ -0,0 +1,79 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<6a316a219ec113afac8b56bd16025da7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_height_to_width.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_height_to_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(150)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child0, 150); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child1, 150); + YGNodeStyleSetAspectRatio(root_child1, 0.5 / 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(375, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(375, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_min_max_constraints.cpp b/tests/generated/grid_aspect_ratio_min_max_constraints.cpp new file mode 100644 index 0000000000..3dad91b44f --- /dev/null +++ b/tests/generated/grid_aspect_ratio_min_max_constraints.cpp @@ -0,0 +1,81 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<31f7382c678de534a237eced99cc539a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_min_max_constraints.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_min_max_constraints) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 200); + YGNodeStyleSetMaxHeight(root_child0, 80); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 200); + YGNodeStyleSetMinHeight(root_child1, 150); + YGNodeStyleSetAspectRatio(root_child1, 2 / 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes.cpp b/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes.cpp new file mode 100644 index 0000000000..f922589dd2 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes.cpp @@ -0,0 +1,57 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_overridden_by_explicit_sizes.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_overridden_by_explicit_sizes) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes_flex.cpp b/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes_flex.cpp new file mode 100644 index 0000000000..b027c130ad --- /dev/null +++ b/tests/generated/grid_aspect_ratio_overridden_by_explicit_sizes_flex.cpp @@ -0,0 +1,57 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_overridden_by_explicit_sizes_flex.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_overridden_by_explicit_sizes_flex) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_percentage_auto_margin.cpp b/tests/generated/grid_aspect_ratio_percentage_auto_margin.cpp new file mode 100644 index 0000000000..c4c9eea497 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_percentage_auto_margin.cpp @@ -0,0 +1,101 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<3fb949083e324aa1082f8eb4bf6fb6f7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_percentage_auto_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_percentage_auto_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(30)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetAspectRatio(root_child0, 16 / 9); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 80); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child2, YGEdgeTop); + YGNodeStyleSetMarginAuto(root_child2, YGEdgeBottom); + YGNodeStyleSetAspectRatio(root_child2, 1 / 1); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(270, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(365, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_reresolution_auto_rows.cpp b/tests/generated/grid_aspect_ratio_reresolution_auto_rows.cpp new file mode 100644 index 0000000000..ffab9f32c5 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_reresolution_auto_rows.cpp @@ -0,0 +1,77 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<50241767581b5d46117a5091edb52e74>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_reresolution_auto_rows.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_reresolution_auto_rows) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetAspectRatio(root_child1, 2 / 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_spanning_items.cpp b/tests/generated/grid_aspect_ratio_spanning_items.cpp new file mode 100644 index 0000000000..83c2e30952 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_spanning_items.cpp @@ -0,0 +1,83 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_spanning_items.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_spanning_items) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(150)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAspectRatio(root_child0, 3 / 1); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 150); + YGNodeStyleSetAspectRatio(root_child1, 1 / 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(470, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(470, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_spanning_with_content_distribution.cpp b/tests/generated/grid_aspect_ratio_spanning_with_content_distribution.cpp new file mode 100644 index 0000000000..9a2a63ff8c --- /dev/null +++ b/tests/generated/grid_aspect_ratio_spanning_with_content_distribution.cpp @@ -0,0 +1,107 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<02da1776f45b97c8eec220da5f585959>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_spanning_with_content_distribution.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_spanning_with_content_distribution) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignContent(root, YGAlignSpaceBetween); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 2); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEnd(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 50); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridColumnEnd(root_child1, 2); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeStyleSetGridRowEnd(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetAspectRatio(root_child2, 2 / 1); + YGNodeStyleSetGridColumnStart(root_child2, 2); + YGNodeStyleSetGridColumnEnd(root_child2, 3); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeStyleSetGridRowEnd(root_child2, 3); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(450, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_triggers_reresolution.cpp b/tests/generated/grid_aspect_ratio_triggers_reresolution.cpp new file mode 100644 index 0000000000..2209c969d9 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_triggers_reresolution.cpp @@ -0,0 +1,62 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_triggers_reresolution.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_triggers_reresolution) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_aspect_ratio_width_to_height.cpp b/tests/generated/grid_aspect_ratio_width_to_height.cpp new file mode 100644 index 0000000000..71dd22a620 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_width_to_height.cpp @@ -0,0 +1,79 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_aspect_ratio_width_to_height.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_width_to_height) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(200)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 200); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 200); + YGNodeStyleSetAspectRatio(root_child1, 1.77 / 1); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(113, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_auto_margin_overflow_block.cpp b/tests/generated/grid_auto_margin_overflow_block.cpp new file mode 100644 index 0000000000..e34ff742ef --- /dev/null +++ b/tests/generated/grid_auto_margin_overflow_block.cpp @@ -0,0 +1,62 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_margin_overflow_block.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_auto_margin_overflow_block) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(100)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeTop); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeBottom); + YGNodeStyleSetWidth(root_child0, 50); + YGNodeStyleSetHeight(root_child0, 200); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_auto_margin_overflow_inline.cpp b/tests/generated/grid_auto_margin_overflow_inline.cpp new file mode 100644 index 0000000000..09771190c9 --- /dev/null +++ b/tests/generated/grid_auto_margin_overflow_inline.cpp @@ -0,0 +1,61 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_margin_overflow_inline.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_auto_margin_overflow_inline) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft); + YGNodeStyleSetMarginAuto(root_child0, YGEdgeRight); + YGNodeStyleSetWidth(root_child0, 200); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_auto_rows.cpp b/tests/generated/grid_auto_rows.cpp new file mode 100644 index 0000000000..34eb2ce0bd --- /dev/null +++ b/tests/generated/grid_auto_rows.cpp @@ -0,0 +1,158 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_rows.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_auto_rows) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + auto root_gridAutoRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridAutoRows, YGPoints(10)); + YGGridTrackListAddTrack(root_gridAutoRows, YGPoints(20)); + YGGridTrackListAddTrack(root_gridAutoRows, YGPoints(30)); + YGNodeStyleSetGridAutoRows(root, root_gridAutoRows); + YGGridTrackListFree(root_gridAutoRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridRowStart(root_child0, -4); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child7)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child7)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_auto_single_item.cpp b/tests/generated/grid_auto_single_item.cpp new file mode 100644 index 0000000000..cc15989fce --- /dev/null +++ b/tests/generated/grid_auto_single_item.cpp @@ -0,0 +1,169 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_single_item.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_auto_single_item) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_auto_single_item_fixed_width.cpp b/tests/generated/grid_auto_single_item_fixed_width.cpp new file mode 100644 index 0000000000..2fe9ea1448 --- /dev/null +++ b/tests/generated/grid_auto_single_item_fixed_width.cpp @@ -0,0 +1,170 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<61f8ae651f24b947e7c3a0591b404837>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_single_item_fixed_width.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_auto_single_item_fixed_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMinWidth(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.cpp b/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.cpp new file mode 100644 index 0000000000..84300005a6 --- /dev/null +++ b/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.cpp @@ -0,0 +1,170 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_single_item_fixed_width_with_definite_width.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_auto_single_item_fixed_width_with_definite_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 100); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_auto_takes_precedence_over_fr.cpp b/tests/generated/grid_auto_takes_precedence_over_fr.cpp new file mode 100644 index 0000000000..b0d4e4b476 --- /dev/null +++ b/tests/generated/grid_auto_takes_precedence_over_fr.cpp @@ -0,0 +1,76 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_auto_takes_precedence_over_fr.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_auto_takes_precedence_over_fr) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_available_space_greater_than_max_content.cpp b/tests/generated/grid_available_space_greater_than_max_content.cpp new file mode 100644 index 0000000000..7f78514d88 --- /dev/null +++ b/tests/generated/grid_available_space_greater_than_max_content.cpp @@ -0,0 +1,88 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<4aaa68bf7d2b517812bde67a4b19baec>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_available_space_greater_than_max_content.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_available_space_greater_than_max_content) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 400); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeSetContext(root_child0_child0, (void*)"HH HH HH HH"); + YGNodeSetMeasureFunc(root_child0_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + YGNodeSetContext(root_child0_child1, (void*)"HH HH HH HH"); + YGNodeSetMeasureFunc(root_child0_child1, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(290, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_basic.cpp b/tests/generated/grid_basic.cpp new file mode 100644 index 0000000000..113aa9b2e4 --- /dev/null +++ b/tests/generated/grid_basic.cpp @@ -0,0 +1,170 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<8544c908601d1f214c6bc21dc5b38be6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_basic) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_basic_implicit_tracks.cpp b/tests/generated/grid_basic_implicit_tracks.cpp new file mode 100644 index 0000000000..e0d94a8fae --- /dev/null +++ b/tests/generated/grid_basic_implicit_tracks.cpp @@ -0,0 +1,75 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<8a9dad87090860bf23f675774babbcf6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic_implicit_tracks.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_basic_implicit_tracks) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 35); + YGNodeStyleSetHeight(root_child1, 35); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(75, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(35, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_basic_with_overflow.cpp b/tests/generated/grid_basic_with_overflow.cpp new file mode 100644 index 0000000000..62e60a1a64 --- /dev/null +++ b/tests/generated/grid_basic_with_overflow.cpp @@ -0,0 +1,183 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<4eed264a79d7b1f5129a4dd7a8d8a451>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic_with_overflow.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_basic_with_overflow) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + + YGNodeRef root_child9 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child9, 9); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child9)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child9)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child9)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child9)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child9)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child9)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child9)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child9)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_basic_with_padding.cpp b/tests/generated/grid_basic_with_padding.cpp new file mode 100644 index 0000000000..ab70e81b99 --- /dev/null +++ b/tests/generated/grid_basic_with_padding.cpp @@ -0,0 +1,172 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<2e8630a57354a706de39f129e2a41d28>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_basic_with_padding.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_basic_with_padding) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_complex_mixed_spanning_alignment.cpp b/tests/generated/grid_complex_mixed_spanning_alignment.cpp new file mode 100644 index 0000000000..eda0333230 --- /dev/null +++ b/tests/generated/grid_complex_mixed_spanning_alignment.cpp @@ -0,0 +1,109 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<42073a18f6b6ffcfdfeb2cf8dcf7e680>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_complex_mixed_spanning_alignment.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, complex_mixed_spanning_alignment) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); + YGNodeStyleSetAlignContent(root, YGAlignCenter); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 600); + YGNodeStyleSetHeight(root, 400); + YGNodeStyleSetGap(root, YGGutterColumn, 10); + YGNodeStyleSetGap(root, YGGutterRow, 10); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(100)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(80)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyEnd); + YGNodeStyleSetWidth(root_child0, 250); + YGNodeStyleSetHeightPercent(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 3); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child1, YGAlignCenter); + YGNodeStyleSetWidthPercent(root_child1, 100); + YGNodeStyleSetHeight(root_child1, 80); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child2, 100); + YGNodeStyleSetHeight(root_child2, 200); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeStyleSetGridRowEnd(root_child2, 4); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(600, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(350, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(230, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(500, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_display_none_fixed_size.cpp b/tests/generated/grid_display_none_fixed_size.cpp new file mode 100644 index 0000000000..8beee7ed47 --- /dev/null +++ b/tests/generated/grid_display_none_fixed_size.cpp @@ -0,0 +1,71 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_display_none_fixed_size.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_display_none_fixed_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexGrow(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 20); + YGNodeStyleSetHeight(root_child1, 20); + YGNodeStyleSetDisplay(root_child1, YGDisplayNone); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_distribute_space_flex_auto.cpp b/tests/generated/grid_distribute_space_flex_auto.cpp new file mode 100644 index 0000000000..2fe7e99cbe --- /dev/null +++ b/tests/generated/grid_distribute_space_flex_auto.cpp @@ -0,0 +1,107 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<37d652da10b673403933fa09616a5e2b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_distribute_space_flex_auto.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_distribute_space_flex_auto) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 300); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 200); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridColumnEnd(root_child0, 4); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 50); + YGNodeStyleSetHeight(root_child1, 30); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetHeight(root_child2, 30); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child3, 50); + YGNodeStyleSetHeight(root_child3, 30); + YGNodeInsertChild(root, root_child3, 3); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_expand_flexible_indefinite_free_space.cpp b/tests/generated/grid_expand_flexible_indefinite_free_space.cpp new file mode 100644 index 0000000000..8db63fc6d4 --- /dev/null +++ b/tests/generated/grid_expand_flexible_indefinite_free_space.cpp @@ -0,0 +1,109 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<5b1411b81fa8b2110c40cb0e39e48842>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_expand_flexible_indefinite_free_space.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_expand_flexible_indefinite_free_space_container) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidthMaxContent(root); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGFr(2)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child0, 100); + YGNodeStyleSetHeight(root_child0_child0, 80); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child1, 150); + YGNodeStyleSetHeight(root_child0_child1, 120); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child2, 120); + YGNodeStyleSetHeight(root_child0_child2, 100); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(480, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(360, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(480, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(360, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(360, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(480, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(360, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(480, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(360, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(380, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(210, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_fixed_size_no_content_proportions.cpp b/tests/generated/grid_fr_fixed_size_no_content_proportions.cpp new file mode 100644 index 0000000000..1a3ea4376f --- /dev/null +++ b/tests/generated/grid_fr_fixed_size_no_content_proportions.cpp @@ -0,0 +1,89 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<90667b8ca3c2375d07a2e45c36868fef>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_fixed_size_no_content_proportions.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_fixed_size_no_content_proportions) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(3)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(67, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(167, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(33, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(67, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.cpp b/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.cpp new file mode 100644 index 0000000000..b85dd7506e --- /dev/null +++ b/tests/generated/grid_fr_fixed_size_no_content_proportions_sub_1_sum.cpp @@ -0,0 +1,75 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<9a3f1523284c8c3b4c5ec67cab4dd90a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_fixed_size_no_content_proportions_sub_1_sum.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_fixed_size_no_content_proportions_sub_1_sum) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0.3f)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0.2f)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_fixed_size_single_item.cpp b/tests/generated/grid_fr_fixed_size_single_item.cpp new file mode 100644 index 0000000000..a52b1e9475 --- /dev/null +++ b/tests/generated/grid_fr_fixed_size_single_item.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<2b0210ceedef0f5780d8bff325bd7f0a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_fixed_size_single_item.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_fixed_size_single_item) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child4, 100); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_no_sized_items_indefinite.cpp b/tests/generated/grid_fr_no_sized_items_indefinite.cpp new file mode 100644 index 0000000000..0da27c60cd --- /dev/null +++ b/tests/generated/grid_fr_no_sized_items_indefinite.cpp @@ -0,0 +1,168 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_no_sized_items_indefinite.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_no_sized_items_indefinite) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_single_item_indefinite.cpp b/tests/generated/grid_fr_single_item_indefinite.cpp new file mode 100644 index 0000000000..b00813e79d --- /dev/null +++ b/tests/generated/grid_fr_single_item_indefinite.cpp @@ -0,0 +1,185 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_single_item_indefinite.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_single_item_indefinite) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidthMaxContent(root); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthAuto(root_child0); + YGNodeStyleSetHeightAuto(root_child0); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child1, 100); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_span_2_proportion.cpp b/tests/generated/grid_fr_span_2_proportion.cpp new file mode 100644 index 0000000000..8d849fc9ee --- /dev/null +++ b/tests/generated/grid_fr_span_2_proportion.cpp @@ -0,0 +1,90 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_span_2_proportion) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(2)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetGridColumnStartSpan(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_span_2_proportion_sub_1_sum.cpp b/tests/generated/grid_fr_span_2_proportion_sub_1_sum.cpp new file mode 100644 index 0000000000..db249f7424 --- /dev/null +++ b/tests/generated/grid_fr_span_2_proportion_sub_1_sum.cpp @@ -0,0 +1,90 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<158468f8c63a4f583fe313cad140e1fc>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_sub_1_sum.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_span_2_proportion_sub_1_sum) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0.2f)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0.3f)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetGridColumnStartSpan(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.cpp b/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.cpp new file mode 100644 index 0000000000..db6cb33b6f --- /dev/null +++ b/tests/generated/grid_fr_span_2_proportion_with_non_spanned_track.cpp @@ -0,0 +1,131 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<1c9cc3a49dd9e7b0ada76e149465e5cb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_with_non_spanned_track.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_span_2_proportion_with_non_spanned_track) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidthMaxContent(root); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(1)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(2)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(3)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child0, 60); + YGNodeStyleSetGridColumnStartSpan(root_child0_child0, 2); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_span_2_proportion_zero_sum.cpp b/tests/generated/grid_fr_span_2_proportion_zero_sum.cpp new file mode 100644 index 0000000000..157047f5a6 --- /dev/null +++ b/tests/generated/grid_fr_span_2_proportion_zero_sum.cpp @@ -0,0 +1,90 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_zero_sum.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_span_2_proportion_zero_sum) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetGridColumnStartSpan(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.cpp b/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.cpp new file mode 100644 index 0000000000..ffc603536d --- /dev/null +++ b/tests/generated/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.cpp @@ -0,0 +1,117 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7e673b8bb76aae75fe7fe737293641ee>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_fr_span_2_proportion_zero_sum_with_non_spanned_track.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_span_2_proportion_zero_sum_with_non_spanned_track) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(0)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 60); + YGNodeStyleSetGridColumnStartSpan(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_gap.cpp b/tests/generated/grid_gap.cpp new file mode 100644 index 0000000000..5942e20965 --- /dev/null +++ b/tests/generated/grid_gap.cpp @@ -0,0 +1,172 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetGap(root, YGGutterColumn, 40); + YGNodeStyleSetGap(root, YGGutterRow, 40); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_hidden.cpp b/tests/generated/grid_hidden.cpp new file mode 100644 index 0000000000..76c87b5836 --- /dev/null +++ b/tests/generated/grid_hidden.cpp @@ -0,0 +1,173 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_hidden.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_hidden) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child1, YGDisplayNone); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child4, YGDisplayNone); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child6, YGDisplayNone); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_center.cpp b/tests/generated/grid_justify_content_center.cpp new file mode 100644 index 0000000000..64c253e835 --- /dev/null +++ b/tests/generated/grid_justify_content_center.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<374c0b0476ad3f9f7218efc2c9a04666>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_center.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyCenter); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_center_negative_space_gap.cpp b/tests/generated/grid_justify_content_center_negative_space_gap.cpp new file mode 100644 index 0000000000..79b63d9de6 --- /dev/null +++ b/tests/generated/grid_justify_content_center_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<15266da3c05fed4f60430d0f42df26b5>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_center_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_center_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifyCenter); + YGNodeStyleSetAlignContent(root_child0, YGAlignCenter); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_center_with_padding_border.cpp b/tests/generated/grid_justify_content_center_with_padding_border.cpp new file mode 100644 index 0000000000..83c74ffc22 --- /dev/null +++ b/tests/generated/grid_justify_content_center_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_center_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_center_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyCenter); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(132, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(132, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(132, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(132, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(132, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(132, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_end.cpp b/tests/generated/grid_justify_content_end.cpp new file mode 100644 index 0000000000..4d8d15bffc --- /dev/null +++ b/tests/generated/grid_justify_content_end.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_end.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_end) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyEnd); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_end_negative_space_gap.cpp b/tests/generated/grid_justify_content_end_negative_space_gap.cpp new file mode 100644 index 0000000000..4013a8253b --- /dev/null +++ b/tests/generated/grid_justify_content_end_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_end_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_end_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifyEnd); + YGNodeStyleSetAlignContent(root_child0, YGAlignCenter); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_end_with_padding_border.cpp b/tests/generated/grid_justify_content_end_with_padding_border.cpp new file mode 100644 index 0000000000..cf5bc97f77 --- /dev/null +++ b/tests/generated/grid_justify_content_end_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7537b21b517e49c80b0e98a4aac4ddcb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_end_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_end_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyEnd); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_space_around.cpp b/tests/generated/grid_justify_content_space_around.cpp new file mode 100644 index 0000000000..7056b72e24 --- /dev/null +++ b/tests/generated/grid_justify_content_space_around.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<746006d1c5f74480dc1acc12a0333af8>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_around.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_space_around) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(147, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_space_around_negative_space_gap.cpp b/tests/generated/grid_justify_content_space_around_negative_space_gap.cpp new file mode 100644 index 0000000000..f2dcf2ce3b --- /dev/null +++ b/tests/generated/grid_justify_content_space_around_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<1a73e455d1077aef412f870f3ed573d9>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_around_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_space_around_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifySpaceAround); + YGNodeStyleSetAlignContent(root_child0, YGAlignCenter); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_space_around_with_padding_border.cpp b/tests/generated/grid_justify_content_space_around_with_padding_border.cpp new file mode 100644 index 0000000000..5df13fcd22 --- /dev/null +++ b/tests/generated/grid_justify_content_space_around_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<0e254030cfb88b9b151fd87ddd1cf539>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_around_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_space_around_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceAround); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(49, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(135, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(49, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(135, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(49, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(135, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(135, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(49, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(135, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(49, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(135, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(49, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_space_between.cpp b/tests/generated/grid_justify_content_space_between.cpp new file mode 100644 index 0000000000..a659756411 --- /dev/null +++ b/tests/generated/grid_justify_content_space_between.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7fd0178e8cb9d134b61e5072cb7dbd6a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_between.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_space_between) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_space_between_negative_space_gap.cpp b/tests/generated/grid_justify_content_space_between_negative_space_gap.cpp new file mode 100644 index 0000000000..04a02a4b82 --- /dev/null +++ b/tests/generated/grid_justify_content_space_between_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_between_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_space_between_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifySpaceBetween); + YGNodeStyleSetAlignContent(root_child0, YGAlignCenter); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_space_between_with_padding_border.cpp b/tests/generated/grid_justify_content_space_between_with_padding_border.cpp new file mode 100644 index 0000000000..5ef1e00e53 --- /dev/null +++ b/tests/generated/grid_justify_content_space_between_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<183aeb632966e684c87f3705a0f9d584>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_between_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_space_between_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceBetween); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_space_evenly.cpp b/tests/generated/grid_justify_content_space_evenly.cpp new file mode 100644 index 0000000000..4f581ded7b --- /dev/null +++ b/tests/generated/grid_justify_content_space_evenly.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<207d958a1af757616eb03b4930988a95>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_evenly.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_space_evenly) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceEvenly); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_space_evenly_negative_space_gap.cpp b/tests/generated/grid_justify_content_space_evenly_negative_space_gap.cpp new file mode 100644 index 0000000000..4553fedee8 --- /dev/null +++ b/tests/generated/grid_justify_content_space_evenly_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<909a9e93c6476e9e003fc4c12191e3f9>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_evenly_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_space_evenly_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifySpaceEvenly); + YGNodeStyleSetAlignContent(root_child0, YGAlignCenter); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_space_evenly_with_padding_border.cpp b/tests/generated/grid_justify_content_space_evenly_with_padding_border.cpp new file mode 100644 index 0000000000..dc91f83159 --- /dev/null +++ b/tests/generated/grid_justify_content_space_evenly_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7cd771926c53559c96249500b4b1a76f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_space_evenly_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_space_evenly_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifySpaceEvenly); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(134, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(134, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(134, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(134, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(134, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(134, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_start.cpp b/tests/generated/grid_justify_content_start.cpp new file mode 100644 index 0000000000..4c87311180 --- /dev/null +++ b/tests/generated/grid_justify_content_start.cpp @@ -0,0 +1,171 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_start.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_start) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyStart); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_start_negative_space_gap.cpp b/tests/generated/grid_justify_content_start_negative_space_gap.cpp new file mode 100644 index 0000000000..cfa832ff2d --- /dev/null +++ b/tests/generated/grid_justify_content_start_negative_space_gap.cpp @@ -0,0 +1,194 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7e3622be24c4d90496df8be08280d8c4>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_start_negative_space_gap.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_start_negative_space_gap) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root, YGEdgeLeft, 60); + YGNodeStyleSetBorder(root, YGEdgeTop, 60); + YGNodeStyleSetBorder(root, YGEdgeRight, 60); + YGNodeStyleSetBorder(root, YGEdgeBottom, 60); + YGNodeStyleSetWidth(root, 240); + YGNodeStyleSetHeight(root, 240); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root_child0, YGJustifyStart); + YGNodeStyleSetAlignContent(root_child0, YGAlignCenter); + YGNodeStyleSetWidth(root_child0, 120); + YGNodeStyleSetHeight(root_child0, 120); + YGNodeStyleSetGap(root_child0, YGGutterColumn, 10); + YGNodeStyleSetGap(root_child0, YGGutterRow, 10); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(20)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(240, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_content_start_with_padding_border.cpp b/tests/generated/grid_justify_content_start_with_padding_border.cpp new file mode 100644 index 0000000000..ddd9426f7c --- /dev/null +++ b/tests/generated/grid_justify_content_start_with_padding_border.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_content_start_with_padding_border.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_content_start_with_padding_border) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyStart); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetBorder(root, YGEdgeLeft, 8); + YGNodeStyleSetBorder(root, YGEdgeTop, 2); + YGNodeStyleSetBorder(root, YGEdgeRight, 4); + YGNodeStyleSetBorder(root, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(88, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(128, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(136, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(56, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(92, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_items_sized_center.cpp b/tests/generated/grid_justify_items_sized_center.cpp new file mode 100644 index 0000000000..4cfa293d4f --- /dev/null +++ b/tests/generated/grid_justify_items_sized_center.cpp @@ -0,0 +1,88 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_center.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_items_sized_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyItems(root, YGJustifyCenter); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_items_sized_end.cpp b/tests/generated/grid_justify_items_sized_end.cpp new file mode 100644 index 0000000000..da3347a252 --- /dev/null +++ b/tests/generated/grid_justify_items_sized_end.cpp @@ -0,0 +1,88 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<260cf805172afbde73005b170f01d418>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_end.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_items_sized_end) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyItems(root, YGJustifyEnd); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_items_sized_start.cpp b/tests/generated/grid_justify_items_sized_start.cpp new file mode 100644 index 0000000000..cab8519606 --- /dev/null +++ b/tests/generated/grid_justify_items_sized_start.cpp @@ -0,0 +1,88 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<5c234609f9b26b3c3513290d72128284>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_start.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_items_sized_start) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyItems(root, YGJustifyStart); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_items_sized_stretch.cpp b/tests/generated/grid_justify_items_sized_stretch.cpp new file mode 100644 index 0000000000..7cd2ccab79 --- /dev/null +++ b/tests/generated/grid_justify_items_sized_stretch.cpp @@ -0,0 +1,88 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_items_sized_stretch.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_items_sized_stretch) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyItems(root, YGJustifyStretch); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeStyleSetGridColumnStart(root_child1, 3); + YGNodeStyleSetGridRowStart(root_child1, 3); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_justify_self_sized_all.cpp b/tests/generated/grid_justify_self_sized_all.cpp new file mode 100644 index 0000000000..d66e9f87d0 --- /dev/null +++ b/tests/generated/grid_justify_self_sized_all.cpp @@ -0,0 +1,181 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<8304d044befccbc15314adb8805f4dd1>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_justify_self_sized_all.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_justify_self_sized_all) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStart); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child1, YGJustifyStart); + YGNodeStyleSetWidth(root_child1, 60); + YGNodeStyleSetHeight(root_child1, 60); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child2, YGJustifyEnd); + YGNodeStyleSetWidth(root_child2, 20); + YGNodeStyleSetHeight(root_child2, 20); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child3, YGJustifyEnd); + YGNodeStyleSetWidth(root_child3, 60); + YGNodeStyleSetHeight(root_child3, 60); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child4, YGJustifyCenter); + YGNodeStyleSetWidth(root_child4, 20); + YGNodeStyleSetHeight(root_child4, 20); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child5, YGJustifyCenter); + YGNodeStyleSetWidth(root_child5, 60); + YGNodeStyleSetHeight(root_child5, 60); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child6, YGJustifyStretch); + YGNodeStyleSetWidth(root_child6, 20); + YGNodeStyleSetHeight(root_child6, 20); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child7, YGJustifyStretch); + YGNodeStyleSetWidth(root_child7, 60); + YGNodeStyleSetHeight(root_child7, 60); + YGNodeInsertChild(root, root_child7, 7); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child7)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child7)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_auto_margins.cpp b/tests/generated/grid_margins_auto_margins.cpp new file mode 100644 index 0000000000..9482a5b19a --- /dev/null +++ b/tests/generated/grid_margins_auto_margins.cpp @@ -0,0 +1,188 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7f851ed9187b1cc7463b33393f79d486>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_auto_margins.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_auto_margins) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child2, YGJustifyStart); + YGNodeStyleSetMarginAuto(root_child2, YGEdgeLeft); + YGNodeStyleSetMarginAuto(root_child2, YGEdgeRight); + YGNodeStyleSetWidth(root_child2, 20); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetAlignSelf(root_child4, YGAlignStart); + YGNodeStyleSetMarginAuto(root_child4, YGEdgeTop); + YGNodeStyleSetMarginAuto(root_child4, YGEdgeBottom); + YGNodeStyleSetHeight(root_child4, 20); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child6, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child6, YGAlignStart); + YGNodeStyleSetMarginAuto(root_child6, YGEdgeLeft); + YGNodeStyleSetMarginAuto(root_child6, YGEdgeTop); + YGNodeStyleSetMarginAuto(root_child6, YGEdgeRight); + YGNodeStyleSetMarginAuto(root_child6, YGEdgeBottom); + YGNodeStyleSetWidth(root_child6, 20); + YGNodeStyleSetHeight(root_child6, 20); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(130, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_auto_margins_override_stretch.cpp b/tests/generated/grid_margins_auto_margins_override_stretch.cpp new file mode 100644 index 0000000000..4459dcc0e5 --- /dev/null +++ b/tests/generated/grid_margins_auto_margins_override_stretch.cpp @@ -0,0 +1,179 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<5ca4d42613944f43013780e7d90d9c07>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_auto_margins_override_stretch.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_auto_margins_override_stretch) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child6, YGJustifyStretch); + YGNodeStyleSetMarginAuto(root_child6, YGEdgeLeft); + YGNodeStyleSetMarginAuto(root_child6, YGEdgeTop); + YGNodeStyleSetMarginAuto(root_child6, YGEdgeRight); + YGNodeStyleSetMarginAuto(root_child6, YGEdgeBottom); + YGNodeInsertChild(root, root_child6, 6); + YGNodeSetContext(root_child6, (void*)"HH​HH"); + YGNodeSetMeasureFunc(root_child6, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(105, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_fixed_center.cpp b/tests/generated/grid_margins_fixed_center.cpp new file mode 100644 index 0000000000..a23f3e0d05 --- /dev/null +++ b/tests/generated/grid_margins_fixed_center.cpp @@ -0,0 +1,141 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_center.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_fixed_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyCenter); + YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 8); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 6); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(52, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(132, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_fixed_end.cpp b/tests/generated/grid_margins_fixed_end.cpp new file mode 100644 index 0000000000..0822f0551b --- /dev/null +++ b/tests/generated/grid_margins_fixed_end.cpp @@ -0,0 +1,141 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_end.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_fixed_end) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyEnd); + YGNodeStyleSetAlignSelf(root_child0, YGAlignEnd); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(58, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(27, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(124, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(27, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_fixed_start.cpp b/tests/generated/grid_margins_fixed_start.cpp new file mode 100644 index 0000000000..e15228410f --- /dev/null +++ b/tests/generated/grid_margins_fixed_start.cpp @@ -0,0 +1,141 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_start.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_fixed_start) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child0, YGAlignStart); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(44, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(11, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(138, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(11, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_fixed_stretch.cpp b/tests/generated/grid_margins_fixed_stretch.cpp new file mode 100644 index 0000000000..07f5d78b59 --- /dev/null +++ b/tests/generated/grid_margins_fixed_stretch.cpp @@ -0,0 +1,140 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_fixed_stretch.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_fixed_stretch) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 40); + YGNodeStyleSetPadding(root, YGEdgeTop, 10); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 30); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStretch); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 1); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 2); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(44, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(11, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(138, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(11, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_percent_center.cpp b/tests/generated/grid_margins_percent_center.cpp new file mode 100644 index 0000000000..02c7bab587 --- /dev/null +++ b/tests/generated/grid_margins_percent_center.cpp @@ -0,0 +1,137 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7d7504eeb931e35400e0a7427d24acd2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_center.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_percent_center) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyCenter); + YGNodeStyleSetAlignSelf(root_child0, YGAlignCenter); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(41, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_percent_end.cpp b/tests/generated/grid_margins_percent_end.cpp new file mode 100644 index 0000000000..f404809654 --- /dev/null +++ b/tests/generated/grid_margins_percent_end.cpp @@ -0,0 +1,137 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<4aeafff353937fc85915020dbd94ef52>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_end.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_percent_end) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyEnd); + YGNodeStyleSetAlignSelf(root_child0, YGAlignEnd); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(-2, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(17, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(44, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(17, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_percent_start.cpp b/tests/generated/grid_margins_percent_start.cpp new file mode 100644 index 0000000000..e8781409e1 --- /dev/null +++ b/tests/generated/grid_margins_percent_start.cpp @@ -0,0 +1,137 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<26450e7fa424b2de2e0e4ae1e3a57adb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_start.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_percent_start) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child0, YGAlignStart); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(4, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(38, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_margins_percent_stretch.cpp b/tests/generated/grid_margins_percent_stretch.cpp new file mode 100644 index 0000000000..65218e6378 --- /dev/null +++ b/tests/generated/grid_margins_percent_stretch.cpp @@ -0,0 +1,136 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<773e98a2e85957592429d9c4a63e13b7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_margins_percent_stretch.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_margins_percent_stretch) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(20)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStretch); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 20); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 10); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 15); + YGNodeStyleSetWidth(root_child0, 20); + YGNodeStyleSetHeight(root_child0, 20); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(4, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(38, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_minmax_auto_fixed_10px.cpp b/tests/generated/grid_minmax_auto_fixed_10px.cpp new file mode 100644 index 0000000000..e402c72f7c --- /dev/null +++ b/tests/generated/grid_minmax_auto_fixed_10px.cpp @@ -0,0 +1,62 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<46a605699431c8653d1f1a2738222c34>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_auto_fixed_10px.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_minmax_auto_fixed_10px) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGMinMax(YGAuto(), YGPoints(10))); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HH​HH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_minmax_auto_percent_definite.cpp b/tests/generated/grid_minmax_auto_percent_definite.cpp new file mode 100644 index 0000000000..21aadccf62 --- /dev/null +++ b/tests/generated/grid_minmax_auto_percent_definite.cpp @@ -0,0 +1,63 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<5e837fa1b0e01bde66983c1fe139f67d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_auto_percent_definite.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_minmax_auto_percent_definite) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGMinMax(YGAuto(), YGPercent(20))); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HH​HH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_minmax_auto_percent_indefinite.cpp b/tests/generated/grid_minmax_auto_percent_indefinite.cpp new file mode 100644 index 0000000000..f8f86e7d71 --- /dev/null +++ b/tests/generated/grid_minmax_auto_percent_indefinite.cpp @@ -0,0 +1,76 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<2b07c4b926c8a48af23d230429f9052b>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_auto_percent_indefinite.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_minmax_auto_percent_indefinite) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidthMaxContent(root); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGMinMax(YGAuto(), YGPercent(20))); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeSetContext(root_child0_child0, (void*)"HH HH"); + YGNodeSetMeasureFunc(root_child0_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_minmax_column_fixed_width_above_range.cpp b/tests/generated/grid_minmax_column_fixed_width_above_range.cpp new file mode 100644 index 0000000000..c7d0964a50 --- /dev/null +++ b/tests/generated/grid_minmax_column_fixed_width_above_range.cpp @@ -0,0 +1,169 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_fixed_width_above_range.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_minmax_column_fixed_width_above_range) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 140); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGMinMax(YGPoints(20), YGPoints(40))); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_minmax_column_fixed_width_below_range.cpp b/tests/generated/grid_minmax_column_fixed_width_below_range.cpp new file mode 100644 index 0000000000..654a23cd77 --- /dev/null +++ b/tests/generated/grid_minmax_column_fixed_width_below_range.cpp @@ -0,0 +1,169 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<1c2ef85ed752e851c75a1733b5ed7802>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_fixed_width_below_range.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_minmax_column_fixed_width_below_range) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 90); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGMinMax(YGPoints(20), YGPoints(40))); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_minmax_column_fixed_width_within_range.cpp b/tests/generated/grid_minmax_column_fixed_width_within_range.cpp new file mode 100644 index 0000000000..70ad8c21f0 --- /dev/null +++ b/tests/generated/grid_minmax_column_fixed_width_within_range.cpp @@ -0,0 +1,169 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<1f7381c8b17fcdd380958608cd5e95c6>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_fixed_width_within_range.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_minmax_column_fixed_width_within_range) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 110); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGMinMax(YGPoints(20), YGPoints(40))); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + + YGNodeRef root_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child7, 7); + + YGNodeRef root_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(110, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child7)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_minmax_column_indefinite.cpp b/tests/generated/grid_minmax_column_indefinite.cpp new file mode 100644 index 0000000000..3c1773ead8 --- /dev/null +++ b/tests/generated/grid_minmax_column_indefinite.cpp @@ -0,0 +1,182 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_indefinite.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_minmax_column_indefinite) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidthMaxContent(root); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGMinMax(YGPoints(20), YGPoints(40))); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + + YGNodeRef root_child0_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child5, 5); + + YGNodeRef root_child0_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child6, 6); + + YGNodeRef root_child0_child7 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child7, 7); + + YGNodeRef root_child0_child8 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child8, 8); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child6)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child0_child7)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child7)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child7)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child8)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child8)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child8)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_minmax_column_with_auto_fixed.cpp b/tests/generated/grid_minmax_column_with_auto_fixed.cpp new file mode 100644 index 0000000000..0ba54d1912 --- /dev/null +++ b/tests/generated/grid_minmax_column_with_auto_fixed.cpp @@ -0,0 +1,75 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_with_auto_fixed.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_minmax_column_with_auto_fixed) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 60); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGMinMax(YGPoints(20), YGPoints(40))); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_minmax_column_with_fr_fixed.cpp b/tests/generated/grid_minmax_column_with_fr_fixed.cpp new file mode 100644 index 0000000000..8ac9ad5a6b --- /dev/null +++ b/tests/generated/grid_minmax_column_with_fr_fixed.cpp @@ -0,0 +1,75 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_minmax_column_with_fr_fixed.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_minmax_column_with_fr_fixed) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 60); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGMinMax(YGPoints(20), YGPoints(40))); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_overflow_inline_axis_hidden.cpp b/tests/generated/grid_overflow_inline_axis_hidden.cpp new file mode 100644 index 0000000000..e09d66bfb3 --- /dev/null +++ b/tests/generated/grid_overflow_inline_axis_hidden.cpp @@ -0,0 +1,57 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_inline_axis_hidden.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_overflow_inline_axis_hidden) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetOverflow(root_child0, YGOverflowHidden); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HHHHHHHHHH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_overflow_inline_axis_scroll.cpp b/tests/generated/grid_overflow_inline_axis_scroll.cpp new file mode 100644 index 0000000000..431fddd4a0 --- /dev/null +++ b/tests/generated/grid_overflow_inline_axis_scroll.cpp @@ -0,0 +1,57 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<9152957bbb7ccc86b18b7d1157ba865e>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_inline_axis_scroll.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_overflow_inline_axis_scroll) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetOverflow(root_child0, YGOverflowScroll); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HHHHHHHHHH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_overflow_inline_axis_visible.cpp b/tests/generated/grid_overflow_inline_axis_visible.cpp new file mode 100644 index 0000000000..f7981e63f8 --- /dev/null +++ b/tests/generated/grid_overflow_inline_axis_visible.cpp @@ -0,0 +1,56 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_inline_axis_visible.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_overflow_inline_axis_visible) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HHHHHHHHHH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(-50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_overflow_scrollbars_overridden_by_available_space.cpp b/tests/generated/grid_overflow_scrollbars_overridden_by_available_space.cpp new file mode 100644 index 0000000000..0a4138644d --- /dev/null +++ b/tests/generated/grid_overflow_scrollbars_overridden_by_available_space.cpp @@ -0,0 +1,69 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<31a59a2607355edda0f9e5d71cf1edf7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_overridden_by_available_space.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_overflow_scrollbars_overridden_by_available_space) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 2); + YGNodeStyleSetHeight(root, 4); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetOverflow(root_child0, YGOverflowScroll); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(4, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(4, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_overflow_scrollbars_overridden_by_max_size.cpp b/tests/generated/grid_overflow_scrollbars_overridden_by_max_size.cpp new file mode 100644 index 0000000000..351c01b1c1 --- /dev/null +++ b/tests/generated/grid_overflow_scrollbars_overridden_by_max_size.cpp @@ -0,0 +1,55 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<1d0e78c738bc9998f6cebb67327066d4>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_overridden_by_max_size.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_overflow_scrollbars_overridden_by_max_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetOverflow(root, YGOverflowScroll); + YGNodeStyleSetMaxWidth(root, 2); + YGNodeStyleSetMaxHeight(root, 4); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_overflow_scrollbars_overridden_by_size.cpp b/tests/generated/grid_overflow_scrollbars_overridden_by_size.cpp new file mode 100644 index 0000000000..b2adbc12d0 --- /dev/null +++ b/tests/generated/grid_overflow_scrollbars_overridden_by_size.cpp @@ -0,0 +1,55 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<3acc0c830492517752f6f40f29b6ff5a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_overridden_by_size.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_overflow_scrollbars_overridden_by_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetOverflow(root, YGOverflowScroll); + YGNodeStyleSetWidth(root, 2); + YGNodeStyleSetHeight(root, 4); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(4, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(4, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(2, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.cpp b/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.cpp new file mode 100644 index 0000000000..24be9509bc --- /dev/null +++ b/tests/generated/grid_overflow_scrollbars_take_up_space_both_axis.cpp @@ -0,0 +1,55 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<31097b2890c5de0c00b981eeccb95e8f>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_overflow_scrollbars_take_up_space_both_axis.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_overflow_scrollbars_take_up_space_both_axis) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetOverflow(root, YGOverflowScroll); + YGNodeStyleSetWidth(root, 50); + YGNodeStyleSetHeight(root, 50); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_padding_border_overrides_container_max_size.cpp b/tests/generated/grid_padding_border_overrides_container_max_size.cpp new file mode 100644 index 0000000000..7d1a00b4f9 --- /dev/null +++ b/tests/generated/grid_padding_border_overrides_container_max_size.cpp @@ -0,0 +1,62 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<98f3b47e4cbd057e14092d08467594cb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_container_max_size.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_padding_border_overrides_container_max_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 8); + YGNodeStyleSetPadding(root, YGEdgeTop, 2); + YGNodeStyleSetPadding(root, YGEdgeRight, 4); + YGNodeStyleSetPadding(root, YGEdgeBottom, 6); + YGNodeStyleSetBorder(root, YGEdgeLeft, 7); + YGNodeStyleSetBorder(root, YGEdgeTop, 1); + YGNodeStyleSetBorder(root, YGEdgeRight, 3); + YGNodeStyleSetBorder(root, YGEdgeBottom, 5); + YGNodeStyleSetMaxWidth(root, 12); + YGNodeStyleSetMaxHeight(root, 12); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_padding_border_overrides_container_size.cpp b/tests/generated/grid_padding_border_overrides_container_size.cpp new file mode 100644 index 0000000000..191300cf40 --- /dev/null +++ b/tests/generated/grid_padding_border_overrides_container_size.cpp @@ -0,0 +1,62 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<6c075045a4eeef4ca24947efcd29891a>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_container_size.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_padding_border_overrides_container_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 8); + YGNodeStyleSetPadding(root, YGEdgeTop, 2); + YGNodeStyleSetPadding(root, YGEdgeRight, 4); + YGNodeStyleSetPadding(root, YGEdgeBottom, 6); + YGNodeStyleSetBorder(root, YGEdgeLeft, 7); + YGNodeStyleSetBorder(root, YGEdgeTop, 1); + YGNodeStyleSetBorder(root, YGEdgeRight, 3); + YGNodeStyleSetBorder(root, YGEdgeBottom, 5); + YGNodeStyleSetWidth(root, 12); + YGNodeStyleSetHeight(root, 12); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_padding_border_overrides_max_size.cpp b/tests/generated/grid_padding_border_overrides_max_size.cpp new file mode 100644 index 0000000000..1876a81561 --- /dev/null +++ b/tests/generated/grid_padding_border_overrides_max_size.cpp @@ -0,0 +1,62 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<3e9e70f6c4112fb363916ad680a55d30>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_max_size.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_padding_border_overrides_max_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 8); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 4); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 6); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 1); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 3); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetMaxWidth(root_child0, 12); + YGNodeStyleSetMaxHeight(root_child0, 12); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_padding_border_overrides_min_size.cpp b/tests/generated/grid_padding_border_overrides_min_size.cpp new file mode 100644 index 0000000000..d63f3470d3 --- /dev/null +++ b/tests/generated/grid_padding_border_overrides_min_size.cpp @@ -0,0 +1,60 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7a924d3717f90f9ce71cb4c5ea61c813>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_min_size.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_padding_border_overrides_min_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 8); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 4); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 6); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 1); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 3); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 5); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_padding_border_overrides_size.cpp b/tests/generated/grid_padding_border_overrides_size.cpp new file mode 100644 index 0000000000..2e4979327c --- /dev/null +++ b/tests/generated/grid_padding_border_overrides_size.cpp @@ -0,0 +1,62 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<4162c06ab96357415f1cce019a2540dd>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_padding_border_overrides_size.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_padding_border_overrides_size) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 8); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 2); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 4); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 6); + YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 7); + YGNodeStyleSetBorder(root_child0, YGEdgeTop, 1); + YGNodeStyleSetBorder(root_child0, YGEdgeRight, 3); + YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetWidth(root_child0, 12); + YGNodeStyleSetHeight(root_child0, 12); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(14, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_item_inside_stretch_item.cpp b/tests/generated/grid_percent_item_inside_stretch_item.cpp new file mode 100644 index 0000000000..920e20e122 --- /dev/null +++ b/tests/generated/grid_percent_item_inside_stretch_item.cpp @@ -0,0 +1,70 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<542dd994683172458ac547cfd9b83d03>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_item_inside_stretch_item.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_item_inside_stretch_item) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0_child0, 50); + YGNodeStyleSetDisplay(root_child0_child0, YGDisplayGrid); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_items_nested_inside_stretch_alignment.cpp b/tests/generated/grid_percent_items_nested_inside_stretch_alignment.cpp new file mode 100644 index 0000000000..68000ec739 --- /dev/null +++ b/tests/generated/grid_percent_items_nested_inside_stretch_alignment.cpp @@ -0,0 +1,69 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<558d7324449b92aeedefe5fcc0d94b57>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_inside_stretch_alignment.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_items_nested_inside_stretch_alignment) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeTop, 20); + YGNodeStyleSetDisplay(root_child0_child0, YGDisplayGrid); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_items_nested_moderate.cpp b/tests/generated/grid_percent_items_nested_moderate.cpp new file mode 100644 index 0000000000..103cd1b5ea --- /dev/null +++ b/tests/generated/grid_percent_items_nested_moderate.cpp @@ -0,0 +1,89 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<76277975b5fd737422b54650aef79243>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_moderate.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_items_nested_moderate) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root, YGEdgeTop, 3); + YGNodeStyleSetPadding(root, YGEdgeRight, 3); + YGNodeStyleSetPadding(root, YGEdgeBottom, 3); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 3); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 3); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeRight, 3); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginPercent(root_child0_child0, YGEdgeLeft, 5); + YGNodeStyleSetMarginPercent(root_child0_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0_child0, YGEdgeRight, 5); + YGNodeStyleSetMarginPercent(root_child0_child0, YGEdgeBottom, 5); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0_child0, 45); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(184, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_items_nested_with_margin.cpp b/tests/generated/grid_percent_items_nested_with_margin.cpp new file mode 100644 index 0000000000..669a015194 --- /dev/null +++ b/tests/generated/grid_percent_items_nested_with_margin.cpp @@ -0,0 +1,73 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_with_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_items_nested_with_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthPercent(root_child0, 50); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginPercent(root_child0_child0, YGEdgeLeft, 5); + YGNodeStyleSetMarginPercent(root_child0_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0_child0, YGEdgeRight, 5); + YGNodeStyleSetMarginPercent(root_child0_child0, YGEdgeBottom, 5); + YGNodeStyleSetWidthPercent(root_child0_child0, 45); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_items_nested_with_padding_margin.cpp b/tests/generated/grid_percent_items_nested_with_padding_margin.cpp new file mode 100644 index 0000000000..a6b827fa85 --- /dev/null +++ b/tests/generated/grid_percent_items_nested_with_padding_margin.cpp @@ -0,0 +1,127 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<08b531347f968875ff2d4648ce95e522>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_nested_with_padding_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_items_nested_with_padding_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(4)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 5); + YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetMinWidthPercent(root_child0, 60); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 5); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 5); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 5); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, 5); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeLeft, 3); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeTop, 3); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeRight, 3); + YGNodeStyleSetPaddingPercent(root_child0_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0_child0, 50); + YGNodeStyleSetDisplay(root_child0_child0, YGDisplayGrid); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeLeft, 5); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeRight, 5); + YGNodeStyleSetMarginPercent(root_child0_child0_child0, YGEdgeBottom, 5); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0_child0_child0, 45); + YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(32, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child1)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(173, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(22, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(8, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetLeft(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(1, YGNodeLayoutGetTop(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetWidth(root_child0_child0_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0_child0_child0)); + + ASSERT_FLOAT_EQ(168, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(32, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child1)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_items_width_and_margin.cpp b/tests/generated/grid_percent_items_width_and_margin.cpp new file mode 100644 index 0000000000..d7f47a9993 --- /dev/null +++ b/tests/generated/grid_percent_items_width_and_margin.cpp @@ -0,0 +1,66 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7095f3c4789ba0bf7357499ae24aebee>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_width_and_margin.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_items_width_and_margin) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root, YGEdgeTop, 3); + YGNodeStyleSetPadding(root, YGEdgeRight, 3); + YGNodeStyleSetPadding(root, YGEdgeBottom, 3); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeLeft, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeTop, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeRight, 5); + YGNodeStyleSetMarginPercent(root_child0, YGEdgeBottom, 5); + YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeTop, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeRight, 3); + YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0, 45); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(13, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(191, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(3, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(6, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_items_width_and_padding.cpp b/tests/generated/grid_percent_items_width_and_padding.cpp new file mode 100644 index 0000000000..3023f803c5 --- /dev/null +++ b/tests/generated/grid_percent_items_width_and_padding.cpp @@ -0,0 +1,58 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<997fab94cf2217f13273ebdb64b4cc22>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_items_width_and_padding.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_items_width_and_padding) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeLeft, 3); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeTop, 3); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeRight, 3); + YGNodeStyleSetPaddingPercent(root_child0, YGEdgeBottom, 3); + YGNodeStyleSetWidthPercent(root_child0, 50); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_tracks_definite_overflow.cpp b/tests/generated/grid_percent_tracks_definite_overflow.cpp new file mode 100644 index 0000000000..5211b6527c --- /dev/null +++ b/tests/generated/grid_percent_tracks_definite_overflow.cpp @@ -0,0 +1,130 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<502524eb7debb1ac1f3fbf1c8ecc35a8>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_definite_overflow.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_tracks_definite_overflow) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 60); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(80)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(96, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(72, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(-24, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(72, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(-24, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_tracks_definite_underflow.cpp b/tests/generated/grid_percent_tracks_definite_underflow.cpp new file mode 100644 index 0000000000..0b979ef064 --- /dev/null +++ b/tests/generated/grid_percent_tracks_definite_underflow.cpp @@ -0,0 +1,130 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_definite_underflow.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_tracks_definite_underflow) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 60); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(10)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(30)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(30)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(60)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(108, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(84, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(108, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(12, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(84, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(48, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_tracks_indefinite_only.cpp b/tests/generated/grid_percent_tracks_indefinite_only.cpp new file mode 100644 index 0000000000..7d3fe76043 --- /dev/null +++ b/tests/generated/grid_percent_tracks_indefinite_only.cpp @@ -0,0 +1,128 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<2d1a565e360fa8565bfe381e23b66ab7>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_indefinite_only.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_tracks_indefinite_only) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(10)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(30)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(30)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(60)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child5)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child5)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.cpp b/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.cpp new file mode 100644 index 0000000000..c960d97f07 --- /dev/null +++ b/tests/generated/grid_percent_tracks_indefinite_with_content_overflow.cpp @@ -0,0 +1,147 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_indefinite_with_content_overflow.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_tracks_indefinite_with_content_overflow) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(50)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(80)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child6)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child6)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.cpp b/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.cpp new file mode 100644 index 0000000000..c456c7da3c --- /dev/null +++ b/tests/generated/grid_percent_tracks_indefinite_with_content_underflow.cpp @@ -0,0 +1,147 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<7547d24a0ef58d097c9667fb754f6a15>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_percent_tracks_indefinite_with_content_underflow.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_percent_tracks_indefinite_with_content_underflow) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(10)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(20)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(30)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(30)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPercent(60)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child1, 1); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child4, 4); + + YGNodeRef root_child5 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child5, 5); + + YGNodeRef root_child6 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child6, 6); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child6)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child4)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child5)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child5)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child5)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child5)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child6)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child6)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child6)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child6)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_placement_auto_negative.cpp b/tests/generated/grid_placement_auto_negative.cpp new file mode 100644 index 0000000000..4bcd54eb22 --- /dev/null +++ b/tests/generated/grid_placement_auto_negative.cpp @@ -0,0 +1,93 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_placement_auto_negative.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_placement_auto_negative) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child0, -5); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridRowStart(root_child2, 2); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.cpp b/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.cpp new file mode 100644 index 0000000000..30b1c8244a --- /dev/null +++ b/tests/generated/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.cpp @@ -0,0 +1,94 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<97c21431792fb6b878943a131c3a3d93>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_placement_definite_in_secondary_axis_with_fully_definite_negative) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridRowStart(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child1, -4); + YGNodeStyleSetGridRowStart(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridRowStart(root_child2, 1); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_placement_definite_primary.cpp b/tests/generated/grid_placement_definite_primary.cpp new file mode 100644 index 0000000000..3fb1296ce0 --- /dev/null +++ b/tests/generated/grid_placement_definite_primary.cpp @@ -0,0 +1,116 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<364a530561857f24e44751f7f4b423f0>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_placement_definite_primary.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_placement_definite_primary) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(33)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPercent(74)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child2, 1); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child3, 2); + YGNodeInsertChild(root, root_child3, 3); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetGridColumnStart(root_child4, 1); + YGNodeInsertChild(root, root_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(66, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(66, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(66, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(66, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(66, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(134, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(66, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(-14, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(134, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(66, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(-14, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(148, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(134, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(66, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_relative_all_sides.cpp b/tests/generated/grid_relative_all_sides.cpp new file mode 100644 index 0000000000..1b9ce79eed --- /dev/null +++ b/tests/generated/grid_relative_all_sides.cpp @@ -0,0 +1,59 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_relative_all_sides.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_relative_all_sides) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeTop, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeRight, 10); + YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0, 40); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_size_child_fixed_tracks.cpp b/tests/generated/grid_size_child_fixed_tracks.cpp new file mode 100644 index 0000000000..c5ed1a2f9b --- /dev/null +++ b/tests/generated/grid_size_child_fixed_tracks.cpp @@ -0,0 +1,140 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<1dc94993e0f238efc5af7c705ab4ecd2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_size_child_fixed_tracks.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_size_child_fixed_tracks) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 120); + YGNodeStyleSetHeight(root, 120); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGPoints(40)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child0, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child0, YGAlignStart); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"HH HH HH HH"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child1, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child1, YGAlignStart); + YGNodeInsertChild(root, root_child1, 1); + YGNodeSetContext(root_child1, (void*)"HHH HHH"); + YGNodeSetMeasureFunc(root_child1, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child2, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child2, YGAlignStart); + YGNodeInsertChild(root, root_child2, 2); + YGNodeSetContext(root_child2, (void*)"HH HHHH"); + YGNodeSetMeasureFunc(root_child2, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child3, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child3, YGAlignStart); + YGNodeStyleSetWidth(root_child3, 20); + YGNodeInsertChild(root, root_child3, 3); + YGNodeSetContext(root_child3, (void*)"HH HH HH HH"); + YGNodeSetMeasureFunc(root_child3, &facebook::yoga::test::IntrinsicSizeMeasure); + + YGNodeRef root_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifySelf(root_child4, YGJustifyStart); + YGNodeStyleSetAlignSelf(root_child4, YGAlignStart); + YGNodeStyleSetMaxWidth(root_child4, 30); + YGNodeInsertChild(root, root_child4, 4); + YGNodeSetContext(root_child4, (void*)"HH HH HH HH"); + YGNodeSetMeasureFunc(root_child4, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child3)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/grid_taffy_issue_624.cpp b/tests/generated/grid_taffy_issue_624.cpp new file mode 100644 index 0000000000..456bd2fa82 --- /dev/null +++ b/tests/generated/grid_taffy_issue_624.cpp @@ -0,0 +1,112 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<9c6ed4053b313cccd1051fd979129faa>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/grid_taffy_issue_624.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_taffy_issue_624) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetJustifyContent(root, YGJustifyStart); + YGNodeStyleSetJustifyItems(root, YGJustifyStart); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 320); + YGNodeStyleSetHeight(root, 640); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + auto root_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateColumns, YGFr(1)); + YGNodeStyleSetGridTemplateColumns(root, root_gridTemplateColumns); + YGGridTrackListFree(root_gridTemplateColumns); + auto root_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGAuto()); + YGGridTrackListAddTrack(root_gridTemplateRows, YGFr(1)); + YGNodeStyleSetGridTemplateRows(root, root_gridTemplateRows); + YGGridTrackListFree(root_gridTemplateRows); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 50); + YGNodeStyleSetGridColumnStart(root_child0, 1); + YGNodeStyleSetGridRowStart(root_child0, 1); + YGNodeStyleSetGridRowEndSpan(root_child0, 2); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child1, 40); + YGNodeStyleSetHeight(root_child1, 30); + YGNodeStyleSetGridColumnStart(root_child1, 2); + YGNodeStyleSetGridColumnEndSpan(root_child1, 2); + YGNodeStyleSetGridRowStart(root_child1, 1); + YGNodeStyleSetGridRowEndSpan(root_child1, 2); + YGNodeInsertChild(root, root_child1, 1); + + YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child2, 120); + YGNodeStyleSetHeight(root_child2, 20); + YGNodeStyleSetGridColumnStart(root_child2, 1); + YGNodeStyleSetGridColumnEndSpan(root_child2, 2); + YGNodeStyleSetGridRowStart(root_child2, 3); + YGNodeStyleSetGridRowEndSpan(root_child2, 1); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(640, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(320, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(640, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(220, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(180, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/xgrid_aspect_ratio_fill_child_min_width.cpp b/tests/generated/xgrid_aspect_ratio_fill_child_min_width.cpp new file mode 100644 index 0000000000..e5170563f8 --- /dev/null +++ b/tests/generated/xgrid_aspect_ratio_fill_child_min_width.cpp @@ -0,0 +1,56 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<<38191dc0420c71f7560c500d08fc3cc8>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/xgrid_aspect_ratio_fill_child_min_width.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_aspect_ratio_fill_child_min_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + YGNodeStyleSetDisplay(root, YGDisplayGrid); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMinHeight(root_child0, 50); + YGNodeStyleSetAspectRatio(root_child0, 2 / 1); + YGNodeInsertChild(root, root_child0, 0); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/generated/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.cpp b/tests/generated/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.cpp new file mode 100644 index 0000000000..cdb1bce5d9 --- /dev/null +++ b/tests/generated/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.cpp @@ -0,0 +1,131 @@ +/* + * 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. + * + * clang-format off + * @generated SignedSource<> + * generated by gentest/gentest-driver.ts from gentest/fixtures/xgrid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track.html + */ + +#include +#include +#include "../util/TestUtil.h" + +TEST(YogaTest, grid_fr_span_2_proportion_sub_1_sum_with_non_spanned_track) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidthMaxContent(root); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetDisplay(root_child0, YGDisplayGrid); + auto root_child0_gridTemplateColumns = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(0.2f)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(0.3f)); + YGGridTrackListAddTrack(root_child0_gridTemplateColumns, YGFr(0.5f)); + YGNodeStyleSetGridTemplateColumns(root_child0, root_child0_gridTemplateColumns); + YGGridTrackListFree(root_child0_gridTemplateColumns); + auto root_child0_gridTemplateRows = YGGridTrackListCreate(); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGGridTrackListAddTrack(root_child0_gridTemplateRows, YGPoints(40)); + YGNodeStyleSetGridTemplateRows(root_child0, root_child0_gridTemplateRows); + YGGridTrackListFree(root_child0_gridTemplateRows); + YGNodeInsertChild(root, root_child0, 0); + + YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0_child0, 60); + YGNodeStyleSetGridColumnStartSpan(root_child0_child0, 2); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + + YGNodeRef root_child0_child3 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child3, 3); + + YGNodeRef root_child0_child4 = YGNodeNewWithConfig(config); + YGNodeInsertChild(root_child0, root_child0_child4, 4); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(78, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(78, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(78, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(78, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(54, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(24, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child2)); + + ASSERT_FLOAT_EQ(18, YGNodeLayoutGetLeft(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child3)); + ASSERT_FLOAT_EQ(36, YGNodeLayoutGetWidth(root_child0_child3)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child3)); + + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child4)); + ASSERT_FLOAT_EQ(9, YGNodeLayoutGetWidth(root_child0_child4)); + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child4)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/tests/grid/AutoPlacementTest.cpp b/tests/grid/AutoPlacementTest.cpp new file mode 100644 index 0000000000..2e7acf3def --- /dev/null +++ b/tests/grid/AutoPlacementTest.cpp @@ -0,0 +1,507 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include + +using namespace facebook::yoga; + +class GridAutoplacementTest : public ::testing::Test { +protected: + void SetUp() override { + gridContainer = new Node(); + gridContainer->style().setDisplay(Display::Grid); + } + + void TearDown() override { + delete gridContainer; + } + + Node* gridContainer; + + Node* createGridItem(GridLine columnStart = GridLine::auto_(), + GridLine columnEnd = GridLine::auto_(), + GridLine rowStart = GridLine::auto_(), + GridLine rowEnd = GridLine::auto_()) { + auto item = new Node(); + item->style().setGridColumnStart(columnStart); + item->style().setGridColumnEnd(columnEnd); + item->style().setGridRowStart(rowStart); + item->style().setGridRowEnd(rowEnd); + gridContainer->insertChild(item, gridContainer->getChildren().size()); + return item; + } +}; + +TEST_F(GridAutoplacementTest, places_items_with_definite_positions) { + createGridItem(GridLine::fromInteger(1), GridLine::fromInteger(3), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + createGridItem(GridLine::fromInteger(2), GridLine::fromInteger(4), + GridLine::fromInteger(2), GridLine::fromInteger(3)); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + ASSERT_EQ(placements.size(), 2); + + EXPECT_EQ(placements[0].columnStart, 0); + EXPECT_EQ(placements[0].columnEnd, 2); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 1); + + EXPECT_EQ(placements[1].columnStart, 1); + EXPECT_EQ(placements[1].columnEnd, 3); + EXPECT_EQ(placements[1].rowStart, 1); + EXPECT_EQ(placements[1].rowEnd, 2); +} + +TEST_F(GridAutoplacementTest, places_items_with_definite_row_auto_column) { + createGridItem(GridLine::fromInteger(1), GridLine::fromInteger(3), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + createGridItem(GridLine::auto_(), GridLine::auto_(), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + ASSERT_EQ(placements.size(), 2); + + EXPECT_EQ(placements[0].columnStart, 0); + EXPECT_EQ(placements[0].columnEnd, 2); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 1); + EXPECT_EQ(placements[1].columnStart, 2); + EXPECT_EQ(placements[1].columnEnd, 3); + EXPECT_EQ(placements[1].rowStart, 0); + EXPECT_EQ(placements[1].rowEnd, 1); +} + +TEST_F(GridAutoplacementTest, handles_overlapping_definite_row_items) { + createGridItem(GridLine::auto_(), GridLine::span(2), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + createGridItem(GridLine::auto_(), GridLine::span(2), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 2); + + EXPECT_EQ(placements[0].columnStart, 0); + EXPECT_EQ(placements[0].columnEnd, 2); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 1); + + EXPECT_EQ(placements[1].columnStart, 2); + EXPECT_EQ(placements[1].columnEnd, 4); + EXPECT_EQ(placements[1].rowStart, 0); + EXPECT_EQ(placements[1].rowEnd, 1); +} + +TEST_F(GridAutoplacementTest, places_auto_positioned_items) { + createGridItem(); + createGridItem(); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 2); + + EXPECT_EQ(placements[0].columnStart, 0); + EXPECT_EQ(placements[0].columnEnd, 1); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 1); + + EXPECT_EQ(placements[1].columnStart, 0); + EXPECT_EQ(placements[1].columnEnd, 1); + EXPECT_EQ(placements[1].rowStart, 1); + EXPECT_EQ(placements[1].rowEnd, 2); +} + +TEST_F(GridAutoplacementTest, handles_large_spans) { + createGridItem(GridLine::auto_(), GridLine::span(5)); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 1); + + EXPECT_EQ(placements[0].columnStart, 0); + EXPECT_EQ(placements[0].columnEnd, 5); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 1); +} + +TEST_F(GridAutoplacementTest, places_items_with_definite_column_auto_row) { + createGridItem(GridLine::fromInteger(2), GridLine::fromInteger(4), + GridLine::auto_(), GridLine::auto_()); + + createGridItem(GridLine::fromInteger(1), GridLine::fromInteger(2), + GridLine::auto_(), GridLine::auto_()); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 2); + + EXPECT_EQ(placements[0].columnStart, 1); + EXPECT_EQ(placements[0].columnEnd, 3); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 1); + + EXPECT_EQ(placements[1].columnStart, 0); + EXPECT_EQ(placements[1].columnEnd, 1); + EXPECT_EQ(placements[1].rowStart, 1); + EXPECT_EQ(placements[1].rowEnd, 2); +} + +TEST_F(GridAutoplacementTest, avoids_overlaps_with_definite_column_items) { + createGridItem(GridLine::fromInteger(1), GridLine::fromInteger(3), + GridLine::fromInteger(1), GridLine::fromInteger(3)); + + createGridItem(GridLine::fromInteger(2), GridLine::fromInteger(3), + GridLine::auto_(), GridLine::auto_()); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 2); + + EXPECT_EQ(placements[0].columnStart, 0); + EXPECT_EQ(placements[0].columnEnd, 2); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 2); + + EXPECT_EQ(placements[1].columnStart, 1); + EXPECT_EQ(placements[1].columnEnd, 2); + EXPECT_EQ(placements[1].rowStart, 2); + EXPECT_EQ(placements[1].rowEnd, 3); +} + +TEST_F(GridAutoplacementTest, handles_mixed_positioning_strategies) { + createGridItem(GridLine::fromInteger(1), GridLine::fromInteger(2), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + createGridItem(GridLine::auto_(), GridLine::span(2), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + createGridItem(); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 3); + + EXPECT_EQ(placements[0].columnStart, 0); + EXPECT_EQ(placements[0].columnEnd, 1); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 1); + + EXPECT_EQ(placements[1].columnStart, 1); + EXPECT_EQ(placements[1].columnEnd, 3); + EXPECT_EQ(placements[1].rowStart, 0); + EXPECT_EQ(placements[1].rowEnd, 1); + + EXPECT_EQ(placements[2].columnStart, 0); + EXPECT_EQ(placements[2].columnEnd, 1); + EXPECT_EQ(placements[2].rowStart, 1); + EXPECT_EQ(placements[2].rowEnd, 2); +} + +TEST_F(GridAutoplacementTest, handles_negative_grid_line_references_simple) { + std::vector columns = { + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f) + }; + gridContainer->style().setGridTemplateColumns(std::move(columns)); + createGridItem(GridLine::fromInteger(-1), GridLine::fromInteger(-2)); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 1); + EXPECT_EQ(placements[0].columnStart, 2); + EXPECT_EQ(placements[0].columnEnd, 3); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 1); +} + +TEST_F(GridAutoplacementTest, handles_negative_grid_line_references) { + std::vector columns = { + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f) + }; + gridContainer->style().setGridTemplateColumns(std::move(columns)); + + // .one { grid-column-start: -5; grid-column-end: -4; } + auto node1 = createGridItem(GridLine::fromInteger(-5), GridLine::fromInteger(-4)); + + // .two { grid-column-start: 1; grid-column-end: 2; grid-row-start: 1; grid-row-end: 2; } + auto node2 = createGridItem(GridLine::fromInteger(1), GridLine::fromInteger(2), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + auto node3 = createGridItem(); + auto node4 = createGridItem(); + auto node5 = createGridItem(); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 5); + + for (auto placement : placements) { + if (placement.node == node1) { + EXPECT_EQ(placement.columnStart, -1); + EXPECT_EQ(placement.columnEnd, 0); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } else if (placement.node == node2) { + EXPECT_EQ(placement.columnStart, 0); + EXPECT_EQ(placement.columnEnd, 1); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } + else if (placement.node == node3) { + EXPECT_EQ(placement.columnStart, 1); + EXPECT_EQ(placement.columnEnd, 2); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } + else if (placement.node == node4) { + EXPECT_EQ(placement.columnStart, 2); + EXPECT_EQ(placement.columnEnd, 3); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } + else if (placement.node == node5) { + EXPECT_EQ(placement.columnStart, -1); + EXPECT_EQ(placement.columnEnd, 0); + EXPECT_EQ(placement.rowStart, 1); + EXPECT_EQ(placement.rowEnd, 2); + } + } +} + +TEST_F(GridAutoplacementTest, same_start_and_end_line_spans_one_track) { + createGridItem( + GridLine::fromInteger(1), GridLine::fromInteger(1), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 1); + EXPECT_EQ(placements[0].columnStart, 0); + EXPECT_EQ(placements[0].columnEnd, 1); + EXPECT_EQ(placements[0].rowStart, 0); + EXPECT_EQ(placements[0].rowEnd, 1); +} + +TEST_F(GridAutoplacementTest, handles_negative_grid_lines_with_row_positioning) { + std::vector columns = { + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f) + }; + gridContainer->style().setGridTemplateColumns(std::move(columns)); + + // .one { grid-column-start: -5; grid-column-end: -4; grid-row-start: 2; grid-row-end: 3; } + auto node1 = createGridItem(GridLine::fromInteger(-5), GridLine::fromInteger(-4), + GridLine::fromInteger(2), GridLine::fromInteger(3)); + + // .two { grid-row-start: 1; grid-row-end: 2; } + auto node2 = createGridItem(GridLine::auto_(), GridLine::auto_(), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + auto node3 = createGridItem(); + auto node4 = createGridItem(); + auto node5 = createGridItem(); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems;; + + ASSERT_EQ(placements.size(), 5); + + for (auto placement : placements) { + if (placement.node == node1) { + EXPECT_EQ(placement.columnStart, -1); + EXPECT_EQ(placement.columnEnd, 0); + EXPECT_EQ(placement.rowStart, 1); + EXPECT_EQ(placement.rowEnd, 2); + } else if (placement.node == node2) { + EXPECT_EQ(placement.columnStart, -1); + EXPECT_EQ(placement.columnEnd, 0); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } else if (placement.node == node3) { + EXPECT_EQ(placement.columnStart, 0); + EXPECT_EQ(placement.columnEnd, 1); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } else if (placement.node == node4) { + EXPECT_EQ(placement.columnStart, 1); + EXPECT_EQ(placement.columnEnd, 2); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } else if (placement.node == node5) { + EXPECT_EQ(placement.columnStart, 2); + EXPECT_EQ(placement.columnEnd, 3); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } + } +} + +TEST_F(GridAutoplacementTest, skips_past_large_blocking_items) { + auto largeItem = createGridItem( + GridLine::fromInteger(1), GridLine::fromInteger(6), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + auto autoItem1 = createGridItem( + GridLine::auto_(), GridLine::auto_(), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + auto autoItem2 = createGridItem( + GridLine::auto_(), GridLine::auto_(), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 3); + + for (auto placement : placements) { + if (placement.node == largeItem) { + EXPECT_EQ(placement.columnStart, 0); + EXPECT_EQ(placement.columnEnd, 5); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } else if (placement.node == autoItem1) { + EXPECT_EQ(placement.columnStart, 5); + EXPECT_EQ(placement.columnEnd, 6); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } else if (placement.node == autoItem2) { + EXPECT_EQ(placement.columnStart, 6); + EXPECT_EQ(placement.columnEnd, 7); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } + } +} + +TEST_F(GridAutoplacementTest, skips_past_large_blocking_rows) { + createGridItem( + GridLine::fromInteger(1), GridLine::fromInteger(2), + GridLine::fromInteger(1), GridLine::fromInteger(6)); + + auto autoItem = createGridItem( + GridLine::fromInteger(1), GridLine::fromInteger(2), + GridLine::auto_(), GridLine::auto_()); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 2); + + for (auto placement : placements) { + if (placement.node == autoItem) { + EXPECT_EQ(placement.columnStart, 0); + EXPECT_EQ(placement.columnEnd, 1); + EXPECT_EQ(placement.rowStart, 5); + EXPECT_EQ(placement.rowEnd, 6); + } + } +} + +TEST_F(GridAutoplacementTest, handles_nested_overlapping_items) { + createGridItem( + GridLine::fromInteger(1), GridLine::fromInteger(8), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + createGridItem( + GridLine::fromInteger(3), GridLine::fromInteger(5), + GridLine::fromInteger(2), GridLine::fromInteger(3)); + + auto autoItem = createGridItem( + GridLine::auto_(), GridLine::auto_(), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + + ASSERT_EQ(placements.size(), 3); + + for (auto placement : placements) { + if (placement.node == autoItem) { + EXPECT_EQ(placement.columnStart, 7); + EXPECT_EQ(placement.columnEnd, 8); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } + } +} + +TEST_F(GridAutoplacementTest, handles_negative_and_positive_grid_lines_auto_row) { + std::vector columns = { + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f) + }; + gridContainer->style().setGridTemplateColumns(std::move(columns)); + + // .one { grid-column-start: -5; grid-column-end: -4; grid-row-start: 1; grid-row-end: 2; } + auto node1 = createGridItem(GridLine::fromInteger(-5), GridLine::fromInteger(-4), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + // .two { grid-column-start: 1; grid-column-end: 2; } (auto rows) + auto node2 = createGridItem(GridLine::fromInteger(1), GridLine::fromInteger(2), + GridLine::auto_(), GridLine::auto_()); + + auto node3 = createGridItem(); + auto node4 = createGridItem(); + auto node5 = createGridItem(); + + auto autoPlacementResult = AutoPlacement::performAutoPlacement(gridContainer); + auto& placements = autoPlacementResult.gridItems; + ASSERT_EQ(placements.size(), 5); + + for (auto placement : placements) { + if (placement.node == node1) { + EXPECT_EQ(placement.columnStart, -1); + EXPECT_EQ(placement.columnEnd, 0); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } else if (placement.node == node2) { + EXPECT_EQ(placement.columnStart, 0); + EXPECT_EQ(placement.columnEnd, 1); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } else if (placement.node == node3) { + EXPECT_EQ(placement.columnStart, 1); + EXPECT_EQ(placement.columnEnd, 2); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } else if (placement.node == node4) { + EXPECT_EQ(placement.columnStart, 2); + EXPECT_EQ(placement.columnEnd, 3); + EXPECT_EQ(placement.rowStart, 0); + EXPECT_EQ(placement.rowEnd, 1); + } + else if (placement.node == node5) { + EXPECT_EQ(placement.columnStart, -1); + EXPECT_EQ(placement.columnEnd, 0); + EXPECT_EQ(placement.rowStart, 1); + EXPECT_EQ(placement.rowEnd, 2); + } + } +} diff --git a/tests/grid/CreateGridTrackTest.cpp b/tests/grid/CreateGridTrackTest.cpp new file mode 100644 index 0000000000..f6977d1ffa --- /dev/null +++ b/tests/grid/CreateGridTrackTest.cpp @@ -0,0 +1,269 @@ +/* +* 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. +*/ + +#include +#include +#include +#include +#include +#include +#include + +using namespace facebook::yoga; + +class GridCreateTracksTest : public ::testing::Test { +protected: + void SetUp() override { + gridContainer = new Node(); + gridContainer->style().setDisplay(Display::Grid); + } + + void TearDown() override { + delete gridContainer; + } + + Node* gridContainer; + + Node* createGridItem(GridLine columnStart = GridLine::auto_(), + GridLine columnEnd = GridLine::auto_(), + GridLine rowStart = GridLine::auto_(), + GridLine rowEnd = GridLine::auto_()) { + auto item = new Node(); + item->style().setGridColumnStart(columnStart); + item->style().setGridColumnEnd(columnEnd); + item->style().setGridRowStart(rowStart); + item->style().setGridRowEnd(rowEnd); + gridContainer->insertChild(item, gridContainer->getChildren().size()); + return item; + } +}; + +TEST_F(GridCreateTracksTest, only_explicit_tracks) { + std::vector columns = { + GridTrackSize::length(100.0f), + GridTrackSize::length(150.0f) + }; + std::vector rows = { + GridTrackSize::length(80.0f), + GridTrackSize::fr(1.0f) + }; + + gridContainer->style().setGridTemplateColumns(std::move(columns)); + gridContainer->style().setGridTemplateRows(std::move(rows)); + + createGridItem(GridLine::fromInteger(1), GridLine::fromInteger(2), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + createGridItem(GridLine::fromInteger(2), GridLine::fromInteger(3), + GridLine::fromInteger(2), GridLine::fromInteger(3)); + + auto autoPlacementResult = ResolvedAutoPlacement::resolveGridItemPlacements(gridContainer); + GridTracks tracks = createGridTracks(gridContainer, autoPlacementResult); + + EXPECT_EQ(tracks.columnTracks.size(), 2); + EXPECT_TRUE(tracks.columnTracks[0].minSizingFunction.isPoints()); + EXPECT_TRUE(tracks.columnTracks[1].minSizingFunction.isPoints()); + + EXPECT_EQ(tracks.rowTracks.size(), 2); + EXPECT_TRUE(tracks.rowTracks[0].minSizingFunction.isPoints()); + EXPECT_TRUE(tracks.rowTracks[1].maxSizingFunction.isStretch()); +} + +TEST_F(GridCreateTracksTest, implicit_tracks_after_explicit_grid) { + std::vector columns = { + GridTrackSize::length(100.0f), + GridTrackSize::length(150.0f) + }; + + gridContainer->style().setGridTemplateColumns(std::move(columns)); + + createGridItem(GridLine::fromInteger(1), GridLine::fromInteger(5), + GridLine::fromInteger(1), GridLine::fromInteger(2)); + + auto autoPlacementResult = ResolvedAutoPlacement::resolveGridItemPlacements(gridContainer); + GridTracks tracks = createGridTracks(gridContainer, autoPlacementResult); + + EXPECT_EQ(tracks.columnTracks.size(), 4); + + EXPECT_TRUE(tracks.columnTracks[0].minSizingFunction.isPoints()); + EXPECT_TRUE(tracks.columnTracks[1].minSizingFunction.isPoints()); + + EXPECT_TRUE(tracks.columnTracks[2].minSizingFunction.isAuto()); + EXPECT_TRUE(tracks.columnTracks[3].minSizingFunction.isAuto()); +} + +TEST_F(GridCreateTracksTest, implicit_tracks_before_explicit_grid_negative_indices) { + std::vector columns = { + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f), + GridTrackSize::length(20.0f) + }; + + gridContainer->style().setGridTemplateColumns(std::move(columns)); + + createGridItem(GridLine::fromInteger(-5), GridLine::fromInteger(-4)); + + auto autoPlacementResult = ResolvedAutoPlacement::resolveGridItemPlacements(gridContainer); + GridTracks tracks = createGridTracks(gridContainer, autoPlacementResult); + + EXPECT_EQ(tracks.columnTracks.size(), 4); + + EXPECT_TRUE(tracks.columnTracks[0].minSizingFunction.isAuto()); +} + +TEST_F(GridCreateTracksTest, implicit_tracks_before_and_after) { + std::vector columns = { + GridTrackSize::length(100.0f), + GridTrackSize::fr(1.0f) + }; + + // creates 3 grid lines 1, 2, 3 + gridContainer->style().setGridTemplateColumns(std::move(columns)); + // -4 index = 0 index. 1 new track before. and 5 index = 1 new track after. total 5 tracks + createGridItem(GridLine::fromInteger(-4), GridLine::fromInteger(5)); + + auto autoPlacementResult = ResolvedAutoPlacement::resolveGridItemPlacements(gridContainer); + GridTracks tracks = createGridTracks(gridContainer, autoPlacementResult); + + EXPECT_EQ(tracks.columnTracks.size(), 5); + EXPECT_TRUE(tracks.columnTracks[0].minSizingFunction.isAuto()); + EXPECT_TRUE(tracks.columnTracks[1].minSizingFunction.isPoints()); + EXPECT_TRUE(tracks.columnTracks[2].maxSizingFunction.isStretch()); + EXPECT_TRUE(tracks.columnTracks[4].minSizingFunction.isAuto()); + EXPECT_TRUE(tracks.columnTracks[4].minSizingFunction.isAuto()); +} + +TEST_F(GridCreateTracksTest, no_explicit_tracks_only_implicit) { + createGridItem(); + createGridItem(); + createGridItem(); + + auto autoPlacementResult = ResolvedAutoPlacement::resolveGridItemPlacements(gridContainer); + GridTracks tracks = createGridTracks(gridContainer, autoPlacementResult); + + for (const auto& track : tracks.columnTracks) { + EXPECT_TRUE(track.minSizingFunction.isAuto()); + } + + for (const auto& track : tracks.rowTracks) { + EXPECT_TRUE(track.minSizingFunction.isAuto()); + } +} + +TEST_F(GridCreateTracksTest, empty_grid_no_items) { + std::vector columns = { + GridTrackSize::length(100.0f), + GridTrackSize::length(150.0f) + }; + + gridContainer->style().setGridTemplateColumns(std::move(columns)); + + auto autoPlacementResult = ResolvedAutoPlacement::resolveGridItemPlacements(gridContainer); + GridTracks tracks = createGridTracks(gridContainer, autoPlacementResult); + EXPECT_EQ(tracks.columnTracks.size(), 2); +} + +TEST_F(GridCreateTracksTest, large_span_creating_many_implicit_tracks) { + createGridItem(GridLine::auto_(), GridLine::span(10)); + + auto autoPlacementResult = ResolvedAutoPlacement::resolveGridItemPlacements(gridContainer); + GridTracks tracks = createGridTracks(gridContainer, autoPlacementResult); + + EXPECT_EQ(tracks.columnTracks.size(), 10); + + for (const auto& track : tracks.columnTracks) { + EXPECT_TRUE(track.minSizingFunction.isAuto()); + } +} + +TEST_F(GridCreateTracksTest, grid_auto_columns_pattern_repeats_backward) { + std::vector columns = { + GridTrackSize::length(100.0f), + GridTrackSize::length(150.0f) + }; + gridContainer->style().setGridTemplateColumns(std::move(columns)); + + std::vector autoColumns = { + GridTrackSize::length(50.0f), + GridTrackSize::fr(1.0f), + GridTrackSize::length(75.0f) + }; + gridContainer->style().setGridAutoColumns(std::move(autoColumns)); + + createGridItem(GridLine::fromInteger(-8), GridLine::fromInteger(-7)); + createGridItem(GridLine::fromInteger(3), GridLine::fromInteger(6)); + + auto autoPlacementResult = ResolvedAutoPlacement::resolveGridItemPlacements(gridContainer); + GridTracks tracks = createGridTracks(gridContainer, autoPlacementResult); + + // 5 negative implicit + 2 explicit + 3 positive implicit = 10 tracks + EXPECT_EQ(tracks.columnTracks.size(), 10); + + // Implicit tracks before explicit grid + EXPECT_TRUE(tracks.columnTracks[4].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.columnTracks[4].minSizingFunction.resolve(0.0f).unwrap(), 75.0f); + EXPECT_TRUE(tracks.columnTracks[3].maxSizingFunction.isStretch()); + EXPECT_TRUE(tracks.columnTracks[2].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.columnTracks[2].minSizingFunction.resolve(0.0f).unwrap(), 50.0f); + EXPECT_TRUE(tracks.columnTracks[1].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.columnTracks[1].minSizingFunction.resolve(0.0f).unwrap(), 75.0f); + EXPECT_TRUE(tracks.columnTracks[0].maxSizingFunction.isStretch()); + + // Explicit grid + EXPECT_TRUE(tracks.columnTracks[5].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.columnTracks[5].minSizingFunction.resolve(0.0f).unwrap(), 100.0f); + EXPECT_TRUE(tracks.columnTracks[6].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.columnTracks[6].minSizingFunction.resolve(0.0f).unwrap(), 150.0f); + + // Implicit tracks after explicit grid + EXPECT_TRUE(tracks.columnTracks[7].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.columnTracks[7].minSizingFunction.resolve(0.0f).unwrap(), 50.0f); + EXPECT_TRUE(tracks.columnTracks[8].maxSizingFunction.isStretch()); + EXPECT_TRUE(tracks.columnTracks[9].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.columnTracks[9].minSizingFunction.resolve(0.0f).unwrap(), 75.0f); +} + +TEST_F(GridCreateTracksTest, grid_auto_rows_pattern_repeats_both_directions) { + std::vector rows = { + GridTrackSize::length(200.0f) + }; + gridContainer->style().setGridTemplateRows(std::move(rows)); + + std::vector autoRows = { + GridTrackSize::length(60.0f), + GridTrackSize::length(80.0f) + }; + gridContainer->style().setGridAutoRows(std::move(autoRows)); + + createGridItem(GridLine::auto_(), GridLine::auto_(), + GridLine::fromInteger(-4), GridLine::fromInteger(-2)); + + createGridItem(GridLine::auto_(), GridLine::auto_(), + GridLine::fromInteger(3), GridLine::fromInteger(5)); + + auto autoPlacementResult = ResolvedAutoPlacement::resolveGridItemPlacements(gridContainer); + GridTracks tracks = createGridTracks(gridContainer, autoPlacementResult); + + // 2 implicit before + 1 explicit + 3 implicit after = 7 tracks + EXPECT_EQ(tracks.rowTracks.size(), 6); + + // Implicit tracks before explicit grid + EXPECT_TRUE(tracks.rowTracks[1].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.rowTracks[1].minSizingFunction.resolve(0.0f).unwrap(), 80.0f); + EXPECT_TRUE(tracks.rowTracks[0].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.rowTracks[0].minSizingFunction.resolve(0.0f).unwrap(), 60.0f); + + // Explicit grid + EXPECT_EQ(tracks.rowTracks[2].minSizingFunction.resolve(0.0f).unwrap(), 200.0f); + + // Implicit tracks after explicit grid + EXPECT_TRUE(tracks.rowTracks[3].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.rowTracks[3].minSizingFunction.resolve(0.0f).unwrap(), 60.0f); + EXPECT_TRUE(tracks.rowTracks[4].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.rowTracks[4].minSizingFunction.resolve(0.0f).unwrap(), 80.0f); + EXPECT_TRUE(tracks.rowTracks[5].minSizingFunction.isPoints()); + EXPECT_EQ(tracks.rowTracks[5].minSizingFunction.resolve(0.0f).unwrap(), 60.0f); +} diff --git a/website/src/components/FlexStyle.ts b/website/src/components/FlexStyle.ts index c0a7a2b34e..2a5f4f8a64 100644 --- a/website/src/components/FlexStyle.ts +++ b/website/src/components/FlexStyle.ts @@ -14,6 +14,7 @@ import { Display, Edge, FlexDirection, + GridTrackType, Gutter, Justify, Overflow, @@ -63,7 +64,7 @@ export type FlexStyle = { bottom?: number | `${number}%`; boxSizing?: 'border-box' | 'content-box'; direction?: 'ltr' | 'rtl'; - display?: 'none' | 'flex' | 'contents'; + display?: 'none' | 'flex' | 'contents' | 'grid'; end?: number | `${number}%`; flex?: number; flexBasis?: number | 'auto' | `${number}%`; @@ -108,6 +109,15 @@ export type FlexStyle = { insetBlock?: number | `${number}%`; inset?: number | `${number}%`; width?: number | 'auto' | `${number}%`; + // Grid properties + gridTemplateColumns?: string; + gridTemplateRows?: string; + gridAutoColumns?: string; + gridAutoRows?: string; + gridColumnStart?: number | `span ${number}`; + gridColumnEnd?: number | `span ${number}`; + gridRowStart?: number | `span ${number}`; + gridRowEnd?: number | `span ${number}`; }; export function applyStyle(node: YogaNode, style: FlexStyle = {}): void { @@ -297,6 +307,64 @@ export function applyStyle(node: YogaNode, style: FlexStyle = {}): void { case 'width': node.setWidth(style.width); break; + case 'gridTemplateColumns': + node.setGridTemplateColumns( + parseGridTemplate(style.gridTemplateColumns), + ); + break; + case 'gridTemplateRows': + node.setGridTemplateRows(parseGridTemplate(style.gridTemplateRows)); + break; + case 'gridAutoColumns': + node.setGridAutoColumns(parseGridTemplate(style.gridAutoColumns)); + break; + case 'gridAutoRows': + node.setGridAutoRows(parseGridTemplate(style.gridAutoRows)); + break; + case 'gridColumnStart': + if ( + typeof style.gridColumnStart === 'string' && + style.gridColumnStart.startsWith('span ') + ) { + node.setGridColumnStartSpan( + parseInt(style.gridColumnStart.slice(5), 10), + ); + } else { + node.setGridColumnStart(style.gridColumnStart as number); + } + break; + case 'gridColumnEnd': + if ( + typeof style.gridColumnEnd === 'string' && + style.gridColumnEnd.startsWith('span ') + ) { + node.setGridColumnEndSpan( + parseInt(style.gridColumnEnd.slice(5), 10), + ); + } else { + node.setGridColumnEnd(style.gridColumnEnd as number); + } + break; + case 'gridRowStart': + if ( + typeof style.gridRowStart === 'string' && + style.gridRowStart.startsWith('span ') + ) { + node.setGridRowStartSpan(parseInt(style.gridRowStart.slice(5), 10)); + } else { + node.setGridRowStart(style.gridRowStart as number); + } + break; + case 'gridRowEnd': + if ( + typeof style.gridRowEnd === 'string' && + style.gridRowEnd.startsWith('span ') + ) { + node.setGridRowEndSpan(parseInt(style.gridRowEnd.slice(5), 10)); + } else { + node.setGridRowEnd(style.gridRowEnd as number); + } + break; } } catch (e) { // Fail gracefully @@ -360,7 +428,7 @@ function direction(str?: 'ltr' | 'rtl'): Direction { throw new Error(`"${str}" is not a valid value for direction`); } -function display(str?: 'none' | 'flex' | 'contents'): Display { +function display(str?: 'none' | 'flex' | 'contents' | 'grid'): Display { switch (str) { case 'none': return Display.None; @@ -368,6 +436,8 @@ function display(str?: 'none' | 'flex' | 'contents'): Display { return Display.Flex; case 'contents': return Display.Contents; + case 'grid': + return Display.Grid; } throw new Error(`"${str}" is not a valid value for display`); } @@ -441,3 +511,75 @@ function position(str?: 'absolute' | 'relative' | 'static'): PositionType { } throw new Error(`"${str}" is not a valid value for position`); } + +type GridTrackValue = { + type: GridTrackType; + value?: number; + min?: GridTrackValue; + max?: GridTrackValue; +}; + +function parseGridTrackValue(track: string): GridTrackValue { + track = track.trim(); + + if (track === 'auto') { + return {type: GridTrackType.Auto}; + } + + if (track.endsWith('fr')) { + return {type: GridTrackType.Fr, value: parseFloat(track)}; + } + + if (track.endsWith('%')) { + return {type: GridTrackType.Percent, value: parseFloat(track)}; + } + + if (track.endsWith('px')) { + return {type: GridTrackType.Points, value: parseFloat(track)}; + } + + if (track.startsWith('minmax(') && track.endsWith(')')) { + const inner = track.slice(7, -1); + const commaIndex = findTopLevelComma(inner); + if (commaIndex === -1) { + throw new Error(`Invalid minmax syntax: ${track}`); + } + const minPart = inner.slice(0, commaIndex).trim(); + const maxPart = inner.slice(commaIndex + 1).trim(); + return { + type: GridTrackType.Minmax, + min: parseGridTrackValue(minPart), + max: parseGridTrackValue(maxPart), + }; + } + + const num = parseFloat(track); + if (!isNaN(num)) { + return {type: GridTrackType.Points, value: num}; + } + + throw new Error(`Invalid grid track value: ${track}`); +} + +function findTopLevelComma(str: string): number { + let depth = 0; + for (let i = 0; i < str.length; i++) { + if (str[i] === '(') depth++; + else if (str[i] === ')') depth--; + else if (str[i] === ',' && depth === 0) return i; + } + return -1; +} + +function parseGridTemplate(template?: string): GridTrackValue[] { + if (!template) return []; + + const tracks: GridTrackValue[] = []; + const parts = template.trim().split(/\s+/); + + for (const part of parts) { + tracks.push(parseGridTrackValue(part)); + } + + return tracks; +} diff --git a/yoga/CMakeLists.txt b/yoga/CMakeLists.txt index b6eca1ac72..594600f702 100644 --- a/yoga/CMakeLists.txt +++ b/yoga/CMakeLists.txt @@ -20,7 +20,8 @@ include(${YOGA_ROOT}/cmake/project-defaults.cmake) file(GLOB SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/**/*.cpp) + ${CMAKE_CURRENT_SOURCE_DIR}/**/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/grid/*.cpp) add_library(yogacore STATIC ${SOURCES}) diff --git a/yoga/YGEnums.cpp b/yoga/YGEnums.cpp index 4bdace6b7a..9fc4a83a82 100644 --- a/yoga/YGEnums.cpp +++ b/yoga/YGEnums.cpp @@ -29,6 +29,10 @@ const char* YGAlignToString(const YGAlign value) { return "space-around"; case YGAlignSpaceEvenly: return "space-evenly"; + case YGAlignStart: + return "start"; + case YGAlignEnd: + return "end"; } return "unknown"; } @@ -73,6 +77,8 @@ const char* YGDisplayToString(const YGDisplay value) { return "none"; case YGDisplayContents: return "contents"; + case YGDisplayGrid: + return "grid"; } return "unknown"; } @@ -141,6 +147,22 @@ const char* YGFlexDirectionToString(const YGFlexDirection value) { return "unknown"; } +const char* YGGridTrackTypeToString(const YGGridTrackType value) { + switch (value) { + case YGGridTrackTypeAuto: + return "auto"; + case YGGridTrackTypePoints: + return "points"; + case YGGridTrackTypePercent: + return "percent"; + case YGGridTrackTypeFr: + return "fr"; + case YGGridTrackTypeMinmax: + return "minmax"; + } + return "unknown"; +} + const char* YGGutterToString(const YGGutter value) { switch (value) { case YGGutterColumn: @@ -155,6 +177,8 @@ const char* YGGutterToString(const YGGutter value) { const char* YGJustifyToString(const YGJustify value) { switch (value) { + case YGJustifyAuto: + return "auto"; case YGJustifyFlexStart: return "flex-start"; case YGJustifyCenter: @@ -167,6 +191,12 @@ const char* YGJustifyToString(const YGJustify value) { return "space-around"; case YGJustifySpaceEvenly: return "space-evenly"; + case YGJustifyStretch: + return "stretch"; + case YGJustifyStart: + return "start"; + case YGJustifyEnd: + return "end"; } return "unknown"; } diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index bb83bcfac9..1b69f09318 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -22,7 +22,9 @@ YG_ENUM_DECL( YGAlignBaseline, YGAlignSpaceBetween, YGAlignSpaceAround, - YGAlignSpaceEvenly) + YGAlignSpaceEvenly, + YGAlignStart, + YGAlignEnd) YG_ENUM_DECL( YGBoxSizing, @@ -44,7 +46,8 @@ YG_ENUM_DECL( YGDisplay, YGDisplayFlex, YGDisplayNone, - YGDisplayContents) + YGDisplayContents, + YGDisplayGrid) YG_ENUM_DECL( YGEdge, @@ -79,6 +82,14 @@ YG_ENUM_DECL( YGFlexDirectionRow, YGFlexDirectionRowReverse) +YG_ENUM_DECL( + YGGridTrackType, + YGGridTrackTypeAuto, + YGGridTrackTypePoints, + YGGridTrackTypePercent, + YGGridTrackTypeFr, + YGGridTrackTypeMinmax) + YG_ENUM_DECL( YGGutter, YGGutterColumn, @@ -87,12 +98,16 @@ YG_ENUM_DECL( YG_ENUM_DECL( YGJustify, + YGJustifyAuto, YGJustifyFlexStart, YGJustifyCenter, YGJustifyFlexEnd, YGJustifySpaceBetween, YGJustifySpaceAround, - YGJustifySpaceEvenly) + YGJustifySpaceEvenly, + YGJustifyStretch, + YGJustifyStart, + YGJustifyEnd) YG_ENUM_DECL( YGLogLevel, diff --git a/yoga/YGGridTrackList.cpp b/yoga/YGGridTrackList.cpp new file mode 100644 index 0000000000..4c148e56fe --- /dev/null +++ b/yoga/YGGridTrackList.cpp @@ -0,0 +1,186 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include + +using namespace facebook::yoga; + +// Internal representation of a grid track value +struct YGGridTrackValue { + enum class Type { + Points, + Percent, + Fr, + Auto, + MinMax + }; + + Type type; + float value; + YGGridTrackValue* minValue; + YGGridTrackValue* maxValue; + + YGGridTrackValue(Type t, float v = 0.0f) + : type(t), value(v), minValue(nullptr), maxValue(nullptr) {} + + YGGridTrackValue(YGGridTrackValue* min, YGGridTrackValue* max) + : type(Type::MinMax), + value(0.0f), + minValue(min), + maxValue(max) {} + + ~YGGridTrackValue() { + // MinMax owns its min/max values + if (type == Type::MinMax) { + delete minValue; + delete maxValue; + } + } + + StyleSizeLength toStyleSizeLength() const { + switch (type) { + case Type::Points: + return StyleSizeLength::points(value); + case Type::Percent: + return StyleSizeLength::percent(value); + case Type::Fr: + return StyleSizeLength::stretch(value); + case Type::Auto: + return StyleSizeLength::ofAuto(); + case Type::MinMax: + // MinMax should not call this, it needs special handling + return StyleSizeLength::ofAuto(); + } + return StyleSizeLength::ofAuto(); + } +}; + +// Internal representation of a grid track list +struct YGGridTrackList { + std::vector tracks; + + ~YGGridTrackList() { + for (auto* track : tracks) { + delete track; + } + } + + GridTrackList toGridTrackList() const { + GridTrackList result; + result.reserve(tracks.size()); + + for (auto* track : tracks) { + if (track->type == YGGridTrackValue::Type::MinMax) { + auto min = track->minValue->toStyleSizeLength(); + auto max = track->maxValue->toStyleSizeLength(); + result.push_back(GridTrackSize::minmax(min, max)); + } else { + switch (track->type) { + case YGGridTrackValue::Type::Points: + result.push_back(GridTrackSize::length(track->value)); + break; + case YGGridTrackValue::Type::Percent: + result.push_back(GridTrackSize::percent(track->value)); + break; + case YGGridTrackValue::Type::Fr: + result.push_back(GridTrackSize::fr(track->value)); + break; + case YGGridTrackValue::Type::Auto: + result.push_back(GridTrackSize::auto_()); + break; + case YGGridTrackValue::Type::MinMax: + // Already handled above + break; + } + } + } + + return result; + } +}; + +YGGridTrackListRef YGGridTrackListCreate() { + return new YGGridTrackList(); +} + +void YGGridTrackListFree(YGGridTrackListRef list) { + delete list; +} + +void YGGridTrackListAddTrack( + YGGridTrackListRef list, + YGGridTrackValueRef trackValue) { + if (list && trackValue) { + list->tracks.push_back(trackValue); + } +} + +YGGridTrackValueRef YGPoints(float points) { + return new YGGridTrackValue(YGGridTrackValue::Type::Points, points); +} + +YGGridTrackValueRef YGPercent(float percent) { + return new YGGridTrackValue(YGGridTrackValue::Type::Percent, percent); +} + +YGGridTrackValueRef YGFr(float fr) { + return new YGGridTrackValue(YGGridTrackValue::Type::Fr, fr); +} + +YGGridTrackValueRef YGAuto() { + return new YGGridTrackValue(YGGridTrackValue::Type::Auto); +} + +YGGridTrackValueRef YGMinMax( + YGGridTrackValueRef min, + YGGridTrackValueRef max) { + return new YGGridTrackValue(min, max); +} + +void YGNodeStyleSetGridTemplateRows( + YGNodeRef node, + YGGridTrackListRef trackList) { + if (node && trackList) { + auto* n = resolveRef(node); + n->style().setGridTemplateRows(trackList->toGridTrackList()); + n->markDirtyAndPropagate(); + } +} + +void YGNodeStyleSetGridTemplateColumns( + YGNodeRef node, + YGGridTrackListRef trackList) { + if (node && trackList) { + auto* n = resolveRef(node); + n->style().setGridTemplateColumns(trackList->toGridTrackList()); + n->markDirtyAndPropagate(); + } +} + +void YGNodeStyleSetGridAutoRows( + YGNodeRef node, + YGGridTrackListRef trackList) { + if (node && trackList) { + auto* n = resolveRef(node); + n->style().setGridAutoRows(trackList->toGridTrackList()); + n->markDirtyAndPropagate(); + } +} + +void YGNodeStyleSetGridAutoColumns( + YGNodeRef node, + YGGridTrackListRef trackList) { + if (node && trackList) { + auto* n = resolveRef(node); + n->style().setGridAutoColumns(trackList->toGridTrackList()); + n->markDirtyAndPropagate(); + } +} diff --git a/yoga/YGGridTrackList.h b/yoga/YGGridTrackList.h new file mode 100644 index 0000000000..c3fedfa33a --- /dev/null +++ b/yoga/YGGridTrackList.h @@ -0,0 +1,97 @@ +/* + * 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. + */ + +#pragma once + +#include +#include + +YG_EXTERN_C_BEGIN + +/** + * Opaque handle to a grid track list for building grid-template-rows/columns. + */ +typedef struct YGGridTrackList* YGGridTrackListRef; + +/** + * Opaque handle to a grid track value. + */ +typedef struct YGGridTrackValue* YGGridTrackValueRef; + +/** + * Create a new grid track list. + */ +YG_EXPORT YGGridTrackListRef YGGridTrackListCreate(void); + +/** + * Free a grid track list. + */ +YG_EXPORT void YGGridTrackListFree(YGGridTrackListRef list); + +/** + * Add a track to the grid track list. + */ +YG_EXPORT void YGGridTrackListAddTrack( + YGGridTrackListRef list, + YGGridTrackValueRef trackValue); + +/** + * Create a grid track value with a points (px) length. + */ +YG_EXPORT YGGridTrackValueRef YGPoints(float points); + +/** + * Create a grid track value with a percentage length. + */ +YG_EXPORT YGGridTrackValueRef YGPercent(float percent); + +/** + * Create a grid track value with a flexible (fr) length. + */ +YG_EXPORT YGGridTrackValueRef YGFr(float fr); + +/** + * Create a grid track value with auto sizing. + */ +YG_EXPORT YGGridTrackValueRef YGAuto(void); + +/** + * Create a grid track value with minmax(min, max) sizing. + */ +YG_EXPORT YGGridTrackValueRef YGMinMax( + YGGridTrackValueRef min, + YGGridTrackValueRef max); + +/** + * Set the grid-template-rows property on a node. + */ +YG_EXPORT void YGNodeStyleSetGridTemplateRows( + YGNodeRef node, + YGGridTrackListRef trackList); + +/** + * Set the grid-template-columns property on a node. + */ +YG_EXPORT void YGNodeStyleSetGridTemplateColumns( + YGNodeRef node, + YGGridTrackListRef trackList); + +/** + * Set the grid-auto-rows property on a node. + */ +YG_EXPORT void YGNodeStyleSetGridAutoRows( + YGNodeRef node, + YGGridTrackListRef trackList); + +/** + * Set the grid-auto-columns property on a node. + */ +YG_EXPORT void YGNodeStyleSetGridAutoColumns( + YGNodeRef node, + YGGridTrackListRef trackList); + +YG_EXTERN_C_END diff --git a/yoga/YGNodeStyle.cpp b/yoga/YGNodeStyle.cpp index 4e77405b6c..fd3c608a5d 100644 --- a/yoga/YGNodeStyle.cpp +++ b/yoga/YGNodeStyle.cpp @@ -74,6 +74,28 @@ YGJustify YGNodeStyleGetJustifyContent(const YGNodeConstRef node) { return unscopedEnum(resolveRef(node)->style().justifyContent()); } +void YGNodeStyleSetJustifyItems( + const YGNodeRef node, + const YGJustify justifyItems) { + updateStyle<&Style::justifyItems, &Style::setJustifyItems>( + node, scopedEnum(justifyItems)); +} + +YGJustify YGNodeStyleGetJustifyItems(const YGNodeConstRef node) { + return unscopedEnum(resolveRef(node)->style().justifyItems()); +} + +void YGNodeStyleSetJustifySelf( + const YGNodeRef node, + const YGJustify justifySelf) { + updateStyle<&Style::justifySelf, &Style::setJustifySelf>( + node, scopedEnum(justifySelf)); +} + +YGJustify YGNodeStyleGetJustifySelf(const YGNodeConstRef node) { + return unscopedEnum(resolveRef(node)->style().justifySelf()); +} + void YGNodeStyleSetAlignContent( const YGNodeRef node, const YGAlign alignContent) { @@ -171,7 +193,7 @@ float YGNodeStyleGetFlexShrink(const YGNodeConstRef nodeRef) { const auto node = resolveRef(nodeRef); return node->style().flexShrink().isUndefined() ? (node->getConfig()->useWebDefaults() ? Style::WebDefaultFlexShrink - : Style::DefaultFlexShrink) + : Style::DefaultFlexShrink) : node->style().flexShrink().unwrap(); } @@ -503,3 +525,85 @@ void YGNodeStyleSetMaxHeightStretch(const YGNodeRef node) { YGValue YGNodeStyleGetMaxHeight(const YGNodeConstRef node) { return (YGValue)resolveRef(node)->style().maxDimension(Dimension::Height); } + +// Grid Item Placement Properties + +void YGNodeStyleSetGridColumnStart(YGNodeRef node, int32_t gridColumnStart) { + updateStyle<&Style::gridColumnStart, &Style::setGridColumnStart>( + node, GridLine::fromInteger(gridColumnStart)); +} + +void YGNodeStyleSetGridColumnStartAuto(YGNodeRef node) { + updateStyle<&Style::gridColumnStart, &Style::setGridColumnStart>( + node, GridLine::auto_()); +} + +void YGNodeStyleSetGridColumnStartSpan(YGNodeRef node, int32_t span) { + updateStyle<&Style::gridColumnStart, &Style::setGridColumnStart>( + node, GridLine::span(span)); +} + +int32_t YGNodeStyleGetGridColumnStart(YGNodeConstRef node) { + const auto& gridLine = resolveRef(node)->style().gridColumnStart(); + return gridLine.isInteger() ? gridLine.integer : 0; +} + +void YGNodeStyleSetGridColumnEnd(YGNodeRef node, int32_t gridColumnEnd) { + updateStyle<&Style::gridColumnEnd, &Style::setGridColumnEnd>( + node, GridLine::fromInteger(gridColumnEnd)); +} + +void YGNodeStyleSetGridColumnEndAuto(YGNodeRef node) { + updateStyle<&Style::gridColumnEnd, &Style::setGridColumnEnd>( + node, GridLine::auto_()); +} + +void YGNodeStyleSetGridColumnEndSpan(YGNodeRef node, int32_t span) { + updateStyle<&Style::gridColumnEnd, &Style::setGridColumnEnd>( + node, GridLine::span(span)); +} + +int32_t YGNodeStyleGetGridColumnEnd(YGNodeConstRef node) { + const auto& gridLine = resolveRef(node)->style().gridColumnEnd(); + return gridLine.isInteger() ? gridLine.integer : 0; +} + +void YGNodeStyleSetGridRowStart(YGNodeRef node, int32_t gridRowStart) { + updateStyle<&Style::gridRowStart, &Style::setGridRowStart>( + node, GridLine::fromInteger(gridRowStart)); +} + +void YGNodeStyleSetGridRowStartAuto(YGNodeRef node) { + updateStyle<&Style::gridRowStart, &Style::setGridRowStart>( + node, GridLine::auto_()); +} + +void YGNodeStyleSetGridRowStartSpan(YGNodeRef node, int32_t span) { + updateStyle<&Style::gridRowStart, &Style::setGridRowStart>( + node, GridLine::span(span)); +} + +int32_t YGNodeStyleGetGridRowStart(YGNodeConstRef node) { + const auto& gridLine = resolveRef(node)->style().gridRowStart(); + return gridLine.isInteger() ? gridLine.integer : 0; +} + +void YGNodeStyleSetGridRowEnd(YGNodeRef node, int32_t gridRowEnd) { + updateStyle<&Style::gridRowEnd, &Style::setGridRowEnd>( + node, GridLine::fromInteger(gridRowEnd)); +} + +void YGNodeStyleSetGridRowEndAuto(YGNodeRef node) { + updateStyle<&Style::gridRowEnd, &Style::setGridRowEnd>( + node, GridLine::auto_()); +} + +void YGNodeStyleSetGridRowEndSpan(YGNodeRef node, int32_t span) { + updateStyle<&Style::gridRowEnd, &Style::setGridRowEnd>( + node, GridLine::span(span)); +} + +int32_t YGNodeStyleGetGridRowEnd(YGNodeConstRef node) { + const auto& gridLine = resolveRef(node)->style().gridRowEnd(); + return gridLine.isInteger() ? gridLine.integer : 0; +} diff --git a/yoga/YGNodeStyle.h b/yoga/YGNodeStyle.h index 21b8326d85..1cc12002e6 100644 --- a/yoga/YGNodeStyle.h +++ b/yoga/YGNodeStyle.h @@ -8,7 +8,6 @@ #pragma once #include - #include #include @@ -29,6 +28,16 @@ YG_EXPORT void YGNodeStyleSetJustifyContent( YGJustify justifyContent); YG_EXPORT YGJustify YGNodeStyleGetJustifyContent(YGNodeConstRef node); +YG_EXPORT void YGNodeStyleSetJustifyItems( + YGNodeRef node, + YGJustify justifyItems); +YG_EXPORT YGJustify YGNodeStyleGetJustifyItems(YGNodeConstRef node); + +YG_EXPORT void YGNodeStyleSetJustifySelf( + YGNodeRef node, + YGJustify justifySelf); +YG_EXPORT YGJustify YGNodeStyleGetJustifySelf(YGNodeConstRef node); + YG_EXPORT void YGNodeStyleSetAlignContent(YGNodeRef node, YGAlign alignContent); YG_EXPORT YGAlign YGNodeStyleGetAlignContent(YGNodeConstRef node); @@ -148,4 +157,25 @@ YG_EXPORT YGValue YGNodeStyleGetMaxHeight(YGNodeConstRef node); YG_EXPORT void YGNodeStyleSetAspectRatio(YGNodeRef node, float aspectRatio); YG_EXPORT float YGNodeStyleGetAspectRatio(YGNodeConstRef node); +// Grid Item Properties +YG_EXPORT void YGNodeStyleSetGridColumnStart(YGNodeRef node, int gridColumnStart); +YG_EXPORT void YGNodeStyleSetGridColumnStartAuto(YGNodeRef node); +YG_EXPORT void YGNodeStyleSetGridColumnStartSpan(YGNodeRef node, int span); +YG_EXPORT int YGNodeStyleGetGridColumnStart(YGNodeConstRef node); + +YG_EXPORT void YGNodeStyleSetGridColumnEnd(YGNodeRef node, int gridColumnEnd); +YG_EXPORT void YGNodeStyleSetGridColumnEndAuto(YGNodeRef node); +YG_EXPORT void YGNodeStyleSetGridColumnEndSpan(YGNodeRef node, int span); +YG_EXPORT int YGNodeStyleGetGridColumnEnd(YGNodeConstRef node); + +YG_EXPORT void YGNodeStyleSetGridRowStart(YGNodeRef node, int gridRowStart); +YG_EXPORT void YGNodeStyleSetGridRowStartAuto(YGNodeRef node); +YG_EXPORT void YGNodeStyleSetGridRowStartSpan(YGNodeRef node, int span); +YG_EXPORT int YGNodeStyleGetGridRowStart(YGNodeConstRef node); + +YG_EXPORT void YGNodeStyleSetGridRowEnd(YGNodeRef node, int gridRowEnd); +YG_EXPORT void YGNodeStyleSetGridRowEndAuto(YGNodeRef node); +YG_EXPORT void YGNodeStyleSetGridRowEndSpan(YGNodeRef node, int span); +YG_EXPORT int YGNodeStyleGetGridRowEnd(YGNodeConstRef node); + YG_EXTERN_C_END diff --git a/yoga/Yoga.h b/yoga/Yoga.h index 97f05ed3ea..80f37d837f 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -19,3 +19,4 @@ #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export +#include // IWYU pragma: export diff --git a/yoga/algorithm/AbsoluteLayout.cpp b/yoga/algorithm/AbsoluteLayout.cpp index b2d8d8dbef..5759acbb1e 100644 --- a/yoga/algorithm/AbsoluteLayout.cpp +++ b/yoga/algorithm/AbsoluteLayout.cpp @@ -23,7 +23,10 @@ static inline void setFlexStartLayoutPosition( axis, direction, containingBlockWidth) + parent->getLayout().border(flexStartEdge(axis)); - if (!child->hasErrata(Errata::AbsolutePositionWithoutInsetsExcludesPadding)) { + // https://www.w3.org/TR/css-grid-1/#abspos + // absolute positioned grid items are positioned relative to the padding edge of the grid container + if (!child->hasErrata(Errata::AbsolutePositionWithoutInsetsExcludesPadding) && + parent->style().display() != Display::Grid) { position += parent->getLayout().padding(flexStartEdge(axis)); } @@ -40,7 +43,10 @@ static inline void setFlexEndLayoutPosition( child->style().computeFlexEndMargin( axis, direction, containingBlockWidth); - if (!child->hasErrata(Errata::AbsolutePositionWithoutInsetsExcludesPadding)) { + // https://www.w3.org/TR/css-grid-1/#abspos + // absolute positioned grid items are positioned relative to the padding edge of the grid container + if (!child->hasErrata(Errata::AbsolutePositionWithoutInsetsExcludesPadding) && + parent->style().display() != Display::Grid) { flexEndPosition += parent->getLayout().padding(flexEndEdge(axis)); } @@ -60,7 +66,10 @@ static inline void setCenterLayoutPosition( parent->getLayout().border(flexStartEdge(axis)) - parent->getLayout().border(flexEndEdge(axis)); - if (!child->hasErrata(Errata::AbsolutePositionWithoutInsetsExcludesPadding)) { + // https://www.w3.org/TR/css-grid-1/#abspos + // absolute positioned grid items are positioned relative to the padding edge of the grid container + if (!child->hasErrata(Errata::AbsolutePositionWithoutInsetsExcludesPadding) && + parent->style().display() != Display::Grid) { parentContentBoxSize -= parent->getLayout().padding(flexStartEdge(axis)); parentContentBoxSize -= parent->getLayout().padding(flexEndEdge(axis)); } @@ -74,7 +83,10 @@ static inline void setCenterLayoutPosition( child->style().computeFlexStartMargin( axis, direction, containingBlockWidth); - if (!child->hasErrata(Errata::AbsolutePositionWithoutInsetsExcludesPadding)) { + // https://www.w3.org/TR/css-grid-1/#abspos + // absolute positioned grid items are positioned relative to the padding edge of the grid container + if (!child->hasErrata(Errata::AbsolutePositionWithoutInsetsExcludesPadding) && + parent->style().display() != Display::Grid) { position += parent->getLayout().padding(flexStartEdge(axis)); } @@ -87,13 +99,19 @@ static void justifyAbsoluteChild( const Direction direction, const FlexDirection mainAxis, const float containingBlockWidth) { - const Justify parentJustifyContent = parent->style().justifyContent(); - switch (parentJustifyContent) { + const Justify justify = parent->style().display() == Display::Grid + ? resolveChildJustification(parent, child) + : parent->style().justifyContent(); + switch (justify) { + case Justify::Start: + case Justify::Auto: + case Justify::Stretch: case Justify::FlexStart: case Justify::SpaceBetween: setFlexStartLayoutPosition( parent, child, direction, mainAxis, containingBlockWidth); break; + case Justify::End: case Justify::FlexEnd: setFlexEndLayoutPosition( parent, child, direction, mainAxis, containingBlockWidth); @@ -124,6 +142,7 @@ static void alignAbsoluteChild( } switch (itemAlign) { + case Align::Start: case Align::Auto: case Align::FlexStart: case Align::Baseline: @@ -134,6 +153,7 @@ static void alignAbsoluteChild( setFlexStartLayoutPosition( parent, child, direction, crossAxis, containingBlockWidth); break; + case Align::End: case Align::FlexEnd: setFlexEndLayoutPosition( parent, child, direction, crossAxis, containingBlockWidth); @@ -234,9 +254,15 @@ void layoutAbsoluteChild( LayoutData& layoutMarkerData, const uint32_t depth, const uint32_t generationCount) { - const FlexDirection mainAxis = - resolveDirection(node->style().flexDirection(), direction); - const FlexDirection crossAxis = resolveCrossDirection(mainAxis, direction); + // For grid containers, use inline (Row) and block (Column) axes for + // positioning, since grid alignment properties (justify-self, align-self) + // operate on inline/block axes, not main/cross axes based on flex-direction. + const FlexDirection mainAxis = node->style().display() == Display::Grid + ? resolveDirection(FlexDirection::Row, direction) + : resolveDirection(node->style().flexDirection(), direction); + const FlexDirection crossAxis = node->style().display() == Display::Grid + ? FlexDirection::Column + : resolveCrossDirection(mainAxis, direction); const bool isMainAxisRow = isRow(mainAxis); float childWidth = YGUndefined; diff --git a/yoga/algorithm/Align.h b/yoga/algorithm/Align.h index bb21fe5dca..5e008fc12f 100644 --- a/yoga/algorithm/Align.h +++ b/yoga/algorithm/Align.h @@ -20,12 +20,24 @@ inline Align resolveChildAlignment( const Align align = child->style().alignSelf() == Align::Auto ? node->style().alignItems() : child->style().alignSelf(); - if (align == Align::Baseline && isColumn(node->style().flexDirection())) { + + if (node->style().display() == Display::Flex + && align == Align::Baseline + && isColumn(node->style().flexDirection())) { return Align::FlexStart; } + return align; } +inline Justify resolveChildJustification( + const yoga::Node* node, + const yoga::Node* child) { + return child->style().justifySelf() == Justify::Auto + ? node->style().justifyItems() + : child->style().justifySelf(); +} + /** * Fallback alignment to use on overflow * https://www.w3.org/TR/css-align-3/#distribution-values diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index fcc0531354..0858696b28 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -30,12 +30,13 @@ #include #include #include +#include namespace facebook::yoga { std::atomic gCurrentGenerationCount(0); -static void constrainMaxSizeForMode( +void constrainMaxSizeForMode( const yoga::Node* node, Direction direction, FlexDirection axis, @@ -468,7 +469,7 @@ static bool measureNodeWithFixedSize( return false; } -static void zeroOutLayoutRecursively(yoga::Node* const node) { +void zeroOutLayoutRecursively(yoga::Node* const node) { node->getLayout() = {}; node->setLayoutDimension(0, Dimension::Width); node->setLayoutDimension(0, Dimension::Height); @@ -480,7 +481,7 @@ static void zeroOutLayoutRecursively(yoga::Node* const node) { } } -static void cleanupContentsNodesRecursively(yoga::Node* const node) { +void cleanupContentsNodesRecursively(yoga::Node* const node) { if (node->hasContentsChildren()) [[unlikely]] { node->cloneContentsChildrenIfNeeded(); for (auto child : node->getChildren()) { @@ -498,7 +499,7 @@ static void cleanupContentsNodesRecursively(yoga::Node* const node) { } } -static float calculateAvailableInnerDimension( +float calculateAvailableInnerDimension( const yoga::Node* const node, const Direction direction, const Dimension dimension, @@ -1046,6 +1047,14 @@ static void justifyMainAxis( if (flexLine.numberOfAutoMargins == 0) { switch (justifyContent) { + case Justify::Start: + case Justify::End: + case Justify::Auto: + // No-Op + break; + case Justify::Stretch: + // No-Op + break; case Justify::Center: leadingMainDim = flexLine.layout.remainingFreeSpace / 2; break; @@ -1367,6 +1376,24 @@ static void calculateLayoutImpl( // current node as they will not be traversed cleanupContentsNodesRecursively(node); + if (node->style().display() == Display::Grid) { + calculateGridLayoutInternal( + node, + availableWidth, + availableHeight, + ownerDirection, + widthSizingMode, + heightSizingMode, + ownerWidth, + ownerHeight, + performLayout, + reason, + layoutMarkerData, + depth, + generationCount); + return; + } + // STEP 1: CALCULATE VALUES FOR REMAINDER OF ALGORITHM const FlexDirection mainAxis = resolveDirection(node->style().flexDirection(), direction); @@ -1799,6 +1826,10 @@ static void calculateLayoutImpl( : fallbackAlignment(node->style().alignContent()); switch (alignContent) { + case Align::Start: + case Align::End: + // No-Op + break; case Align::FlexEnd: currentLead += remainingAlignContentDim; break; @@ -1886,6 +1917,10 @@ static void calculateLayoutImpl( } if (child->style().positionType() != PositionType::Absolute) { switch (resolveChildAlignment(node, child)) { + case Align::Start: + case Align::End: + // No-Op + break; case Align::FlexStart: { child->setLayoutPosition( currentLead + diff --git a/yoga/algorithm/CalculateLayout.h b/yoga/algorithm/CalculateLayout.h index 5e6884ec1a..86b3c61afe 100644 --- a/yoga/algorithm/CalculateLayout.h +++ b/yoga/algorithm/CalculateLayout.h @@ -35,4 +35,26 @@ bool calculateLayoutInternal( uint32_t depth, uint32_t generationCount); +void constrainMaxSizeForMode( + const yoga::Node* node, + Direction direction, + FlexDirection axis, + float ownerAxisSize, + float ownerWidth, + /*in_out*/ SizingMode* mode, + /*in_out*/ float* size); + +float calculateAvailableInnerDimension( + const yoga::Node* const node, + const Direction direction, + const Dimension dimension, + const float availableDim, + const float paddingAndBorder, + const float ownerDim, + const float ownerWidth); + +void zeroOutLayoutRecursively(yoga::Node* const node); + +void cleanupContentsNodesRecursively(yoga::Node* const node); + } // namespace facebook::yoga diff --git a/yoga/algorithm/grid/AutoPlacement.h b/yoga/algorithm/grid/AutoPlacement.h new file mode 100644 index 0000000000..f636a9bf4a --- /dev/null +++ b/yoga/algorithm/grid/AutoPlacement.h @@ -0,0 +1,530 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +namespace facebook::yoga { + +struct OccupancyGrid { + std::unordered_map>> rowIntervals; + + void markOccupied(int32_t rowStart, int32_t rowEnd, int32_t colStart, int32_t colEnd) { + for (int32_t row = rowStart; row < rowEnd; row++) { + rowIntervals[row].push_back({colStart, colEnd}); + } + } + + bool hasOverlap(int32_t rowStart, int32_t rowEnd, int32_t colStart, int32_t colEnd) const { + for (int32_t row = rowStart; row < rowEnd; row++) { + auto it = rowIntervals.find(row); + if (it == rowIntervals.end()) { + continue; + } + for (const auto& interval : it->second) { + if (interval.first < colEnd && interval.second > colStart) { + return true; + } + } + } + return false; + } +}; + +struct GridItemTrackPlacement { + int32_t start = 0; + int32_t end = 0; + int32_t span = 1; + // https://www.w3.org/TR/css-grid-1/#grid-placement-errors + static GridItemTrackPlacement resolveLinePlacement(const GridLine& startLine, const GridLine& endLine, int32_t explicitLineCount) { + GridItemTrackPlacement placement; + + auto resolveNegativeLineValue = [](int32_t lineValue, int32_t explicitLineCount) -> int32_t { + return lineValue < 0 ? explicitLineCount + lineValue + 1 : lineValue; + }; + + // If the placement for a grid item contains two lines + if (startLine.type == GridLineType::Integer && endLine.type == GridLineType::Integer) { + // if lines are negative, we count it from the last line. e.g. -1 is the last line + auto normalizedStartLine = resolveNegativeLineValue(startLine.integer, explicitLineCount); + auto normalizedEndLine = resolveNegativeLineValue(endLine.integer, explicitLineCount); + // and the start line is further end-ward than the end line, swap the two lines. + if (normalizedStartLine > normalizedEndLine) { + placement.start = normalizedEndLine; + placement.end = normalizedStartLine; + placement.span = placement.end - placement.start; + } + // If the start line is equal to the end line, remove the end line. + else if (normalizedStartLine == normalizedEndLine) { + placement.start = normalizedStartLine; + placement.end = normalizedStartLine + 1; + placement.span = 1; + } + else { + placement.start = normalizedStartLine; + placement.end = normalizedEndLine; + placement.span = placement.end - placement.start; + } + } + // If the placement contains two spans, remove the one contributed by the end grid-placement property. + else if (startLine.type == GridLineType::Span && endLine.type == GridLineType::Span) { + placement.start = 0; + placement.end = 0; + placement.span = startLine.integer; + } + + else if (startLine.type == GridLineType::Integer && endLine.type == GridLineType::Span) { + auto normalizedStartLine = resolveNegativeLineValue(startLine.integer, explicitLineCount); + placement.start = normalizedStartLine; + placement.span = endLine.integer; + placement.end = placement.start + placement.span; + } + + else if (startLine.type == GridLineType::Span && endLine.type == GridLineType::Integer) { + auto normalizedEndLine = resolveNegativeLineValue(endLine.integer, explicitLineCount); + placement.end = normalizedEndLine; + placement.span = startLine.integer; + placement.start = placement.end - placement.span; + } + + else if (startLine.type == GridLineType::Integer) { + auto normalizedStartLine = resolveNegativeLineValue(startLine.integer, explicitLineCount); + placement.start = normalizedStartLine; + placement.span = 1; + placement.end = placement.start + placement.span; + } + + else if (startLine.type == GridLineType::Span) { + placement.span = startLine.integer; + placement.start = 0; + placement.end = 0; + } + + else if (endLine.type == GridLineType::Integer) { + auto normalizedEndLine = resolveNegativeLineValue(endLine.integer, explicitLineCount); + placement.end = normalizedEndLine; + placement.span = 1; + placement.start = placement.end - placement.span; + } + + else if (endLine.type == GridLineType::Span) { + placement.span = endLine.integer; + placement.start = 0; + placement.end = 0; + } + + else { + placement.start = 0; + placement.end = 0; + placement.span = 1; + } + + // we want 0 based indexing, so we subtract 1. Negative values will imply auto implicit grid lines + placement.start = placement.start - 1; + placement.end = placement.end - 1; + + return placement; + } +}; + +struct AutoPlacement { + struct AutoPlacementItem { + int32_t columnStart; + int32_t columnEnd; + int32_t rowStart; + int32_t rowEnd; + + yoga::Node* node; + + bool overlaps(const AutoPlacementItem& other) const { + return columnStart < other.columnEnd && columnEnd > other.columnStart && rowStart < other.rowEnd && rowEnd > other.rowStart; + } + }; + + + std::vector gridItems; + int32_t minColumnStart; + int32_t minRowStart; + int32_t maxColumnEnd; + int32_t maxRowEnd; + + static AutoPlacement performAutoPlacement(yoga::Node* node) { + std::vector gridItems; + gridItems.reserve(node->getChildCount()); + std::unordered_set placedItems; + placedItems.reserve(node->getChildCount()); + int32_t minColumnStart = 0; + int32_t minRowStart = 0; + int32_t maxColumnEnd = static_cast(node->style().gridTemplateColumns().size()); + int32_t maxRowEnd = static_cast(node->style().gridTemplateRows().size()); + OccupancyGrid occupancy; + + // function to push back a grid item placement and record the min/max column/row start/end + auto recordGridArea = [&](AutoPlacementItem& gridItemArea) { + yoga::assertFatal( + gridItemArea.columnEnd > gridItemArea.columnStart, + "Grid item column end must be greater than column start"); + yoga::assertFatal( + gridItemArea.rowEnd > gridItemArea.rowStart, + "Grid item row end must be greater than row start"); + gridItems.push_back(gridItemArea); + placedItems.insert(gridItemArea.node); + occupancy.markOccupied(gridItemArea.rowStart, gridItemArea.rowEnd, gridItemArea.columnStart, gridItemArea.columnEnd); + minColumnStart = std::min(minColumnStart, gridItemArea.columnStart); + minRowStart = std::min(minRowStart, gridItemArea.rowStart); + maxColumnEnd = std::max(maxColumnEnd, gridItemArea.columnEnd); + maxRowEnd = std::max(maxRowEnd, gridItemArea.rowEnd); + }; + + int32_t explicitColumnLineCount = static_cast(node->style().gridTemplateColumns().size() + 1); + int32_t explicitRowLineCount = static_cast(node->style().gridTemplateRows().size() + 1); + + // Step 1: Position anything that's not auto-positioned. + // In spec level 1, span is always definite. Default is 1. + // So for grid position to be definite, we need either start or end to be definite. + for (auto child : node->getLayoutChildren()) { + if (child->style().positionType() == PositionType::Absolute || child->style().display() == Display::None) { + continue; + } + + auto gridItemColumnStart = child->style().gridColumnStart(); + auto gridItemColumnEnd = child->style().gridColumnEnd(); + auto gridItemRowStart = child->style().gridRowStart(); + auto gridItemRowEnd = child->style().gridRowEnd(); + auto hasDefiniteColumn = gridItemColumnStart.type == GridLineType::Integer || + gridItemColumnEnd.type == GridLineType::Integer; + auto hasDefiniteRow = gridItemRowStart.type == GridLineType::Integer || + gridItemRowEnd.type == GridLineType::Integer; + + auto hasDefinitePosition = hasDefiniteColumn && hasDefiniteRow; + + if (hasDefinitePosition) { + auto columnPlacement = GridItemTrackPlacement::resolveLinePlacement(gridItemColumnStart, gridItemColumnEnd, explicitColumnLineCount); + auto rowPlacement = GridItemTrackPlacement::resolveLinePlacement(gridItemRowStart, gridItemRowEnd, explicitRowLineCount); + + auto columnStart = columnPlacement.start; + auto columnEnd = columnPlacement.end; + + auto rowStart = rowPlacement.start; + auto rowEnd = rowPlacement.end; + + auto gridItemArea = AutoPlacementItem{ + columnStart, + columnEnd, + rowStart, + rowEnd, + child + }; + recordGridArea(gridItemArea); + } + } + + // Step 2: Process the items locked to a given row. + // Definite row positions only, exclude items with definite column positions. + std::unordered_map rowStartToColumnStartCache; + for (auto child : node->getLayoutChildren()) { + if (child->style().positionType() == PositionType::Absolute || child->style().display() == Display::None) { + continue; + } + + auto gridItemColumnStart = child->style().gridColumnStart(); + auto gridItemColumnEnd = child->style().gridColumnEnd(); + auto gridItemRowStart = child->style().gridRowStart(); + auto gridItemRowEnd = child->style().gridRowEnd(); + auto hasDefiniteRow = gridItemRowStart.type == GridLineType::Integer || + gridItemRowEnd.type == GridLineType::Integer; + auto hasDefiniteColumn = gridItemColumnStart.type == GridLineType::Integer || + gridItemColumnEnd.type == GridLineType::Integer; + + if (hasDefiniteRow && !hasDefiniteColumn) { + auto rowPlacement = GridItemTrackPlacement::resolveLinePlacement(gridItemRowStart, gridItemRowEnd, explicitRowLineCount); + + auto rowStart = rowPlacement.start; + auto rowEnd = rowPlacement.end; + + auto columnStart = rowStartToColumnStartCache.contains(rowStart) ? + rowStartToColumnStartCache[rowStart] : minColumnStart; + + auto columnPlacement = GridItemTrackPlacement::resolveLinePlacement(gridItemColumnStart, gridItemColumnEnd, explicitColumnLineCount); + auto columnSpan = columnPlacement.span; + auto columnEnd = columnStart + columnSpan; + + bool placed = false; + while (!placed) { + auto gridItemArea = AutoPlacementItem{ + columnStart, + columnEnd, + rowStart, + rowEnd, + child + }; + if (occupancy.hasOverlap(rowStart, rowEnd, columnStart, columnEnd)) { + columnStart++; + columnEnd = columnStart + columnSpan; + } else { + recordGridArea(gridItemArea); + rowStartToColumnStartCache[rowStart] = columnEnd; + placed = true; + } + } + } + } + + // Step 3: Determine the columns in the implicit grid. + // TODO: we dont need this loop. we can do it in above steps. But keeping it for now, to match the spec. + auto largestColumnSpan = 1; + for (auto child : node->getLayoutChildren()) { + if (child->style().positionType() == PositionType::Absolute || child->style().display() == Display::None) { + continue; + } + + auto gridItemColumnStart = child->style().gridColumnStart(); + auto gridItemColumnEnd = child->style().gridColumnEnd(); + + auto hasDefiniteColumn = gridItemColumnStart.type == GridLineType::Integer || + gridItemColumnEnd.type == GridLineType::Integer; + + if (hasDefiniteColumn) { + auto columnPlacement = GridItemTrackPlacement::resolveLinePlacement(gridItemColumnStart, gridItemColumnEnd, explicitColumnLineCount); + + auto columnStart = columnPlacement.start; + auto columnEnd = columnPlacement.end; + + minColumnStart = std::min(minColumnStart, columnStart); + maxColumnEnd = std::max(maxColumnEnd, columnEnd); + } else { + auto columnPlacement = GridItemTrackPlacement::resolveLinePlacement(gridItemColumnStart, gridItemColumnEnd, explicitColumnLineCount); + largestColumnSpan = std::max(largestColumnSpan, columnPlacement.span); + } + } + + // If largest span is larger than current grid width, extend the end + auto currentGridWidth = maxColumnEnd - minColumnStart; + if (largestColumnSpan > currentGridWidth) { + maxColumnEnd = minColumnStart + largestColumnSpan; + } + + // Step 4: Position the remaining grid items. + int32_t autoPlacementCursor[2] = { + minColumnStart, + minRowStart + }; + for (auto child : node->getLayoutChildren()) { + if (child->style().positionType() == PositionType::Absolute || child->style().display() == Display::None) { + continue; + } + + if (!placedItems.contains(child)) { + auto gridItemColumnStart = child->style().gridColumnStart(); + auto gridItemColumnEnd = child->style().gridColumnEnd(); + auto hasDefiniteColumn = gridItemColumnStart.type == GridLineType::Integer || + gridItemColumnEnd.type == GridLineType::Integer; + + auto gridItemRowStart = child->style().gridRowStart(); + auto gridItemRowEnd = child->style().gridRowEnd(); + auto hasDefiniteRow = gridItemRowStart.type == GridLineType::Integer || + gridItemRowEnd.type == GridLineType::Integer; + + auto columnPlacement = GridItemTrackPlacement::resolveLinePlacement(gridItemColumnStart, gridItemColumnEnd, explicitColumnLineCount); + auto rowPlacement = GridItemTrackPlacement::resolveLinePlacement(gridItemRowStart, gridItemRowEnd, explicitRowLineCount); + + // If the item has a definite column position: + if (hasDefiniteColumn) { + auto columnStart = columnPlacement.start; + auto columnEnd = columnPlacement.end; + + // Set cursor column position to item's column-start line + auto previousColumnPosition = autoPlacementCursor[0]; + autoPlacementCursor[0] = columnStart; + + // If this is less than previous column position, increment row + if (autoPlacementCursor[0] < previousColumnPosition) { + autoPlacementCursor[1]++; + } + + // Find a row position where the item doesn't overlap occupied cells + bool foundPosition = false; + auto rowSpan = rowPlacement.span; + while (!foundPosition) { + auto proposedRowStart = autoPlacementCursor[1]; + auto proposedRowEnd = proposedRowStart + rowSpan; + + // Check for overlaps with already placed items + AutoPlacementItem proposedPlacement { + columnStart, + columnEnd, + proposedRowStart, + proposedRowEnd, + child + }; + + if (occupancy.hasOverlap(proposedRowStart, proposedRowEnd, columnStart, columnEnd)) { + autoPlacementCursor[1]++; + } else { + recordGridArea(proposedPlacement); + foundPosition = true; + } + } + } + + // If the item has an automatic grid position in both axes: + else if (!hasDefiniteRow && !hasDefiniteColumn) { + auto itemColumnSpan = columnPlacement.span; + auto itemRowSpan = rowPlacement.span; + + bool foundPosition = false; + while (!foundPosition) { + // Try to find a position starting from current cursor position + while (autoPlacementCursor[0] + itemColumnSpan <= maxColumnEnd) { + auto columnStart = autoPlacementCursor[0]; + auto columnEnd = columnStart + itemColumnSpan; + auto rowStart = autoPlacementCursor[1]; + auto rowEnd = rowStart + itemRowSpan; + + AutoPlacementItem proposedPlacement { + columnStart, + columnEnd, + rowStart, + rowEnd, + child + }; + + if (occupancy.hasOverlap(rowStart, rowEnd, columnStart, columnEnd)) { + autoPlacementCursor[0]++; + } else { + recordGridArea(proposedPlacement); + foundPosition = true; + break; + } + } + + if (!foundPosition) { + // Cursor column position + span would overflow, move to next row + autoPlacementCursor[1]++; + autoPlacementCursor[0] = minColumnStart; + } + } + } + } + } + + return AutoPlacement { + std::move(gridItems), + minColumnStart, + minRowStart, + maxColumnEnd, + maxRowEnd + }; + } +}; + +struct GridItem { + size_t columnStart; + size_t columnEnd; + size_t rowStart; + size_t rowEnd; + yoga::Node* node; + // additional space added to align baselines + // https://www.w3.org/TR/css-grid-1/#algo-baseline-shims + float baselineShim = 0.0f; + // Flags used for optimisations in TrackSizing + bool crossesIntrinsicRow = false; + bool crossesIntrinsicColumn = false; + bool crossesFlexibleRow = false; + bool crossesFlexibleColumn = false; + + GridItem( + size_t columnStart, + size_t columnEnd, + size_t rowStart, + size_t rowEnd, + yoga::Node* node, + float baselineShim = 0.0f) + : columnStart(columnStart), + columnEnd(columnEnd), + rowStart(rowStart), + rowEnd(rowEnd), + node(node), + baselineShim(baselineShim) {} + + bool crossesIntrinsicTrack(Dimension dimension) const { + return dimension == Dimension::Width ? crossesIntrinsicColumn : crossesIntrinsicRow; + } + bool crossesFlexibleTrack(Dimension dimension) const { + return dimension == Dimension::Width ? crossesFlexibleColumn : crossesFlexibleRow; + } +}; + +// Baseline sharing groups - items grouped by their starting row for resolve intrinsic size step in TrackSizing +// https://www.w3.org/TR/css-grid-1/#algo-baseline-shims +using BaselineItemGroups = std::map>; + +struct ResolvedAutoPlacement { + std::vector gridItems; + BaselineItemGroups baselineItemGroups; + int32_t minColumnStart; + int32_t minRowStart; + int32_t maxColumnEnd; + int32_t maxRowEnd; + + // Offset column and row so they starts at 0 index + // also casts start and end values from int32_t to size_t + static ResolvedAutoPlacement resolveGridItemPlacements(Node* node) { + auto autoPlacement = AutoPlacement::performAutoPlacement(node); + + auto minColumnStart = autoPlacement.minColumnStart; + auto minRowStart = autoPlacement.minRowStart; + auto maxColumnEnd = autoPlacement.maxColumnEnd; + auto maxRowEnd = autoPlacement.maxRowEnd; + + std::vector resolvedAreas; + resolvedAreas.reserve(autoPlacement.gridItems.size()); + + BaselineItemGroups baselineGroups; + auto alignItems = node->style().alignItems(); + + for (auto& placement : autoPlacement.gridItems) { + resolvedAreas.emplace_back( + static_cast(placement.columnStart - minColumnStart), + static_cast(placement.columnEnd - minColumnStart), + static_cast(placement.rowStart - minRowStart), + static_cast(placement.rowEnd - minRowStart), + placement.node); + + auto& item = resolvedAreas.back(); + auto alignSelf = item.node->style().alignSelf(); + if (alignSelf == Align::Auto) { + alignSelf = alignItems; + } + bool spansOneRow = (item.rowEnd - item.rowStart) == 1; + if (alignSelf == Align::Baseline && spansOneRow) { + baselineGroups[item.rowStart].push_back(&item); + } + + // TODO: find a better place to call this + placement.node->processDimensions(); + } + + return ResolvedAutoPlacement{ + std::move(resolvedAreas), + std::move(baselineGroups), + minColumnStart, + minRowStart, + maxColumnEnd, + maxRowEnd + }; + } +}; + +} // namespace facebook::yoga diff --git a/yoga/algorithm/grid/GridLayout.cpp b/yoga/algorithm/grid/GridLayout.cpp new file mode 100644 index 0000000000..cbed925cb2 --- /dev/null +++ b/yoga/algorithm/grid/GridLayout.cpp @@ -0,0 +1,444 @@ +/* + * 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. +*/ + +#include +#include +#include +#include +#include + +namespace facebook::yoga { + +void calculateGridLayoutInternal(Node* node, + float availableWidth, + float availableHeight, + Direction ownerDirection, + SizingMode widthSizingMode, + SizingMode heightSizingMode, + float ownerWidth, + float ownerHeight, + bool performLayout, + LayoutPassReason reason, + LayoutData& layoutMarkerData, + uint32_t depth, + uint32_t generationCount) { + (void)reason; // Unused parameter + + const auto& nodeStyle = node->style(); + const Direction direction = node->resolveDirection(ownerDirection); + const float marginInline = nodeStyle.computeMarginForAxis(FlexDirection::Row, ownerWidth); + const float marginBlock = nodeStyle.computeMarginForAxis(FlexDirection::Column, ownerWidth); + const float paddingAndBorderInline = paddingAndBorderForAxis(node, FlexDirection::Row, direction, ownerWidth); + const float paddingAndBorderBlock = paddingAndBorderForAxis(node, FlexDirection::Column, direction, ownerWidth); + const float availableInnerWidth = calculateAvailableInnerDimension( + node, + direction, + Dimension::Width, + availableWidth - marginInline, + paddingAndBorderInline, + ownerWidth, + ownerWidth); + const float availableInnerHeight = calculateAvailableInnerDimension( + node, + direction, + Dimension::Height, + availableHeight - marginBlock, + paddingAndBorderBlock, + ownerHeight, + ownerWidth); + auto widthIsDefinite = (widthSizingMode == SizingMode::StretchFit && + yoga::isDefined(availableWidth)); + auto heightIsDefinite = (heightSizingMode == SizingMode::StretchFit && + yoga::isDefined(availableHeight)); + + // 11. Grid Layout Algorithm + // Step 1: Run the Grid Item Placement Algorithm to resolve the placement of all grid items in the grid. + auto autoPlacement = ResolvedAutoPlacement::resolveGridItemPlacements(node); + // Create the grid tracks (auto and explicit = implicit grid) + auto gridTracks = createGridTracks(node, autoPlacement); + // At this point, we have grid items final positions and implicit grid tracks + + // Step 2: Find the size of the grid container, per § 5.2 Sizing Grid Containers. + // If grid container size is not definite, we have to run the track sizing algorithm to find the size of the grid container. + // Note: During this phase, cyclic s in track sizes are treated as auto. + float containerInnerWidth = widthIsDefinite ? availableInnerWidth : YGUndefined; + float containerInnerHeight = heightIsDefinite ? availableInnerHeight : YGUndefined; + auto& rowTracks = gridTracks.rowTracks; + auto& columnTracks = gridTracks.columnTracks; + auto& gridItems = autoPlacement.gridItems; + auto& baselineItemGroups = autoPlacement.baselineItemGroups; + bool needsSecondTrackSizingPass = true; + + if (!widthIsDefinite || !heightIsDefinite) { + auto trackSizing = TrackSizing( + node, + columnTracks, + rowTracks, + containerInnerWidth, + containerInnerHeight, + gridItems, + widthSizingMode, + heightSizingMode, + direction, + ownerWidth, + ownerHeight, + layoutMarkerData, + depth, + generationCount, + baselineItemGroups); + + trackSizing.runGridSizingAlgorithm(); + + bool containerSizeChanged = false; + + if (!widthIsDefinite) { + auto totalTrackWidth = trackSizing.getTotalBaseSize(Dimension::Width); + containerInnerWidth = boundAxis( + node, + FlexDirection::Row, + direction, + totalTrackWidth, + ownerWidth, + ownerWidth); + if (containerInnerWidth != totalTrackWidth) { + containerSizeChanged = true; + } + } + + if (!heightIsDefinite) { + auto totalTrackHeight = trackSizing.getTotalBaseSize(Dimension::Height); + containerInnerHeight = boundAxis( + node, + FlexDirection::Column, + direction, + totalTrackHeight, + ownerHeight, + ownerWidth); + if (containerInnerHeight != totalTrackHeight) { + containerSizeChanged = true; + } + } + + // We need to run track sizing again if: + // 1. The container size changed due to min/max bounds or + // 2. There are percentage tracks in indefinite dimensions that need resolution + bool hasPercentageTracksNeedingResolution = + (!widthIsDefinite && trackSizing.hasPercentageTracks(Dimension::Width)) || + (!heightIsDefinite && trackSizing.hasPercentageTracks(Dimension::Height)); + needsSecondTrackSizingPass = containerSizeChanged || hasPercentageTracksNeedingResolution; + } + + node->setLayoutMeasuredDimension( + boundAxis( + node, + FlexDirection::Row, + direction, + containerInnerWidth + paddingAndBorderInline, + ownerWidth, + ownerWidth), + Dimension::Width); + + node->setLayoutMeasuredDimension( + boundAxis( + node, + FlexDirection::Column, + direction, + containerInnerHeight + paddingAndBorderBlock, + ownerHeight, + ownerWidth), + Dimension::Height); + + // If we are not performing layout, we can return early after sizing the grid container. + if (!performLayout) { + return; + } + + // Inititialize track sizing with the final container size + auto trackSizing = TrackSizing( + node, + columnTracks, + rowTracks, + containerInnerWidth, + containerInnerHeight, + gridItems, + widthSizingMode, + heightSizingMode, + direction, + ownerWidth, + ownerHeight, + layoutMarkerData, + depth, + generationCount, + baselineItemGroups); + + // Step 3: Given the resulting grid container size, run the Grid Sizing Algorithm to size the grid. + // Run track sizing with the new container dimensions + // Note: During this phase, s in track sizes are resolved against the grid container size. + + // We only need to run track sizing again if: + // 1. Both dimensions were definite or + // 2. The container size changed due to min/max constraints in Step 2, or + // 3. There are percentage tracks in indefinite dimensions that need resolution + if (needsSecondTrackSizingPass) { + trackSizing.runGridSizingAlgorithm(); + } + + // Step 4: Lay out the grid items into their respective containing blocks. Each grid area’s width and height are considered definite for this purpose. + auto gridWidth = trackSizing.getTotalBaseSize(Dimension::Width); + auto gridHeight = trackSizing.getTotalBaseSize(Dimension::Height); + + float leadingPaddingAndBorderInline = nodeStyle.computeInlineStartPadding(FlexDirection::Row, direction, ownerWidth) + + nodeStyle.computeInlineStartBorder(FlexDirection::Row, direction); + float leadingPaddingAndBorderBlock = nodeStyle.computeInlineStartPadding(FlexDirection::Column, direction, ownerWidth) + + nodeStyle.computeInlineStartBorder(FlexDirection::Column, direction); + + // Align content/Justify content + float freeSpaceInlineAxis = containerInnerWidth - gridWidth; + auto inlineDistribution = trackSizing.calculateContentDistribution(Dimension::Width, freeSpaceInlineAxis); + float freeSpaceBlockAxis = containerInnerHeight - gridHeight; + auto blockDistribution = trackSizing.calculateContentDistribution(Dimension::Height, freeSpaceBlockAxis); + + if (freeSpaceInlineAxis < 0.0f || freeSpaceBlockAxis < 0.0f) { + node->setLayoutHadOverflow(true); + } + + auto gridInlineStartOffset = inlineDistribution.startOffset; + auto gridBlockStartOffset = blockDistribution.startOffset; + auto finalEffectiveColumnGap = inlineDistribution.effectiveGap; + auto finalEffectiveRowGap = blockDistribution.effectiveGap; + + std::vector columnGridLineOffsets; + columnGridLineOffsets.reserve(columnTracks.size() + 1); + columnGridLineOffsets.push_back(0.0f); + for (size_t i = 0; i < columnTracks.size(); i++) { + float offset = columnGridLineOffsets[i] + columnTracks[i].baseSize; + if (i < columnTracks.size() - 1) { + offset += finalEffectiveColumnGap; + } + columnGridLineOffsets.push_back(offset); + } + + std::vector rowGridLineOffsets; + rowGridLineOffsets.reserve(rowTracks.size() + 1); + rowGridLineOffsets.push_back(0.0f); + for (size_t i = 0; i < rowTracks.size(); i++) { + float offset = rowGridLineOffsets[i] + rowTracks[i].baseSize; + if (i < rowTracks.size() - 1) { + offset += finalEffectiveRowGap; + } + rowGridLineOffsets.push_back(offset); + } + + for (auto& item : gridItems) { + // grid line offsets include the gap after each track (except the last). + // so we subtract the trailing gap for items that do not end at the last track. + float containingBlockWidth = columnGridLineOffsets[item.columnEnd] - columnGridLineOffsets[item.columnStart]; + if (item.columnEnd < columnTracks.size()) { + containingBlockWidth -= finalEffectiveColumnGap; + } + float containingBlockHeight = rowGridLineOffsets[item.rowEnd] - rowGridLineOffsets[item.rowStart]; + if (item.rowEnd < rowTracks.size()) { + containingBlockHeight -= finalEffectiveRowGap; + } + float gridItemInlineStart = columnGridLineOffsets[item.columnStart]; + float gridItemBlockStart = rowGridLineOffsets[item.rowStart]; + const auto& itemStyle = item.node->style(); + + const auto marginInlineStart = itemStyle.computeInlineStartMargin(FlexDirection::Row, direction, containingBlockWidth); + const auto marginInlineEnd = itemStyle.computeInlineEndMargin(FlexDirection::Row, direction, containingBlockWidth); + const auto marginBlockStart = itemStyle.computeInlineStartMargin(FlexDirection::Column, direction, containingBlockWidth); + const auto marginBlockEnd = itemStyle.computeInlineEndMargin(FlexDirection::Column, direction, containingBlockWidth); + + auto itemConstraints = trackSizing.calculateItemConstraints(item, containingBlockWidth, containingBlockHeight); + + calculateLayoutInternal( + item.node, + itemConstraints.width, + itemConstraints.height, + direction, + itemConstraints.widthSizingMode, + itemConstraints.heightSizingMode, + containingBlockWidth, + containingBlockHeight, + true, + LayoutPassReason::kGridLayout, + layoutMarkerData, + depth, + generationCount); + + auto justifySelf = resolveChildJustification(node, item.node); + auto alignSelf = resolveChildAlignment(node, item.node); + + // since we know the item width and grid width, we can do the alignment here. + // alignment of grid items happen in the grid area + // measured dimension includes padding and border + float actualItemWidth = item.node->getLayout().measuredDimension(Dimension::Width); + auto freeSpaceInlineAxisItem = containingBlockWidth - actualItemWidth - marginInlineStart - marginInlineEnd; + float startAutoMarginOffset = 0.0f; + // https://www.w3.org/TR/css-grid-1/#auto-margins + // auto margins in either axis absorb positive free space prior to alignment via the box alignment properties, thereby disabling the effects of any self-alignment properties in that axis. + if (freeSpaceInlineAxisItem > 0.0f) { + if (itemStyle.inlineStartMarginIsAuto(FlexDirection::Row, direction) + && itemStyle.inlineEndMarginIsAuto(FlexDirection::Row, direction)) { + startAutoMarginOffset = freeSpaceInlineAxisItem / 2; + freeSpaceInlineAxisItem = 0.0f; + } else if (itemStyle.inlineStartMarginIsAuto(FlexDirection::Row, direction)) { + startAutoMarginOffset = freeSpaceInlineAxisItem; + freeSpaceInlineAxisItem = 0.0f; + } else if (itemStyle.inlineEndMarginIsAuto(FlexDirection::Row, direction)) { + startAutoMarginOffset = 0.0f; + freeSpaceInlineAxisItem = 0.0f; + } + } + + float justifySelfOffset = 0.0f; + if (justifySelf == Justify::End) { + justifySelfOffset = freeSpaceInlineAxisItem; + } else if (justifySelf == Justify::Center) { + justifySelfOffset = freeSpaceInlineAxisItem / 2; + } + + float finalLeft = leadingPaddingAndBorderInline + gridItemInlineStart + marginInlineStart + startAutoMarginOffset + justifySelfOffset + gridInlineStartOffset; + + if (direction == Direction::RTL) { + finalLeft = getPositionOfOppositeEdge(finalLeft, FlexDirection::Row, node, item.node); + } + + // Add relative position offset for relatively positioned items. + // For RTL, the relative position is in logical coordinates so we subtract it from the physical left. + float relativePositionInline = item.node->relativePosition(FlexDirection::Row, direction, containingBlockWidth); + if (direction == Direction::RTL) { + item.node->setLayoutPosition(finalLeft - relativePositionInline, PhysicalEdge::Left); + } else { + item.node->setLayoutPosition(finalLeft + relativePositionInline, PhysicalEdge::Left); + } + + float actualItemHeight = item.node->getLayout().measuredDimension(Dimension::Height); + auto freeSpaceBlockAxisItem = containingBlockHeight - actualItemHeight - marginBlockStart - marginBlockEnd; + float topAutoMarginOffset = 0.0f; + if (freeSpaceBlockAxisItem > 0.0f) { + if (itemStyle.inlineStartMarginIsAuto(FlexDirection::Column, direction) + && itemStyle.inlineEndMarginIsAuto(FlexDirection::Column, direction)) { + topAutoMarginOffset = freeSpaceBlockAxisItem / 2; + freeSpaceBlockAxisItem = 0.0f; + } else if (itemStyle.inlineStartMarginIsAuto(FlexDirection::Column, direction)) { + topAutoMarginOffset = freeSpaceBlockAxisItem; + freeSpaceBlockAxisItem = 0.0f; + } else if (itemStyle.inlineEndMarginIsAuto(FlexDirection::Column, direction)) { + freeSpaceBlockAxisItem = 0.0f; + } + } + + float alignSelfOffset = 0.0f; + if (alignSelf == Align::End) { + alignSelfOffset = freeSpaceBlockAxisItem; + } else if (alignSelf == Align::Center) { + alignSelfOffset = freeSpaceBlockAxisItem / 2; + } else if (alignSelf == Align::Baseline) { + alignSelfOffset = item.baselineShim; + } + + float finalTop = gridItemBlockStart + marginBlockStart + topAutoMarginOffset + alignSelfOffset + gridBlockStartOffset + leadingPaddingAndBorderBlock; + + // Add relative position offset for relatively positioned items + float relativePositionBlock = item.node->relativePosition(FlexDirection::Column, direction, containingBlockHeight); + item.node->setLayoutPosition(finalTop + relativePositionBlock, PhysicalEdge::Top); + } + + // Perform layout of absolute children + // https://www.w3.org/TR/css-grid-1/#abspos + // TODO: support grid-[row|column]-[start|end] as containing blocks + if (nodeStyle.positionType() != PositionType::Static || + node->alwaysFormsContainingBlock() || depth == 1) { + for (auto child : node->getLayoutChildren()) { + if (child->style().display() == Display::None) { + zeroOutLayoutRecursively(child); + child->setHasNewLayout(true); + child->setDirty(false); + continue; + } + + if (child->style().positionType() == PositionType::Absolute) { + child->processDimensions(); + } + } + + layoutAbsoluteDescendants( + node, + node, + widthSizingMode, + direction, + layoutMarkerData, + depth, + generationCount, + 0.0f, + 0.0f, + availableInnerWidth, + availableInnerHeight); + } +} + +GridTracks createGridTracks(yoga::Node* node, const ResolvedAutoPlacement& autoPlacement) { + auto gridExplicitColumns = node->style().gridTemplateColumns(); + auto gridExplicitRows = node->style().gridTemplateRows(); + + std::vector columnTracks; + std::vector rowTracks; + columnTracks.reserve(autoPlacement.maxColumnEnd - autoPlacement.minColumnStart); + rowTracks.reserve(autoPlacement.maxRowEnd - autoPlacement.minRowStart); + + // https://www.w3.org/TR/css-grid-1/#auto-tracks + auto autoRowTracks = node->style().gridAutoRows().empty() ? + GridTrackList{GridTrackSize{StyleSizeLength::ofAuto(), StyleSizeLength::ofAuto()}} : + node->style().gridAutoRows(); + auto autoColumnTracks = node->style().gridAutoColumns().empty() ? + GridTrackList{GridTrackSize{StyleSizeLength::ofAuto(), StyleSizeLength::ofAuto()}} : + node->style().gridAutoColumns(); + + // The last implicit grid track before the explicit grid receives the last specified size, and so on backwards. + // i.e. The pattern repeats backwards + auto negativeImplicitGridColumnTrackCount = -autoPlacement.minColumnStart; + auto autoColumnTracksSize = autoColumnTracks.size(); + for (auto i = 0; i < negativeImplicitGridColumnTrackCount; i++) { + auto currentColumnTrackIndex = (negativeImplicitGridColumnTrackCount - i - 1) % autoColumnTracksSize; + auto autoColumnTrack = autoColumnTracks[autoColumnTracksSize - currentColumnTrackIndex - 1]; + columnTracks.push_back(autoColumnTrack); + } + + for (size_t i = 0; i < gridExplicitColumns.size(); i++) { + columnTracks.push_back(gridExplicitColumns[i]); + } + + // The first track after the last explicitly-sized track receives the first specified size + // i.e. the pattern repeats forwards + for (size_t i = 0; i < static_cast(autoPlacement.maxColumnEnd) - gridExplicitColumns.size(); i++) { + auto autoColumnTrack = autoColumnTracks[i % autoColumnTracksSize]; + columnTracks.push_back(autoColumnTrack); + } + + auto negativeImplicitGridRowTrackCount = -autoPlacement.minRowStart; + auto autoRowTracksSize = autoRowTracks.size(); + for (auto i = 0; i < negativeImplicitGridRowTrackCount; i++) { + auto currentRowTrackIndex = (negativeImplicitGridRowTrackCount - i - 1) % autoRowTracksSize; + auto autoRowTrack = autoRowTracks[autoRowTracksSize - currentRowTrackIndex - 1]; + rowTracks.push_back(autoRowTrack); + } + for (size_t i = 0; i < gridExplicitRows.size(); i++) { + rowTracks.push_back(gridExplicitRows[i]); + } + for (size_t i = 0; i < static_cast(autoPlacement.maxRowEnd) - gridExplicitRows.size(); i++) { + auto autoRowTrack = autoRowTracks[i % autoRowTracksSize]; + rowTracks.push_back(autoRowTrack); + } + + return { + std::move(columnTracks), + std::move(rowTracks) + }; +} + +} // namespace facebook::yoga diff --git a/yoga/algorithm/grid/GridLayout.h b/yoga/algorithm/grid/GridLayout.h new file mode 100644 index 0000000000..9e65dc6f83 --- /dev/null +++ b/yoga/algorithm/grid/GridLayout.h @@ -0,0 +1,43 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace facebook::yoga { + +void calculateGridLayoutInternal( + yoga::Node* node, + float availableWidth, + float availableHeight, + Direction ownerDirection, + SizingMode widthSizingMode, + SizingMode heightSizingMode, + float ownerWidth, + float ownerHeight, + bool performLayout, + LayoutPassReason reason, + LayoutData& layoutMarkerData, + uint32_t depth, + uint32_t generationCount); + + +struct GridTracks { + std::vector columnTracks; + std::vector rowTracks; +}; +// Creates implicit grid tracks based on the auto placement result +GridTracks createGridTracks( + yoga::Node* node, + const ResolvedAutoPlacement& autoPlacement); + +} // namespace facebook::yoga diff --git a/yoga/algorithm/grid/TrackSizing.h b/yoga/algorithm/grid/TrackSizing.h new file mode 100644 index 0000000000..8a5bbca512 --- /dev/null +++ b/yoga/algorithm/grid/TrackSizing.h @@ -0,0 +1,1766 @@ +/* + * 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. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace facebook::yoga { + +struct TrackSizing { + enum class AffectedSize { + BaseSize, + GrowthLimit + }; + + struct ContentDistribution { + float startOffset = 0.0f; + float betweenTracksOffset = 0.0f; + float effectiveGap = 0.0f; + }; + + struct ItemConstraint { + float width; + float height; + SizingMode widthSizingMode; + SizingMode heightSizingMode; + float containingBlockWidth; + float containingBlockHeight; + }; + + using CrossDimensionEstimator = std::function; + + struct ItemSizeContribution { + const GridItem* item; + std::vector affectedTracks; + float sizeContribution; + + ItemSizeContribution( + const GridItem* item, + const std::vector& affectedTracks, + float sizeContribution) : + item(item), + affectedTracks(affectedTracks), + sizeContribution(sizeContribution) {} + }; + + Node* node; + std::vector& columnTracks; + std::vector& rowTracks; + float containerInnerWidth; + float containerInnerHeight; + std::vector& gridItems; + SizingMode widthSizingMode; + SizingMode heightSizingMode; + Direction direction; + float ownerWidth; + float ownerHeight; + LayoutData& layoutMarkerData; + uint32_t depth; + uint32_t generationCount; + CrossDimensionEstimator crossDimensionEstimator; + + // below flags are used for optimization purposes + bool hasPercentageColumnTracks = false; + bool hasPercentageRowTracks = false; + bool hasOnlyFixedTracks = false; + bool hasIntrinsicTracks = false; + bool hasFlexibleTracks = false; + + // Pre-computed baseline sharing groups + BaselineItemGroups& baselineItemGroups; + + TrackSizing( + yoga::Node* node, + std::vector& columnTracks, + std::vector& rowTracks, + float containerInnerWidth, + float containerInnerHeight, + std::vector& gridItems, + SizingMode widthSizingMode, + SizingMode heightSizingMode, + Direction direction, + float ownerWidth, + float ownerHeight, + LayoutData& layoutMarkerData, + uint32_t depth, + uint32_t generationCount, + BaselineItemGroups& baselineItemGroups) : + node(node), + columnTracks(columnTracks), + rowTracks(rowTracks), + containerInnerWidth(containerInnerWidth), + containerInnerHeight(containerInnerHeight), + gridItems(gridItems), + widthSizingMode(widthSizingMode), + heightSizingMode(heightSizingMode), + direction(direction), + ownerWidth(ownerWidth), + ownerHeight(ownerHeight), + layoutMarkerData(layoutMarkerData), + depth(depth), + generationCount(generationCount), + baselineItemGroups(baselineItemGroups) {} + + // 11.1. Grid Sizing Algorithm + // https://www.w3.org/TR/css-grid-1/#algo-grid-sizing + void runGridSizingAlgorithm() { + computeItemTrackCrossingFlags(); + + // 1. First, the track sizing algorithm is used to resolve the sizes of the grid columns. + auto rowHeightFromFixedTracks = makeRowHeightEstimatorUsingFixedTracks(calculateEffectiveRowGapForEstimation()); + runTrackSizing(Dimension::Width, rowHeightFromFixedTracks); + + // 2. Next, the track sizing algorithm resolves the sizes of the grid rows. + auto columnWidthFromBaseSizes = makeCrossDimensionEstimatorUsingBaseSize(Dimension::Width, calculateEffectiveGapFromBaseSizes(Dimension::Width)); + runTrackSizing(Dimension::Height, columnWidthFromBaseSizes); + + // 3. Then, if the min-content contribution of any grid item has changed + // Only intrinsic tracks can affect the cross track size in above steps, so this step is only needed if there are intrinsic tracks + if (hasIntrinsicTracks) { + auto rowHeightFromBaseSizes = makeCrossDimensionEstimatorUsingBaseSize(Dimension::Height, calculateEffectiveGapFromBaseSizes(Dimension::Height)); + if (contributionsChanged(Dimension::Width, rowHeightFromFixedTracks, rowHeightFromBaseSizes)) { + runTrackSizing(Dimension::Width, rowHeightFromBaseSizes); + // 4. Next, if the min-content contribution of any grid item has changed + auto newColumnWidthFromBaseSizes = makeCrossDimensionEstimatorUsingBaseSize(Dimension::Width, calculateEffectiveGapFromBaseSizes(Dimension::Width)); + if (contributionsChanged(Dimension::Height, columnWidthFromBaseSizes, newColumnWidthFromBaseSizes)) { + runTrackSizing(Dimension::Height, newColumnWidthFromBaseSizes); + } + } + } + } + + // 11.3. Track Sizing Algorithm + // https://www.w3.org/TR/css-grid-1/#algo-track-sizing + void runTrackSizing(Dimension dimension, CrossDimensionEstimator estimator = nullptr) { + // Store the estimator for use in calculateItemConstraints + crossDimensionEstimator = estimator; + + // Step 1: Initialize Track Sizes + initializeTrackSizes(dimension); + // Step 2: Resolve Intrinsic Track Sizes + resolveIntrinsicTrackSizes(dimension); + // Step 3: Maximize Track Sizes + maximizeTrackSizes(dimension); + // Step 4: Expand Flexible Tracks + expandFlexibleTracks(dimension); + // Step 5: Stretch Auto Tracks + stretchAutoTracks(dimension); + } + + // 11.4 Initialize Track Sizes + // https://www.w3.org/TR/css-grid-1/#algo-init + // Also sets some flags (hasPercentageTracks, hasOnlyFixedTracks) for optimization purposes + void initializeTrackSizes(Dimension dimension) { + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + bool& hasPercentageTracks = dimension == Dimension::Width ? hasPercentageColumnTracks : hasPercentageRowTracks; + hasOnlyFixedTracks = true; + hasIntrinsicTracks = false; + hasFlexibleTracks = false; + + for (size_t i = 0; i < tracks.size(); i++) { + auto& track = tracks[i]; + + // detect percentage tracks for optimization purposes + if (isPercentageSizingFunction(track.minSizingFunction) || + isPercentageSizingFunction(track.maxSizingFunction)) { + hasPercentageTracks = true; + } + + if (isFixedSizingFunction(track.minSizingFunction, containerSize)) { + auto resolved = track.minSizingFunction.resolve(containerSize); + track.baseSize = resolved.unwrap(); + } + else if (isIntrinsicSizingFunction(track.minSizingFunction, containerSize)) { + track.baseSize = 0; + hasOnlyFixedTracks = false; + hasIntrinsicTracks = true; + } + else { + // THIS SHOULD NEVER HAPPEN + track.baseSize = 0; + } + + if (isFixedSizingFunction(track.maxSizingFunction, containerSize)) { + auto resolved = track.maxSizingFunction.resolve(containerSize); + track.growthLimit = resolved.unwrap(); + } + else if (isIntrinsicSizingFunction(track.maxSizingFunction, containerSize)) { + track.growthLimit = INFINITY; + hasOnlyFixedTracks = false; + hasIntrinsicTracks = true; + } + else if (isFlexibleSizingFunction(track.maxSizingFunction)) { + track.growthLimit = INFINITY; + hasOnlyFixedTracks = false; + hasFlexibleTracks = true; + } + else { + // THIS SHOULD NEVER HAPPEN + track.growthLimit = INFINITY; + } + + // In all cases, if the growth limit is less than the base size, increase the growth limit to match the base size. + if (track.growthLimit < track.baseSize) { + track.growthLimit = track.baseSize; + } + + // minmax(20px, 40px) type of tracks are not fixed tracks + if (track.baseSize < track.growthLimit) { + hasOnlyFixedTracks = false; + } + } + } + + // 11.5 Resolve Intrinsic Track Sizes + // https://www.w3.org/TR/css-grid-1/#algo-content + void resolveIntrinsicTrackSizes(Dimension dimension) { + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + + // Step 1: Shim baseline-aligned items (only for height dimension i.e. align-items/align-self) + if (dimension == Dimension::Height) { + shimBaselineAlignedItems(); + } + + // Fast path - if tracks are fixed-sized, skip below steps + if (hasOnlyFixedTracks) { + return; + } + + // Step 2. and Step 3 Increase sizes to accommodate spanning items + accomodateSpanningItemsCrossingContentSizedTracks(dimension); + // Step 4. Increase sizes to accommodate spanning items crossing flexible tracks + accomodateSpanningItemsCrossingFlexibleTracks(dimension); + // Step 5. If any track still has an infinite growth limit (because, for example, it had no items placed in it or it is a flexible track), set its growth limit to its base size. + for (auto& track: tracks) { + if (track.growthLimit == INFINITY) { + track.growthLimit = track.baseSize; + } + } + } + + // https://www.w3.org/TR/css-grid-1/#algo-baseline-shims + void shimBaselineAlignedItems() { + for (const auto& [rowIndex, items] : baselineItemGroups) { + float maxBaselineWithMargin = 0.0f; + std::vector> itemBaselines; + itemBaselines.reserve(items.size()); + + for (auto* itemPtr : items) { + const auto& item = *itemPtr; + + if (itemSizeDependsOnIntrinsicTracks(item)) { + continue; + } + + float containingBlockWidth = crossDimensionEstimator ? crossDimensionEstimator(item) : YGUndefined; + float containingBlockHeight = YGUndefined; + + auto itemConstraints = calculateItemConstraints(item, containingBlockWidth, containingBlockHeight); + + calculateLayoutInternal( + item.node, + itemConstraints.width, + itemConstraints.height, + node->getLayout().direction(), + SizingMode::MaxContent, + itemConstraints.heightSizingMode, + itemConstraints.containingBlockWidth, + itemConstraints.containingBlockHeight, + true, + LayoutPassReason::kGridLayout, + layoutMarkerData, + depth + 1, + generationCount); + + const float baseline = calculateBaseline(item.node); + const float marginTop = item.node->style().computeInlineStartMargin( + FlexDirection::Column, direction, itemConstraints.containingBlockWidth); + const float baselineWithMargin = baseline + marginTop; + + itemBaselines.emplace_back(itemPtr, baselineWithMargin); + maxBaselineWithMargin = std::max(maxBaselineWithMargin, baselineWithMargin); + } + + for (auto& [itemPtr, baselineWithMargin] : itemBaselines) { + itemPtr->baselineShim = maxBaselineWithMargin - baselineWithMargin; + } + } + } + + // https://www.w3.org/TR/css-grid-1/#algo-single-span-items + // https://www.w3.org/TR/css-grid-1/#algo-spanning-items + void accomodateSpanningItemsCrossingContentSizedTracks(Dimension dimension) { + if (!hasIntrinsicTracks) { + return; + } + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + auto sizingMode = dimension == Dimension::Width ? widthSizingMode : heightSizingMode; + + auto startIndexKey = dimension == Dimension::Width ? &GridItem::columnStart : &GridItem::rowStart; + auto endIndexKey = dimension == Dimension::Width ? &GridItem::columnEnd : &GridItem::rowEnd; + + // 2. Size tracks to fit non-spanning items (span = 1 items) + // https://www.w3.org/TR/css-grid-1/#algo-single-span-items + std::vector spanningItemIndices; + spanningItemIndices.reserve(gridItems.size()); + for (size_t index = 0; index < gridItems.size(); index++) { + const auto& item = gridItems[index]; + if (item.crossesFlexibleTrack(dimension)) { + continue; + } + auto startIndex = item.*startIndexKey; + auto endIndex = item.*endIndexKey; + size_t span = endIndex - startIndex; + if (span == 1) { + auto& track = tracks[startIndex]; + auto itemConstraints = calculateItemConstraints(item, dimension); + // For auto minimums: + if (isAutoSizingFunction(track.minSizingFunction, containerSize)) { + float contribution = sizingMode == SizingMode::MaxContent + ? limitedMinContentContribution(item, dimension, itemConstraints) + : minimumContribution(item, dimension, itemConstraints); + track.baseSize = std::max(track.baseSize, contribution); + } + + // For max-content maximums: + if (isAutoSizingFunction(track.maxSizingFunction, containerSize)) { + float contribution = maxContentContribution(item, dimension, itemConstraints); + if (track.growthLimit == INFINITY) { + track.growthLimit = contribution; + } else { + track.growthLimit = std::max(track.growthLimit, contribution); + } + } + // In all cases, if a track's growth limit is now less than its base size, increase the growth limit to match the base size. + if (track.growthLimit < track.baseSize) { + track.growthLimit = track.baseSize; + } + } else { + spanningItemIndices.push_back(index); + } + } + + // 3. Increase sizes to accommodate spanning items crossing content-sized tracks: + // https://www.w3.org/TR/css-grid-1/#algo-spanning-items + if (spanningItemIndices.empty()) { + return; + } + + std::sort(spanningItemIndices.begin(), spanningItemIndices.end(), [&](size_t i, size_t j) { + const auto& a = gridItems[i]; + const auto& b = gridItems[j]; + return (a.*endIndexKey - a.*startIndexKey) < (b.*endIndexKey - b.*startIndexKey); + }); + + size_t previousSpan = 1; + std::vector itemsForIntrinsicMin; + std::vector itemsForIntrinsicMax; + std::vector itemsForMaxContentMax; + + auto distributeSpaceToTracksForItemsWithTheSameSpan = [&]() { + // Step 1: For intrinsic minimums + if (!itemsForIntrinsicMin.empty()) { + distributeExtraSpaceAcrossSpannedTracks(dimension, itemsForIntrinsicMin, AffectedSize::BaseSize); + itemsForIntrinsicMin.clear(); + } + + // Step 2 and Step 3 are skipped since we're not supporting min-content and max-content yet + + // Step 4: If at this point any track's growth limit is now less than its base size, increase its growth limit to match its base size + for (auto& track : tracks) { + if (track.growthLimit < track.baseSize) { + track.growthLimit = track.baseSize; + } + + // https://www.w3.org/TR/css-grid-1/#infinitely-growable + // reset infinitely growable flag for each track + // This flag gets set in Step 5 and used in Step 6, so we need to reset it before running Step 5. + track.infinitelyGrowable = false; + } + + // Step 5: For intrinsic maximums + if (!itemsForIntrinsicMax.empty()) { + distributeExtraSpaceAcrossSpannedTracks(dimension, itemsForIntrinsicMax, AffectedSize::GrowthLimit); + itemsForIntrinsicMax.clear(); + } + + // Step 6: For max-content maximums + if (!itemsForMaxContentMax.empty()) { + distributeExtraSpaceAcrossSpannedTracks(dimension, itemsForMaxContentMax, AffectedSize::GrowthLimit); + itemsForMaxContentMax.clear(); + } + }; + + for (auto& index: spanningItemIndices) { + const auto& item = gridItems[index]; + + if (item.crossesFlexibleTrack(dimension)) { + continue; + } + + auto startIndex = item.*startIndexKey; + auto endIndex = item.*endIndexKey; + size_t span = endIndex - startIndex; + + if (span > previousSpan) { + distributeSpaceToTracksForItemsWithTheSameSpan(); + previousSpan = span; + } + + std::vector intrinsicMinimumSizingFunctionTracks; + std::vector intrinsicMaximumSizingFunctionTracks; + std::vector maxContentMaximumSizingFunctionTracks; + + for (size_t i = startIndex; i < endIndex; i++) { + if (isIntrinsicSizingFunction(tracks[i].minSizingFunction, containerSize)) { + intrinsicMinimumSizingFunctionTracks.push_back(&tracks[i]); + } + + if (isIntrinsicSizingFunction(tracks[i].maxSizingFunction, containerSize)) { + intrinsicMaximumSizingFunctionTracks.push_back(&tracks[i]); + } + + // auto as max sizing function is treated as max-content sizing function + if (isAutoSizingFunction(tracks[i].maxSizingFunction, containerSize)) { + maxContentMaximumSizingFunctionTracks.push_back(&tracks[i]); + } + } + + auto itemConstraints = calculateItemConstraints(item, dimension); + if (!intrinsicMinimumSizingFunctionTracks.empty()) { + auto minContribution = sizingMode == SizingMode::MaxContent + ? limitedMinContentContribution(item, dimension, itemConstraints) + : minimumContribution(item, dimension, itemConstraints); + itemsForIntrinsicMin.emplace_back(&item, std::move(intrinsicMinimumSizingFunctionTracks), minContribution); + } + + if (!intrinsicMaximumSizingFunctionTracks.empty()) { + auto minContentContrib = minContentContribution(item, dimension, itemConstraints); + itemsForIntrinsicMax.emplace_back(&item, std::move(intrinsicMaximumSizingFunctionTracks), minContentContrib); + } + + if (!maxContentMaximumSizingFunctionTracks.empty()) { + auto maxContentContrib = maxContentContribution(item, dimension, itemConstraints); + itemsForMaxContentMax.emplace_back(&item, std::move(maxContentMaximumSizingFunctionTracks), maxContentContrib); + } + } + + // Process last span + distributeSpaceToTracksForItemsWithTheSameSpan(); + }; + + // https://www.w3.org/TR/css-grid-1/#algo-spanning-flex-items + void accomodateSpanningItemsCrossingFlexibleTracks(Dimension dimension) { + if (!hasFlexibleTracks) { + return; + } + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto sizingMode = dimension == Dimension::Width ? widthSizingMode : heightSizingMode; + auto startIndexkey = dimension == Dimension::Width ? &GridItem::columnStart : &GridItem::rowStart; + auto endIndexKey = dimension == Dimension::Width ? &GridItem::columnEnd : &GridItem::rowEnd; + + std::vector itemsSpanningFlexible; + + for (const auto& item : gridItems) { + if (!item.crossesFlexibleTrack(dimension)) { + continue; + } + + auto start = item.*startIndexkey; + auto end = item.*endIndexKey; + std::vector flexibleTracks; + + for (size_t i = start; i < end && i < tracks.size(); i++) { + auto& track = tracks[i]; + if (isFlexibleSizingFunction(track.maxSizingFunction)) { + flexibleTracks.push_back(&track); + } + } + + if (!flexibleTracks.empty()) { + auto itemConstraints = calculateItemConstraints(item, dimension); + auto minContribution = sizingMode == SizingMode::MaxContent + ? limitedMinContentContribution(item, dimension, itemConstraints) + : minimumContribution(item, dimension, itemConstraints); + + itemsSpanningFlexible.emplace_back( + &item, + std::move(flexibleTracks), + minContribution + ); + } + } + + if (!itemsSpanningFlexible.empty()) { + distributeSpaceToFlexibleTracksForItems(dimension, itemsSpanningFlexible); + } + }; + + // https://www.w3.org/TR/css-grid-1/#extra-space + void distributeExtraSpaceAcrossSpannedTracks( + Dimension dimension, + std::vector& gridItemSizeContributions, + AffectedSize affectedSizeType) { + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto startIndexKey = dimension == Dimension::Width ? &GridItem::columnStart : &GridItem::rowStart; + auto endIndexKey = dimension == Dimension::Width ? &GridItem::columnEnd : &GridItem::rowEnd; + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + auto gap = node->style().computeGapForDimension(dimension, containerSize); + std::unordered_map plannedIncrease; + plannedIncrease.reserve(gridItemSizeContributions.size()); + + // 1. Maintain separately for each affected track a planned increase, initially set to 0. (This prevents the size increases from becoming order-dependent.) + for (const auto& itemSizeContribution : gridItemSizeContributions) { + for (auto& track : itemSizeContribution.affectedTracks) { + plannedIncrease[track] = 0.0f; + } + } + + // 2. For each accommodated item, considering only tracks the item spans: + for (const auto& itemSizeContribution : gridItemSizeContributions) { + std::unordered_map itemIncurredIncrease; + itemIncurredIncrease.reserve(itemSizeContribution.affectedTracks.size()); + for (auto& track: itemSizeContribution.affectedTracks) { + itemIncurredIncrease[track] = 0.0f; + } + + // 2.1 Find the space to distribute + auto start = itemSizeContribution.item->*startIndexKey; + auto end = itemSizeContribution.item->*endIndexKey; + float totalSpannedTracksSize = 0.0f; + for (size_t i = start; i < end && i < tracks.size(); i++) { + auto& track = tracks[i]; + if (affectedSizeType == AffectedSize::BaseSize) { + totalSpannedTracksSize += track.baseSize; + } else { + // For infinite growth limits, substitute the track's base size + totalSpannedTracksSize += track.growthLimit == INFINITY ? track.baseSize : track.growthLimit; + } + if (i < end - 1) { + // gaps are treated as tracks of fixed size. Item can span over gaps. + totalSpannedTracksSize += gap; + } + } + + float spaceToDistribute = std::max(0.0f, itemSizeContribution.sizeContribution - totalSpannedTracksSize); + std::unordered_set frozenTracks; + frozenTracks.reserve(itemSizeContribution.affectedTracks.size()); + + // 2.2. Distribute space up to limits + while (frozenTracks.size() < itemSizeContribution.affectedTracks.size() && spaceToDistribute > 0.0f && !yoga::inexactEquals(spaceToDistribute, 0.0f)) { + auto unfrozenTrackCount = itemSizeContribution.affectedTracks.size() - frozenTracks.size(); + auto distributionPerTrack = spaceToDistribute / unfrozenTrackCount; + + for (auto& track: itemSizeContribution.affectedTracks) { + if (frozenTracks.contains(track)) { + continue; + } + + float limit; + float affectedSize; + + if (affectedSizeType == AffectedSize::BaseSize) { + affectedSize = track->baseSize; + limit = track->growthLimit; + } else { + affectedSize = track->growthLimit; + limit = INFINITY; + if (track->growthLimit != INFINITY && !track->infinitelyGrowable) { + limit = track->growthLimit; + } + + // If the affected size was a growth limit and the track is not marked infinitely growable, then each item-incurred increase will be zero. + if (!track->infinitelyGrowable) { + frozenTracks.insert(track); + continue; + } + } + + if (affectedSize + distributionPerTrack + itemIncurredIncrease[track] > limit) { + frozenTracks.insert(track); + auto increase = limit - affectedSize - itemIncurredIncrease[track]; + itemIncurredIncrease[track] += increase; + spaceToDistribute -= increase; + } else { + itemIncurredIncrease[track] += distributionPerTrack; + spaceToDistribute -= distributionPerTrack; + } + } + } + + // 2.3. Distribute space to non-affected tracks: + // Currently, browsers do not implement this step. + // https://github.com/w3c/csswg-drafts/issues/3648 + + // 2.4. Distribute space beyond limits + if (spaceToDistribute > 0.0f && !yoga::inexactEquals(spaceToDistribute, 0.0f)) { + std::vector tracksToGrowBeyondLimits; + for (auto& track: itemSizeContribution.affectedTracks) { + if (isIntrinsicSizingFunction(track->maxSizingFunction, containerSize)) { + tracksToGrowBeyondLimits.push_back(track); + } + } + + // if there are no such tracks, then all affected tracks. + if (affectedSizeType == AffectedSize::BaseSize && tracksToGrowBeyondLimits.empty()) { + tracksToGrowBeyondLimits = itemSizeContribution.affectedTracks; + } + + while (spaceToDistribute > 0.0f && !yoga::inexactEquals(spaceToDistribute, 0.0f) && !tracksToGrowBeyondLimits.empty()) { + auto unfrozenTrackCount = tracksToGrowBeyondLimits.size(); + auto distributionPerTrack = spaceToDistribute / unfrozenTrackCount; + for (auto& track: tracksToGrowBeyondLimits) { + itemIncurredIncrease[track] += distributionPerTrack; + spaceToDistribute -= distributionPerTrack; + } + } + } + + // 2.5. For each affected track, if the track's item-incurred increase is larger than the track's planned increase set the track's planned increase to that value. + for (auto& track: itemSizeContribution.affectedTracks) { + if (itemIncurredIncrease[track] > plannedIncrease[track]) { + plannedIncrease[track] = itemIncurredIncrease[track]; + } + } + } + + // 3. Update the tracks affected sizes + for (const auto& [track, increase] : plannedIncrease) { + if (affectedSizeType == AffectedSize::BaseSize) { + track->baseSize += increase; + } else { + if (track->growthLimit == INFINITY) { + track->growthLimit = track->baseSize + increase; + track->infinitelyGrowable = true; + } else { + track->growthLimit += increase; + } + } + } + } + + // https://www.w3.org/TR/css-grid-1/#extra-space + // Similar to distribute extra space for content sized tracks, but distributes space considering flex factors. + void distributeSpaceToFlexibleTracksForItems( + Dimension dimension, + const std::vector& gridItemSizeContributions) { + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + auto gap = node->style().computeGapForDimension(dimension, containerSize); + auto startIndexKey = dimension == Dimension::Width ? &GridItem::columnStart : &GridItem::rowStart; + auto endIndexKey = dimension == Dimension::Width ? &GridItem::columnEnd : &GridItem::rowEnd; + + // Step 1: Maintain planned increase for each affected track + std::unordered_map plannedIncrease; + for (const auto& itemSizeContribution : gridItemSizeContributions) { + for (auto& track : itemSizeContribution.affectedTracks) { + plannedIncrease[track] = 0.0f; + } + } + + // Step 2: For each item + for (const auto& itemSizeContribution : gridItemSizeContributions) { + std::unordered_map itemIncurredIncrease; + for (auto& track : itemSizeContribution.affectedTracks) { + itemIncurredIncrease[track] = 0.0f; + } + + // 2.1 Find space to distribute + auto start = itemSizeContribution.item->*startIndexKey; + auto end = itemSizeContribution.item->*endIndexKey; + float totalSpannedTracksSize = 0.0f; + for (size_t i = start; i < end && i < tracks.size(); i++) { + totalSpannedTracksSize += tracks[i].baseSize; + if (i < end - 1) { + // gaps are treated as tracks of fixed size. Item can span over gaps. + totalSpannedTracksSize += gap; + } + } + + float spaceToDistribute = std::max(0.0f, itemSizeContribution.sizeContribution - totalSpannedTracksSize); + + float sumOfFlexFactors = 0.0f; + for (auto& track : itemSizeContribution.affectedTracks) { + sumOfFlexFactors += track->maxSizingFunction.value().unwrap(); + } + + if (sumOfFlexFactors > 0.0f) { + // Distribute space by flex ratios (normalized) + for (auto& track : itemSizeContribution.affectedTracks) { + auto flexFactor = track->maxSizingFunction.value().unwrap(); + auto increase = spaceToDistribute * flexFactor / sumOfFlexFactors; + itemIncurredIncrease[track] += increase; + } + } else { + // All flex factors are zero, distribute equally + auto equalShare = spaceToDistribute / static_cast(itemSizeContribution.affectedTracks.size()); + for (auto& track : itemSizeContribution.affectedTracks) { + itemIncurredIncrease[track] += equalShare; + } + } + + for (auto& track : itemSizeContribution.affectedTracks) { + if (itemIncurredIncrease[track] > plannedIncrease[track]) { + plannedIncrease[track] = itemIncurredIncrease[track]; + } + } + } + + // Step 3: Update the tracks' affected sizes by adding in the planned increase + for (const auto& [track, increase] : plannedIncrease) { + track->baseSize += increase; + } + }; + + // 11.6. Maximize Tracks + // https://www.w3.org/TR/css-grid-1/#algo-grow-tracks + void maximizeTrackSizes(Dimension dimension) { + // Fast path - if tracks are fixed-sized, skip below steps + if (hasOnlyFixedTracks) { + return; + } + + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + + // Save original base sizes before maximization + std::vector originalBaseSizes; + originalBaseSizes.reserve(tracks.size()); + for (auto& track : tracks) { + originalBaseSizes.push_back(track.baseSize); + } + + // First attempt with the original container inner size + distributeFreeSpaceToTracks(dimension, containerSize); + + // Check if this would cause the grid to be larger than the grid container's inner size as limited by its max-width/height + auto totalGridSize = getTotalBaseSize(dimension); + + // Get the max constraint for this dimension + const float paddingAndBorder = dimension == Dimension::Width + ? paddingAndBorderForAxis(node, FlexDirection::Row, direction, ownerWidth) + : paddingAndBorderForAxis(node, FlexDirection::Column, direction, ownerWidth); + + auto maxContainerBorderBoxSize = node->style().resolvedMaxDimension( + direction, + dimension, + dimension == Dimension::Width ? ownerWidth : ownerHeight, + ownerWidth); + + auto maxContainerInnerSize = maxContainerBorderBoxSize.isDefined() + ? maxContainerBorderBoxSize.unwrap() - paddingAndBorder + : YGUndefined; + + if (yoga::isDefined(maxContainerInnerSize)) { + if (totalGridSize > maxContainerInnerSize) { + // Redo this step, treating the available grid space as equal to the grid container's inner size when it's sized to its max-width/height + // Reset base sizes to their values before this maximize step + for (size_t i = 0; i < tracks.size(); i++) { + tracks[i].baseSize = originalBaseSizes[i]; + } + + distributeFreeSpaceToTracks(dimension, maxContainerInnerSize); + } + } + } + + // Distribute space in maximizeTrackSizes step + // https://www.w3.org/TR/css-grid-1/#algo-grow-tracks + void distributeFreeSpaceToTracks(Dimension dimension, float targetAvailableSize) { + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto sizingMode = dimension == Dimension::Width ? widthSizingMode : heightSizingMode; + float freeSpace = 0.0f; + if (yoga::isDefined(targetAvailableSize)) { + auto totalBaseSize = getTotalBaseSize(dimension); + freeSpace = std::max(0.0f, targetAvailableSize - totalBaseSize); + } + + // For the purpose of this step: if sizing the grid container under a max-content constraint, the free space is infinite; + // if sizing under a min-content constraint, the free space is zero. + if (sizingMode == SizingMode::MaxContent) { + freeSpace = INFINITY; + } + + // If the free space is positive, distribute it equally to the base sizes of all tracks, + // freezing tracks as they reach their growth limits (and continuing to grow the unfrozen tracks as needed). + if (freeSpace > 0.0f && !yoga::inexactEquals(freeSpace, 0.0f)) { + // growth limit will not be Infinite in maximizeTrackSizes step since we had set Infinite growth limit to base size in resolveIntrinsicTrackSizes's last step - https://www.w3.org/TR/css-grid-1/#algo-finite-growth + if (freeSpace == INFINITY) { + for (auto& track : tracks) { + track.baseSize = track.growthLimit; + } + } else { + std::unordered_set frozenTracks; + frozenTracks.reserve(tracks.size()); + auto extraSpace = freeSpace; + + while (frozenTracks.size() < tracks.size() && extraSpace > 0.0f && !yoga::inexactEquals(extraSpace, 0.0f)) { + auto unfrozenTrackCount = tracks.size() - frozenTracks.size(); + auto distributionPerTrack = extraSpace / unfrozenTrackCount; + + for (auto& track : tracks) { + GridTrackSize* trackPtr = &track; + if (frozenTracks.contains(trackPtr)) { + continue; + } + + // Check if adding this distribution would exceed the growth limit + if (track.baseSize + distributionPerTrack > track.growthLimit) { + auto increase = std::max(0.0f, track.growthLimit - track.baseSize); + track.baseSize += increase; + extraSpace -= increase; + frozenTracks.insert(trackPtr); + } else { + track.baseSize += distributionPerTrack; + extraSpace -= distributionPerTrack; + } + } + } + } + } + } + + // 11.7. Expand Flexible Tracks + // https://www.w3.org/TR/css-grid-1/#algo-flex-tracks + void expandFlexibleTracks(Dimension dimension) { + if (!hasFlexibleTracks) { + return; + } + + auto& gridTracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + auto gap = node->style().computeGapForDimension(dimension, containerSize); + + float freeSpace = calculateFreeSpace(dimension); + + float flexFraction = 0.0f; + // If the free space is zero or if sizing the grid container under a min-content constraint: + if (yoga::inexactEquals(freeSpace, 0.0f)) { + flexFraction = 0.0f; + } + // Otherwise, if the free space is a definite length: + // The used flex fraction is the result of finding the size of an fr using all of the grid tracks and a space to fill of the available grid space. + else if (yoga::isDefined(freeSpace)) { + flexFraction = findFrSize(dimension, 0, gridTracks.size(), containerSize, std::unordered_set()); + } + // Otherwise, if the free space is an indefinite length: + // The used flex fraction is the maximum of: + // For each flexible track, if the flexible track's flex factor is greater than one, the result of dividing the track's base size by its flex factor; otherwise, the track's base size. + // For each grid item that crosses a flexible track, the result of finding the size of an fr using all the grid tracks that the item crosses and a space to fill of the item’s max-content contribution. + else { + for (auto& track : gridTracks) { + if (isFlexibleSizingFunction(track.maxSizingFunction) && track.maxSizingFunction.value().isDefined()) { + float flexFactor = track.maxSizingFunction.value().unwrap(); + if (flexFactor > 1.0f) { + flexFraction = std::max(flexFraction, track.baseSize / flexFactor); + } else { + flexFraction = std::max(flexFraction, track.baseSize); + } + } + } + + auto startIndexKey = dimension == Dimension::Width ? &GridItem::columnStart : &GridItem::rowStart; + auto endIndexKey = dimension == Dimension::Width ? &GridItem::columnEnd : &GridItem::rowEnd; + + for (auto& item : gridItems) { + if (!item.crossesFlexibleTrack(dimension)) { + continue; + } + auto itemConstraints = calculateItemConstraints(item, dimension); + auto itemMaxContentContribution = maxContentContribution(item, dimension, itemConstraints); + flexFraction = std::max(flexFraction, findFrSize(dimension, item.*startIndexKey, item.*endIndexKey, itemMaxContentContribution, std::unordered_set())); + } + } + + // If using this flex fraction would cause the grid to be smaller than the grid container's min-width/height + // (or larger than the grid container's max-width/height), then redo this step, treating the free space as definite + // and the available grid space as equal to the grid container's inner size when it's sized to its min-width/height (max-width/height). + + // Calculate what the grid size would be with this flex fraction + float newTotalSize = 0.0f; + for (size_t i = 0; i < gridTracks.size(); i++) { + auto& track = gridTracks[i]; + if (isFlexibleSizingFunction(track.maxSizingFunction) && track.maxSizingFunction.value().isDefined()) { + float flexFactor = track.maxSizingFunction.value().unwrap(); + newTotalSize += std::max(track.baseSize, flexFraction * flexFactor); + } else { + newTotalSize += track.baseSize; + } + if (i < gridTracks.size() - 1) { + newTotalSize += gap; + } + } + + // Check min constraint for this dimension + const float paddingAndBorder = dimension == Dimension::Width + ? paddingAndBorderForAxis(node, FlexDirection::Row, direction, ownerWidth) + : paddingAndBorderForAxis(node, FlexDirection::Column, direction, ownerWidth); + auto minContainerOuter = node->style().resolvedMinDimension( + direction, + dimension, + dimension == Dimension::Width ? ownerWidth : ownerHeight, + ownerWidth); + auto minContainerSize = minContainerOuter.isDefined() + ? minContainerOuter.unwrap() - paddingAndBorder + : YGUndefined; + + if (yoga::isDefined(minContainerSize)) { + if (newTotalSize < minContainerSize) { + // Redo with min constraint + flexFraction = findFrSize(dimension, 0, gridTracks.size(), minContainerSize, std::unordered_set()); + } + } + + // Get the max constraint for this dimension + auto maxContainerOuter = node->style().resolvedMaxDimension( + direction, + dimension, + dimension == Dimension::Width ? ownerWidth : ownerHeight, + ownerWidth); + + auto maxContainerSize = maxContainerOuter.isDefined() + ? maxContainerOuter.unwrap() - paddingAndBorder + : YGUndefined; + + if (yoga::isDefined(maxContainerSize)) { + if (newTotalSize > maxContainerSize) { + // Redo with max constraint + flexFraction = findFrSize(dimension, 0, gridTracks.size(), maxContainerSize, std::unordered_set()); + } + } + + // For each flexible track, if the product of the used flex fraction and the track's flex factor is greater than the track's base size, + // set its base size to that product. + for (auto& track : gridTracks) { + if (isFlexibleSizingFunction(track.maxSizingFunction) && track.maxSizingFunction.value().isDefined()) { + float flexFactor = track.maxSizingFunction.value().unwrap(); + float newSize = flexFraction * flexFactor; + if (newSize > track.baseSize) { + track.baseSize = newSize; + } + } + } + }; + + // 11.7.1. Find the Size of an fr + // https://www.w3.org/TR/css-grid-1/#algo-find-fr-size + float findFrSize(Dimension dimension, size_t startIndex, size_t endIndex, float spaceToFill, const std::unordered_set& nonFlexibleTracks) { + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + auto gap = node->style().computeGapForDimension(dimension, containerSize); + auto leftoverSpace = spaceToFill; + auto flexFactorSum = 0.0f; + std::vector flexibleTracks; + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + + for (size_t i = startIndex; i < endIndex; i++) { + auto& track = tracks[i]; + // Let leftover space be the space to fill minus the base sizes of the non-flexible grid tracks. + if (i < endIndex - 1) { + // gap is treated as a non-flexible track + leftoverSpace -= gap; + } + + if (!isFlexibleSizingFunction(track.maxSizingFunction) || nonFlexibleTracks.contains(&track)) { + leftoverSpace -= track.baseSize; + } + // Let flex factor sum be the sum of the flex factors of the flexible tracks. + else if (track.maxSizingFunction.isStretch() && track.maxSizingFunction.value().isDefined()) { + flexFactorSum += track.maxSizingFunction.value().unwrap(); + flexibleTracks.push_back(&track); + } + } + + // If this value is less than 1, set it to 1 instead. + if (flexFactorSum < 1.0f) { + flexFactorSum = 1.0f; + } + + // Let the hypothetical fr size be the leftover space divided by the flex factor sum. + auto hypotheticalFrSize = leftoverSpace / flexFactorSum; + // If the product of the hypothetical fr size and a flexible track's flex factor is less than the track's base size, restart this algorithm treating all such tracks as inflexible. + std::unordered_set inflexibleTracks; + for (auto& track : flexibleTracks) { + if (track->maxSizingFunction.isStretch() && track->maxSizingFunction.value().isDefined()) { + float flexFactor = track->maxSizingFunction.value().unwrap(); + if (hypotheticalFrSize * flexFactor < track->baseSize) { + inflexibleTracks.insert(track); + } + } + } + + // restart this algorithm treating all such tracks as inflexible. + if (!inflexibleTracks.empty()) { + inflexibleTracks.insert(nonFlexibleTracks.begin(), nonFlexibleTracks.end()); + return findFrSize(dimension, startIndex, endIndex, spaceToFill, inflexibleTracks); + } + + return hypotheticalFrSize; + } + + // 11.8. Stretch auto Tracks + // https://www.w3.org/TR/css-grid-1/#algo-stretch + void stretchAutoTracks(Dimension dimension) { + // Fast path - if tracks are fixed-sized, skip below steps + if (hasOnlyFixedTracks) { + return; + } + + auto& gridTracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + + // When the content-distribution property of the grid container is normal or stretch in this axis, this step expands tracks that have an auto max track sizing function by dividing any remaining positive, definite free space equally amongst them. If the free space is indefinite, but the grid container has a definite min-width/height, use that size to calculate the free space for this step instead. + auto shouldStretch = false; + if (dimension == Dimension::Width) { + shouldStretch = node->style().justifyContent() == Justify::Stretch; + } else { + shouldStretch = node->style().alignContent() == Align::Stretch; + } + + if (shouldStretch) { + // Count only auto tracks for distribution + std::vector autoTracks; + for (auto& track : gridTracks) { + if (isAutoSizingFunction(track.maxSizingFunction, containerSize)) { + autoTracks.push_back(&track); + } + } + + if (autoTracks.empty()) { + return; + } + + float freeSpace = calculateFreeSpace(dimension); + + // If the free space is indefinite, but the grid container has a definite min-width/height, use that size to calculate the free space for this step instead. + if (!yoga::isDefined(freeSpace)) { + const float paddingAndBorder = dimension == Dimension::Width + ? paddingAndBorderForAxis(node, FlexDirection::Row, direction, ownerWidth) + : paddingAndBorderForAxis(node, FlexDirection::Column, direction, ownerWidth); + + auto minContainerBorderBoxSize = node->style().resolvedMinDimension( + direction, + dimension, + dimension == Dimension::Width ? ownerWidth : ownerHeight, + ownerWidth); + auto minContainerInnerSize = minContainerBorderBoxSize.isDefined() + ? minContainerBorderBoxSize.unwrap() - paddingAndBorder + : YGUndefined; + + if (yoga::isDefined(minContainerInnerSize)) { + auto totalBaseSize = getTotalBaseSize(dimension); + freeSpace = std::max(0.0f, minContainerInnerSize - totalBaseSize); + } + } + + if (yoga::isDefined(freeSpace) && freeSpace > 0.0f && !yoga::inexactEquals(freeSpace, 0.0f)) { + // Divide free space equally among auto tracks only + auto freeSpacePerAutoTrack = freeSpace / autoTracks.size(); + for (auto& track : autoTracks) { + track->baseSize += freeSpacePerAutoTrack; + } + } + } + }; + + // https://www.w3.org/TR/css-grid-1/#free-space + float calculateFreeSpace(Dimension dimension) { + float freeSpace = YGUndefined; + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + if (yoga::isDefined(containerSize)) { + auto totalBaseSize = getTotalBaseSize(dimension); + freeSpace = std::max(0.0f, containerSize - totalBaseSize); + } + + return freeSpace; + } + + float measureItem(const GridItem& item, Dimension dimension, const ItemConstraint& constraints) { + calculateLayoutInternal( + item.node, + constraints.width, + constraints.height, + node->getLayout().direction(), + constraints.widthSizingMode, + constraints.heightSizingMode, + constraints.containingBlockWidth, + constraints.containingBlockHeight, + false, + LayoutPassReason::kMeasureChild, + layoutMarkerData, + depth + 1, + generationCount); + + return item.node->getLayout().measuredDimension(dimension); + } + + // There are 4 size contribution types used for intrinsic track sizing + // 1. minContentContribution - item's min-content size + margins + // 2. maxContentContribution - item's max-content size + margins + // 3. minimumContribution - smallest outer size + // 4. limitedMinContentContribution - min-content clamped by fixed track limits + + // TODO: Yoga does not support min-content constraint yet so we use the max-content size contributions here + float minContentContribution(const GridItem& item, Dimension dimension, const ItemConstraint& itemConstraints) { + auto marginForAxis = item.node->style().computeMarginForAxis( + dimension == Dimension::Width ? FlexDirection::Row : FlexDirection::Column, + itemConstraints.containingBlockWidth); + + float contribution = measureItem(item, dimension, itemConstraints) + marginForAxis; + + if (dimension == Dimension::Height) { + contribution += item.baselineShim; + } + return contribution; + } + + float maxContentContribution(const GridItem& item, Dimension dimension, const ItemConstraint& itemConstraints) { + auto marginForAxis = item.node->style().computeMarginForAxis( + dimension == Dimension::Width ? FlexDirection::Row : FlexDirection::Column, + itemConstraints.containingBlockWidth); + + float contribution = measureItem(item, dimension, itemConstraints) + marginForAxis; + + if (dimension == Dimension::Height) { + contribution += item.baselineShim; + } + return contribution; + } + + // Minimum contribution: the smallest outer size the item can have + // https://www.w3.org/TR/css-grid-1/#minimum-contribution + float minimumContribution(const GridItem& item, Dimension dimension, const ItemConstraint& itemConstraints) { + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + float containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + auto containingBlockSize = dimension == Dimension::Width + ? itemConstraints.containingBlockWidth + : itemConstraints.containingBlockHeight; + + auto marginForAxis = item.node->style().computeMarginForAxis( + dimension == Dimension::Width ? FlexDirection::Row : FlexDirection::Column, + itemConstraints.containingBlockWidth); + + auto preferredSize = item.node->style().dimension(dimension); + auto minSize = item.node->style().minDimension(dimension); + + float contribution = 0.0f; + + // If preferred size is definite (not auto/percent), use min-content contribution + if (!preferredSize.isAuto() && !preferredSize.isPercent()) { + return minContentContribution(item, dimension, itemConstraints); + } + + // If explicit min-size is set, use it + if (minSize.isDefined() && !minSize.isAuto()) { + auto resolvedMinSize = minSize.resolve(containingBlockSize); + contribution = resolvedMinSize.unwrap() + marginForAxis; + } + // Otherwise compute automatic minimum size + else { + contribution = automaticMinimumSize(item, dimension, itemConstraints, tracks, containerSize) + marginForAxis; + } + + if (dimension == Dimension::Height) { + contribution += item.baselineShim; + } + return contribution; + } + + // https://www.w3.org/TR/css-grid-1/#min-size-auto + float automaticMinimumSize( + const GridItem& item, + Dimension dimension, + const ItemConstraint& itemConstraints, + const std::vector& tracks, + float containerSize) { + + auto overflow = item.node->style().overflow(); + size_t startIndex = dimension == Dimension::Width ? item.columnStart : item.rowStart; + size_t endIndex = dimension == Dimension::Width ? item.columnEnd : item.rowEnd; + + // Check its computed overflow is not a scrollable overflow value + bool isScrollContainer = overflow == Overflow::Scroll || overflow == Overflow::Hidden; + if (isScrollContainer) { + return 0.0f; + } + + // Check if it spans at least one track in that axis whose min track sizing function is auto + bool spansAutoMinTrack = false; + for (size_t i = startIndex; i < endIndex; i++) { + // TODO: check if this should also consider percentage auto behaving tracks + if (tracks[i].minSizingFunction.isAuto()) { + spansAutoMinTrack = true; + break; + } + } + if (!spansAutoMinTrack) { + return 0.0f; + } + + // Check if it spans more than one track in that axis, none of those tracks are flexible + bool spansMultipleTracks = (endIndex - startIndex) > 1; + if (spansMultipleTracks && item.crossesFlexibleTrack(dimension)) { + return 0.0f; + } + + return contentBasedMinimum(item, dimension, itemConstraints, tracks, containerSize); + } + + // https://www.w3.org/TR/css-grid-1/#content-based-minimum-size + float contentBasedMinimum( + const GridItem& item, + Dimension dimension, + const ItemConstraint& itemConstraints, + const std::vector& tracks, + float containerSize) { + + float result = measureItem(item, dimension, itemConstraints); + // Clamp by fixed track limit if all spanned tracks have fixed max sizing function + auto fixedLimit = computeFixedTracksLimit(item, dimension, tracks, containerSize); + if (yoga::isDefined(fixedLimit)) { + result = std::min(result, fixedLimit); + } + + // Clamp by max-size if definite + auto containingBlockSize = dimension == Dimension::Width + ? itemConstraints.containingBlockWidth + : itemConstraints.containingBlockHeight; + auto maxSize = item.node->style().maxDimension(dimension); + if (maxSize.isDefined()) { + auto resolvedMaxSize = maxSize.resolve(containingBlockSize); + if (resolvedMaxSize.isDefined()) { + result = std::min(result, resolvedMaxSize.unwrap()); + } + } + + return result; + } + + // https://www.w3.org/TR/css-grid-1/#limited-contribution + float limitedMinContentContribution(const GridItem& item, Dimension dimension, const ItemConstraint& itemConstraints) { + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + float containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + + auto fixedLimit = computeFixedTracksLimit(item, dimension, tracks, containerSize); + auto minContent = minContentContribution(item, dimension, itemConstraints); + auto minimum = minimumContribution(item, dimension, itemConstraints); + + if (yoga::isDefined(fixedLimit)) { + return std::max(std::min(minContent, fixedLimit), minimum); + } + + return std::max(minContent, minimum); + } + + float computeFixedTracksLimit( + const GridItem& item, + Dimension dimension, + const std::vector& tracks, + float containerSize) { + + size_t startIndex = dimension == Dimension::Width ? item.columnStart : item.rowStart; + size_t endIndex = dimension == Dimension::Width ? item.columnEnd : item.rowEnd; + auto gap = node->style().computeGapForDimension(dimension, containerSize); + + float limit = 0.0f; + for (size_t i = startIndex; i < endIndex; i++) { + if (!isFixedSizingFunction(tracks[i].maxSizingFunction, containerSize)) { + return YGUndefined; + } + auto resolved = tracks[i].maxSizingFunction.resolve(containerSize); + if (resolved.isDefined()) { + limit += resolved.unwrap(); + } + if (i < endIndex - 1) { + limit += gap; + } + } + return limit; + } + + static bool isFixedSizingFunction(const StyleSizeLength& sizingFunction, float referenceLength) { + return sizingFunction.isDefined() && sizingFunction.resolve(referenceLength).isDefined(); + } + + static bool isIntrinsicSizingFunction(const StyleSizeLength& sizingFunction, float referenceLength) { + return isAutoSizingFunction(sizingFunction, referenceLength); + } + + static bool isAutoSizingFunction(const StyleSizeLength& sizingFunction, float referenceLength) { + return sizingFunction.isAuto() || (sizingFunction.isPercent() && !yoga::isDefined(referenceLength)); + } + + static bool isFlexibleSizingFunction(const StyleSizeLength& sizingFunction) { + return sizingFunction.isStretch(); + } + + static bool isPercentageSizingFunction(const StyleSizeLength& sizingFunction) { + return sizingFunction.isPercent(); + } + + float getTotalBaseSize(Dimension dimension) { + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + const auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + auto gap = node->style().computeGapForDimension(dimension, containerSize); + + float totalBaseSize = 0.0f; + for (size_t i = 0; i < tracks.size(); i++) { + totalBaseSize += tracks[i].baseSize; + if (i < tracks.size() - 1) { + totalBaseSize += gap; + } + } + return totalBaseSize; + } + + bool hasPercentageTracks(Dimension dimension) const { + return dimension == Dimension::Width ? hasPercentageColumnTracks : hasPercentageRowTracks; + } + + ContentDistribution calculateContentDistribution( + Dimension dimension, + float freeSpace) { + auto numTracks = dimension == Dimension::Width ? columnTracks.size() : rowTracks.size(); + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + auto baseGap = node->style().computeGapForDimension(dimension, containerSize); + + ContentDistribution result; + result.effectiveGap = baseGap; + + if (yoga::inexactEquals(freeSpace, 0.0f)) { + return result; + } + + if (dimension == Dimension::Width) { + const Justify justifyContent = freeSpace > 0.0f ? + node->style().justifyContent() : + fallbackAlignment(node->style().justifyContent()); + + switch (justifyContent) { + case Justify::Center: + result.startOffset = freeSpace / 2.0f; + break; + + case Justify::End: + result.startOffset = freeSpace; + break; + + case Justify::SpaceBetween: + if (numTracks > 1) { + result.betweenTracksOffset = freeSpace / (numTracks - 1); + } + break; + + case Justify::SpaceAround: + if (numTracks > 0) { + result.betweenTracksOffset = freeSpace / numTracks; + result.startOffset = result.betweenTracksOffset / 2.0f; + } + break; + + case Justify::SpaceEvenly: + result.betweenTracksOffset = freeSpace / (numTracks + 1); + result.startOffset = result.betweenTracksOffset; + break; + + case Justify::Start: + case Justify::FlexStart: + case Justify::FlexEnd: + case Justify::Stretch: + case Justify::Auto: + default: + break; + } + } else { + const auto alignContent = freeSpace > 0.0f + ? node->style().alignContent() + : fallbackAlignment(node->style().alignContent()); + switch (alignContent) { + case Align::Center: + // content center works with negative free space too + // refer grid_align_content_center_negative_space_gap fixture + result.startOffset = freeSpace / 2.0f; + break; + case Align::End: + result.startOffset = freeSpace; + break; + case Align::SpaceBetween: + if (numTracks > 1) { + // negative free space is not distributed with space between, checkout grid_align_content_space_between_negative_space_gap fixture + result.betweenTracksOffset = std::max(0.0f, freeSpace / (numTracks - 1)); + } + break; + + case Align::SpaceAround: + if (numTracks > 0) { + result.betweenTracksOffset = freeSpace / numTracks; + result.startOffset = result.betweenTracksOffset / 2.0f; + } + break; + + case Align::SpaceEvenly: + result.betweenTracksOffset = freeSpace / (numTracks + 1); + result.startOffset = result.betweenTracksOffset; + break; + + case Align::Auto: + case Align::FlexStart: + case Align::FlexEnd: + case Align::Stretch: + case Align::Baseline: + case Align::Start: + default: + break; + } + } + + result.effectiveGap = baseGap + result.betweenTracksOffset; + return result; + } + + ItemConstraint calculateItemConstraints(const GridItem& item, Dimension dimension) { + float containingBlockWidth = YGUndefined; + float containingBlockHeight = YGUndefined; + if (dimension == Dimension::Width) { + containingBlockHeight = crossDimensionEstimator(item); + } else { + containingBlockWidth = crossDimensionEstimator(item); + } + + return calculateItemConstraints(item, containingBlockWidth, containingBlockHeight); + } + + ItemConstraint calculateItemConstraints( + const GridItem& item, + float containingBlockWidth, + float containingBlockHeight) { + auto availableWidth = YGUndefined; + auto availableHeight = YGUndefined; + auto itemWidthSizingMode = SizingMode::MaxContent; + auto itemHeightSizingMode = SizingMode::MaxContent; + auto hasDefiniteWidth = item.node->hasDefiniteLength(Dimension::Width, containingBlockWidth); + auto hasDefiniteHeight = item.node->hasDefiniteLength(Dimension::Height, containingBlockHeight); + + if (yoga::isDefined(containingBlockWidth)) { + itemWidthSizingMode = SizingMode::FitContent; + availableWidth = containingBlockWidth; + } + + if (yoga::isDefined(containingBlockHeight)) { + itemHeightSizingMode = SizingMode::FitContent; + availableHeight = containingBlockHeight; + } + + const auto marginInline = item.node->style().computeMarginForAxis(FlexDirection::Row, containingBlockWidth); + if (hasDefiniteWidth) { + itemWidthSizingMode = SizingMode::StretchFit; + auto resolvedWidth = item.node->getResolvedDimension( + direction, + Dimension::Width, + containingBlockWidth, + containingBlockWidth).unwrap(); + resolvedWidth = boundAxis( + item.node, + FlexDirection::Row, + direction, + resolvedWidth, + containingBlockWidth, + containingBlockWidth); + availableWidth = resolvedWidth + marginInline; + } + + const auto marginBlock = item.node->style().computeMarginForAxis(FlexDirection::Column, containingBlockWidth); + if (hasDefiniteHeight) { + itemHeightSizingMode = SizingMode::StretchFit; + auto resolvedHeight = item.node->getResolvedDimension( + direction, + Dimension::Height, + containingBlockHeight, + containingBlockWidth).unwrap(); + resolvedHeight = boundAxis( + item.node, + FlexDirection::Column, + direction, + resolvedHeight, + containingBlockHeight, + containingBlockWidth); + availableHeight = resolvedHeight + marginBlock; + } + + auto justifySelf = resolveChildJustification(node, item.node); + auto alignSelf = resolveChildAlignment(node, item.node); + + bool hasMarginInlineAuto = item.node->style().inlineStartMarginIsAuto(FlexDirection::Row, direction) + || item.node->style().inlineEndMarginIsAuto(FlexDirection::Row, direction); + bool hasMarginBlockAuto = item.node->style().inlineStartMarginIsAuto(FlexDirection::Column, direction) + || item.node->style().inlineEndMarginIsAuto(FlexDirection::Column, direction); + + // For stretch-aligned items with a definite containing block size and no auto margins, + // treat the item as having a definite size in that axis (it will stretch to fill). + const auto& itemStyle = item.node->style(); + + if (yoga::isDefined(containingBlockWidth) && + !hasDefiniteWidth && + justifySelf == Justify::Stretch && + !hasMarginInlineAuto) { + itemWidthSizingMode = SizingMode::StretchFit; + availableWidth = containingBlockWidth; + } + + if (yoga::isDefined(containingBlockHeight) && + !item.node->hasDefiniteLength(Dimension::Height, containingBlockHeight) && + alignSelf == Align::Stretch && + !hasMarginBlockAuto) { + itemHeightSizingMode = SizingMode::StretchFit; + availableHeight = containingBlockHeight; + } + + if (itemStyle.aspectRatio().isDefined() && + !yoga::inexactEquals(itemStyle.aspectRatio().unwrap(), 0.0f)) { + const float aspectRatio = itemStyle.aspectRatio().unwrap(); + if (itemWidthSizingMode == SizingMode::StretchFit && + itemHeightSizingMode == SizingMode::StretchFit) { + if (!hasDefiniteWidth && !hasDefiniteHeight) { + auto resolvedWidth = (availableHeight - marginBlock) * aspectRatio; + resolvedWidth = boundAxis( + item.node, + FlexDirection::Row, + direction, + resolvedWidth, + containingBlockWidth, + containingBlockWidth); + availableWidth = resolvedWidth + marginInline; + } + } else if (itemWidthSizingMode == SizingMode::StretchFit && + itemHeightSizingMode != SizingMode::StretchFit) { + auto resolvedHeight = (availableWidth - marginInline) / aspectRatio; + resolvedHeight = boundAxis( + item.node, + FlexDirection::Column, + direction, + resolvedHeight, + containingBlockHeight, + containingBlockWidth); + availableHeight = resolvedHeight + marginBlock; + itemHeightSizingMode = SizingMode::StretchFit; + } else if (itemHeightSizingMode == SizingMode::StretchFit && + itemWidthSizingMode != SizingMode::StretchFit) { + auto resolvedWidth = (availableHeight - marginBlock) * aspectRatio; + resolvedWidth = boundAxis( + item.node, + FlexDirection::Row, + direction, + resolvedWidth, + containingBlockWidth, + containingBlockWidth); + availableWidth = resolvedWidth + marginInline; + itemWidthSizingMode = SizingMode::StretchFit; + } + } + + constrainMaxSizeForMode(item.node, + direction, + FlexDirection::Row, + containingBlockWidth, + containingBlockWidth, + &itemWidthSizingMode, + &availableWidth); + constrainMaxSizeForMode(item.node, + direction, + FlexDirection::Column, + containingBlockHeight, + containingBlockWidth, + &itemHeightSizingMode, + &availableHeight); + + return ItemConstraint{ + availableWidth, + availableHeight, + itemWidthSizingMode, + itemHeightSizingMode, + containingBlockWidth, + containingBlockHeight + }; + } + + float calculateEffectiveRowGapForEstimation() { + auto rowGap = node->style().computeGapForDimension(Dimension::Height, containerInnerHeight); + + if (!yoga::isDefined(containerInnerHeight)) { + return rowGap; + } + + float totalTrackSize = 0.0f; + for (auto& track : rowTracks) { + if (isFixedSizingFunction(track.maxSizingFunction, containerInnerHeight)) { + totalTrackSize += track.maxSizingFunction.resolve(containerInnerHeight).unwrap(); + } else { + return rowGap; + } + } + + float totalGapSize = rowTracks.size() > 1 ? rowGap * (rowTracks.size() - 1) : 0.0f; + float freeSpace = containerInnerHeight - totalTrackSize - totalGapSize; + + auto distribution = calculateContentDistribution(Dimension::Height, freeSpace); + + return distribution.effectiveGap; + } + + float calculateEffectiveGapFromBaseSizes(Dimension dimension) { + auto containerSize = dimension == Dimension::Width ? containerInnerWidth : containerInnerHeight; + auto gap = node->style().computeGapForDimension(dimension, containerSize); + const auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + + if (!yoga::isDefined(containerSize)) { + return gap; + } + + float totalTrackSize = 0.0f; + for (auto& track : tracks) { + totalTrackSize += track.baseSize; + } + + float totalGapSize = tracks.size() > 1 ? gap * (tracks.size() - 1) : 0.0f; + float freeSpace = containerSize - totalTrackSize - totalGapSize; + + auto distribution = calculateContentDistribution(dimension, freeSpace); + + return distribution.effectiveGap; + } + + bool contributionsChanged( + Dimension dimension, + CrossDimensionEstimator estimatorBefore, + CrossDimensionEstimator estimatorAfter) { + for (const auto& item : gridItems) { + if (!item.crossesIntrinsicTrack(dimension)) { + continue; + } + + float crossDimBefore = estimatorBefore ? estimatorBefore(item) : YGUndefined; + float crossDimAfter = estimatorAfter ? estimatorAfter(item) : YGUndefined; + + // If cross dimension hasn't changed, contribution depending on it won't change + if (yoga::inexactEquals(crossDimBefore, crossDimAfter)) { + continue; + } + + float containingBlockWidth = dimension == Dimension::Width ? YGUndefined : crossDimBefore; + float containingBlockHeight = dimension == Dimension::Width ? crossDimBefore : YGUndefined; + auto constraintsBefore = calculateItemConstraints(item, containingBlockWidth, containingBlockHeight); + float contributionBefore = minContentContribution(item, dimension, constraintsBefore); + + containingBlockWidth = dimension == Dimension::Width ? YGUndefined : crossDimAfter; + containingBlockHeight = dimension == Dimension::Width ? crossDimAfter : YGUndefined; + auto constraintsAfter = calculateItemConstraints(item, containingBlockWidth, containingBlockHeight); + float contributionAfter = minContentContribution(item, dimension, constraintsAfter); + + if (!yoga::inexactEquals(contributionBefore, contributionAfter)) { + return true; + } + } + return false; + } + + bool itemSizeDependsOnIntrinsicTracks(const GridItem& item) const { + auto heightStyle = item.node->style().dimension(Dimension::Height); + if (heightStyle.isPercent()) { + for (size_t i = item.rowStart; i < item.rowEnd && i < rowTracks.size(); i++) { + if (isIntrinsicSizingFunction(rowTracks[i].minSizingFunction, containerInnerHeight) || + isIntrinsicSizingFunction(rowTracks[i].maxSizingFunction, containerInnerHeight)) { + return true; + } + } + } + return false; + } + + void computeItemTrackCrossingFlags() { + for (auto& item : gridItems) { + item.crossesFlexibleColumn = false; + item.crossesIntrinsicColumn = false; + item.crossesFlexibleRow = false; + item.crossesIntrinsicRow = false; + + for (size_t i = item.columnStart; i < item.columnEnd; i++) { + if (isFlexibleSizingFunction(columnTracks[i].maxSizingFunction)) { + item.crossesFlexibleColumn = true; + } else if (isIntrinsicSizingFunction(columnTracks[i].maxSizingFunction, containerInnerWidth)) { + item.crossesIntrinsicColumn = true; + } + if (isIntrinsicSizingFunction(columnTracks[i].minSizingFunction, containerInnerWidth)) { + item.crossesIntrinsicColumn = true; + } + } + + for (size_t i = item.rowStart; i < item.rowEnd; i++) { + if (isFlexibleSizingFunction(rowTracks[i].maxSizingFunction)) { + item.crossesFlexibleRow = true; + } else if (isIntrinsicSizingFunction(rowTracks[i].maxSizingFunction, containerInnerHeight)) { + item.crossesIntrinsicRow = true; + } + if (isIntrinsicSizingFunction(rowTracks[i].minSizingFunction, containerInnerHeight)) { + item.crossesIntrinsicRow = true; + } + } + } + } + + CrossDimensionEstimator makeRowHeightEstimatorUsingFixedTracks(float gap) { + auto& tracks = rowTracks; + auto containerHeight = containerInnerHeight; + return [&tracks, containerHeight, gap](const GridItem& item) -> float { + float height = 0.0f; + for (size_t i = item.rowStart; i < item.rowEnd && i < tracks.size(); i++) { + if (isFixedSizingFunction(tracks[i].maxSizingFunction, containerHeight)) { + height += tracks[i].maxSizingFunction.resolve(containerHeight).unwrap(); + if (i < item.rowEnd - 1) { + height += gap; + } + } else { + return YGUndefined; + } + } + return height; + }; + } + + CrossDimensionEstimator makeCrossDimensionEstimatorUsingBaseSize(Dimension dimension, float gap) { + std::vector baseSizes; + auto& tracks = dimension == Dimension::Width ? columnTracks : rowTracks; + baseSizes.reserve(tracks.size()); + for (const auto& track : tracks) { + baseSizes.push_back(track.baseSize); + } + auto startIndexKey = dimension == Dimension::Width ? &GridItem::columnStart : &GridItem::rowStart; + auto endIndexKey = dimension == Dimension::Width ? &GridItem::columnEnd : &GridItem::rowEnd; + return [baseSizes = std::move(baseSizes), gap, startIndexKey, endIndexKey](const GridItem& item) -> float { + float width = 0.0f; + for (size_t i = item.*startIndexKey; i < item.*endIndexKey && i < baseSizes.size(); i++) { + width += baseSizes[i]; + if (i < item.*endIndexKey - 1) { + width += gap; + } + } + return width; + }; + } +}; + +} // namespace facebook::yoga diff --git a/yoga/enums/Align.h b/yoga/enums/Align.h index 3896fe2b8b..e1b8b29bd7 100644 --- a/yoga/enums/Align.h +++ b/yoga/enums/Align.h @@ -25,11 +25,13 @@ enum class Align : uint8_t { SpaceBetween = YGAlignSpaceBetween, SpaceAround = YGAlignSpaceAround, SpaceEvenly = YGAlignSpaceEvenly, + Start = YGAlignStart, + End = YGAlignEnd, }; template <> constexpr int32_t ordinalCount() { - return 9; + return 11; } constexpr Align scopedEnum(YGAlign unscoped) { diff --git a/yoga/enums/Display.h b/yoga/enums/Display.h index 9bf23c0ac7..9edbee80b5 100644 --- a/yoga/enums/Display.h +++ b/yoga/enums/Display.h @@ -19,11 +19,12 @@ enum class Display : uint8_t { Flex = YGDisplayFlex, None = YGDisplayNone, Contents = YGDisplayContents, + Grid = YGDisplayGrid, }; template <> constexpr int32_t ordinalCount() { - return 3; + return 4; } constexpr Display scopedEnum(YGDisplay unscoped) { diff --git a/yoga/enums/GridTrackType.h b/yoga/enums/GridTrackType.h new file mode 100644 index 0000000000..eb6e8332bc --- /dev/null +++ b/yoga/enums/GridTrackType.h @@ -0,0 +1,43 @@ +/* + * 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 enums.py +// clang-format off +#pragma once + +#include +#include +#include + +namespace facebook::yoga { + +enum class GridTrackType : uint8_t { + Auto = YGGridTrackTypeAuto, + Points = YGGridTrackTypePoints, + Percent = YGGridTrackTypePercent, + Fr = YGGridTrackTypeFr, + Minmax = YGGridTrackTypeMinmax, +}; + +template <> +constexpr int32_t ordinalCount() { + return 5; +} + +constexpr GridTrackType scopedEnum(YGGridTrackType unscoped) { + return static_cast(unscoped); +} + +constexpr YGGridTrackType unscopedEnum(GridTrackType scoped) { + return static_cast(scoped); +} + +inline const char* toString(GridTrackType e) { + return YGGridTrackTypeToString(unscopedEnum(e)); +} + +} // namespace facebook::yoga diff --git a/yoga/enums/Justify.h b/yoga/enums/Justify.h index 255baa6e27..db4afece9a 100644 --- a/yoga/enums/Justify.h +++ b/yoga/enums/Justify.h @@ -16,17 +16,21 @@ namespace facebook::yoga { enum class Justify : uint8_t { + Auto = YGJustifyAuto, FlexStart = YGJustifyFlexStart, Center = YGJustifyCenter, FlexEnd = YGJustifyFlexEnd, SpaceBetween = YGJustifySpaceBetween, SpaceAround = YGJustifySpaceAround, SpaceEvenly = YGJustifySpaceEvenly, + Stretch = YGJustifyStretch, + Start = YGJustifyStart, + End = YGJustifyEnd, }; template <> constexpr int32_t ordinalCount() { - return 6; + return 10; } constexpr Justify scopedEnum(YGJustify unscoped) { diff --git a/yoga/event/event.cpp b/yoga/event/event.cpp index e286ded055..ac6735d6d4 100644 --- a/yoga/event/event.cpp +++ b/yoga/event/event.cpp @@ -29,6 +29,8 @@ const char* LayoutPassReasonToString(const LayoutPassReason value) { return "abs_measure"; case LayoutPassReason::kFlexMeasure: return "flex_measure"; + case LayoutPassReason::kGridLayout: + return "grid_layout"; default: return "unknown"; } diff --git a/yoga/event/event.h b/yoga/event/event.h index 587c1cd063..0d032240dd 100644 --- a/yoga/event/event.h +++ b/yoga/event/event.h @@ -32,6 +32,7 @@ enum struct LayoutPassReason : int { kMeasureChild = 5, kAbsMeasureChild = 6, kFlexMeasure = 7, + kGridLayout = 8, COUNT }; diff --git a/yoga/node/Node.h b/yoga/node/Node.h index 8068c81497..d22c4c1ef0 100644 --- a/yoga/node/Node.h +++ b/yoga/node/Node.h @@ -294,15 +294,15 @@ class YG_EXPORT Node : public ::YGNode { bool isNodeFlexible(); void reset(); - private: - // Used to allow resetting the node - Node& operator=(Node&&) noexcept = default; - float relativePosition( FlexDirection axis, Direction direction, float axisSize) const; + private: + // Used to allow resetting the node + Node& operator=(Node&&) noexcept = default; + void useWebDefaults() { style_.setFlexDirection(FlexDirection::Row); style_.setAlignContent(Align::Stretch); diff --git a/yoga/style/GridLine.h b/yoga/style/GridLine.h new file mode 100644 index 0000000000..e61ca58b8c --- /dev/null +++ b/yoga/style/GridLine.h @@ -0,0 +1,61 @@ +/* + * 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. + */ + +#pragma once + +#include +#include +#include + +namespace facebook::yoga { + +// https://www.w3.org/TR/css-grid-1/#typedef-grid-row-start-grid-line +enum class GridLineType: uint8_t { + Auto, + Integer, + Span, +}; + +struct GridLine { + GridLineType type; + // Line position (1, 2, -1, -2, etc) + int32_t integer; + + static GridLine auto_() { + return GridLine{GridLineType::Auto, 0}; + } + + static GridLine fromInteger(int32_t value) { + return GridLine{GridLineType::Integer, value}; + } + + static GridLine span(int32_t value) { + return GridLine{GridLineType::Span, value}; + } + + bool isAuto() const { + return type == GridLineType::Auto; + } + + bool isInteger() const { + return type == GridLineType::Integer; + } + + bool isSpan() const { + return type == GridLineType::Span; + } + + bool operator==(const GridLine& other) const { + return type == other.type && integer == other.integer; + } + + bool operator!=(const GridLine& other) const { + return !(*this == other); + } +}; + +} // namespace facebook::yoga diff --git a/yoga/style/GridTrack.h b/yoga/style/GridTrack.h new file mode 100644 index 0000000000..0a55804649 --- /dev/null +++ b/yoga/style/GridTrack.h @@ -0,0 +1,61 @@ +/* + * 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. + */ + +#pragma once + +#include +#include + +namespace facebook::yoga { + // https://www.w3.org/TR/css-grid-1/#typedef-track-size + struct GridTrackSize { + StyleSizeLength minSizingFunction; + StyleSizeLength maxSizingFunction; + + // These are used in the grid layout algorithm when distributing spaces among tracks + // TODO: maybe move them to TrackSizing since these are track states + float baseSize = 0.0f; + float growthLimit = 0.0f; + bool infinitelyGrowable = false; + + // Static factory methods for common cases + static GridTrackSize auto_() { + return GridTrackSize{StyleSizeLength::ofAuto(), StyleSizeLength::ofAuto()}; + } + + static GridTrackSize length(float points) { + auto len = StyleSizeLength::points(points); + return GridTrackSize{len, len}; + } + + static GridTrackSize fr(float fraction) { + // Flex sizing function is always a max sizing function + return GridTrackSize{StyleSizeLength::ofAuto(), StyleSizeLength::stretch(fraction)}; + } + + static GridTrackSize percent(float percentage) { + return GridTrackSize{StyleSizeLength::percent(percentage), StyleSizeLength::percent(percentage)}; + } + + static GridTrackSize minmax(StyleSizeLength min, StyleSizeLength max) { + return GridTrackSize{min, max}; + } + + bool operator==(const GridTrackSize& other) const { + return minSizingFunction == other.minSizingFunction && + maxSizingFunction == other.maxSizingFunction; + } + + bool operator!=(const GridTrackSize& other) const { + return !(*this == other); + } + }; + +// Grid track list for grid-template-rows/columns properties +using GridTrackList = std::vector; + +} // namespace facebook::yoga diff --git a/yoga/style/Style.h b/yoga/style/Style.h index 566b6934e6..2793073843 100644 --- a/yoga/style/Style.h +++ b/yoga/style/Style.h @@ -32,6 +32,8 @@ #include #include #include +#include +#include namespace facebook::yoga { @@ -65,6 +67,21 @@ class YG_EXPORT Style { justifyContent_ = value; } + + Justify justifyItems() const { + return justifyItems_; + } + void setJustifyItems(Justify value) { + justifyItems_ = value; + } + + Justify justifySelf() const { + return justifySelf_; + } + void setJustifySelf(Justify value) { + justifySelf_ = value; + } + Align alignContent() const { return alignContent_; } @@ -191,6 +208,64 @@ class YG_EXPORT Style { pool_.store(minDimensions_[yoga::to_underlying(axis)], value); } + // Grid Container Properties + const GridTrackList& gridTemplateColumns() const { + return gridTemplateColumns_; + } + void setGridTemplateColumns(GridTrackList value) { + gridTemplateColumns_ = std::move(value); + } + + const GridTrackList& gridTemplateRows() const { + return gridTemplateRows_; + } + void setGridTemplateRows(GridTrackList value) { + gridTemplateRows_ = std::move(value); + } + + const GridTrackList& gridAutoColumns() const { + return gridAutoColumns_; + } + void setGridAutoColumns(GridTrackList value) { + gridAutoColumns_ = std::move(value); + } + + const GridTrackList& gridAutoRows() const { + return gridAutoRows_; + } + void setGridAutoRows(GridTrackList value) { + gridAutoRows_ = std::move(value); + } + + // Grid Item Properties + const GridLine& gridColumnStart() const { + return gridColumnStart_; + } + void setGridColumnStart(GridLine value) { + gridColumnStart_ = std::move(value); + } + + const GridLine& gridColumnEnd() const { + return gridColumnEnd_; + } + void setGridColumnEnd(GridLine value) { + gridColumnEnd_ = std::move(value); + } + + const GridLine& gridRowStart() const { + return gridRowStart_; + } + void setGridRowStart(GridLine value) { + gridRowStart_ = std::move(value); + } + + const GridLine& gridRowEnd() const { + return gridRowEnd_; + } + void setGridRowEnd(GridLine value) { + gridRowEnd_ = std::move(value); + } + FloatOptional resolvedMinDimension( Direction direction, Dimension axis, @@ -515,6 +590,11 @@ class YG_EXPORT Style { return maxOrDefined(gap.resolve(ownerSize).unwrap(), 0.0f); } + float computeGapForDimension(Dimension dimension, float ownerSize) const { + auto gap = dimension == Dimension::Width ? computeColumnGap() : computeRowGap(); + return maxOrDefined(gap.resolve(ownerSize).unwrap(), 0.0f); + } + bool flexStartMarginIsAuto(FlexDirection axis, Direction direction) const { return computeMargin(flexStartEdge(axis), direction).isAuto(); } @@ -523,10 +603,20 @@ class YG_EXPORT Style { return computeMargin(flexEndEdge(axis), direction).isAuto(); } + bool inlineStartMarginIsAuto(FlexDirection axis, Direction direction) const { + return computeMargin(inlineStartEdge(axis, direction), direction).isAuto(); + } + + bool inlineEndMarginIsAuto(FlexDirection axis, Direction direction) const { + return computeMargin(inlineEndEdge(axis, direction), direction).isAuto(); + } + bool operator==(const Style& other) const { return direction_ == other.direction_ && flexDirection_ == other.flexDirection_ && justifyContent_ == other.justifyContent_ && + justifyItems_ == other.justifyItems_ && + justifySelf_ == other.justifySelf_ && alignContent_ == other.alignContent_ && alignItems_ == other.alignItems_ && alignSelf_ == other.alignSelf_ && positionType_ == other.positionType_ && flexWrap_ == other.flexWrap_ && @@ -545,7 +635,15 @@ class YG_EXPORT Style { minDimensions_, pool_, other.minDimensions_, other.pool_) && lengthsEqual( maxDimensions_, pool_, other.maxDimensions_, other.pool_) && - numbersEqual(aspectRatio_, pool_, other.aspectRatio_, other.pool_); + numbersEqual(aspectRatio_, pool_, other.aspectRatio_, other.pool_) && + gridTemplateColumns_ == other.gridTemplateColumns_ && + gridTemplateRows_ == other.gridTemplateRows_ && + gridAutoColumns_ == other.gridAutoColumns_ && + gridAutoRows_ == other.gridAutoRows_ && + gridColumnStart_ == other.gridColumnStart_ && + gridColumnEnd_ == other.gridColumnEnd_ && + gridRowStart_ == other.gridRowStart_ && + gridRowEnd_ == other.gridRowEnd_; } bool operator!=(const Style& other) const { @@ -727,6 +825,8 @@ class YG_EXPORT Style { FlexDirection flexDirection_ : bitCount() = FlexDirection::Column; Justify justifyContent_ : bitCount() = Justify::FlexStart; + Justify justifyItems_ : bitCount() = Justify::Stretch; + Justify justifySelf_ : bitCount() = Justify::Auto; Align alignContent_ : bitCount() = Align::FlexStart; Align alignItems_ : bitCount() = Align::Stretch; Align alignSelf_ : bitCount() = Align::Auto; @@ -753,6 +853,16 @@ class YG_EXPORT Style { Dimensions maxDimensions_{}; StyleValueHandle aspectRatio_{}; + // Grid properties + GridTrackList gridTemplateColumns_{}; + GridTrackList gridTemplateRows_{}; + GridTrackList gridAutoColumns_{}; + GridTrackList gridAutoRows_{}; + GridLine gridColumnStart_{}; + GridLine gridColumnEnd_{}; + GridLine gridRowStart_{}; + GridLine gridRowEnd_{}; + StyleValuePool pool_; }; diff --git a/yoga/style/StyleSizeLength.h b/yoga/style/StyleSizeLength.h index fc4d371e42..76e079b2da 100644 --- a/yoga/style/StyleSizeLength.h +++ b/yoga/style/StyleSizeLength.h @@ -42,6 +42,12 @@ class StyleSizeLength { : StyleSizeLength{FloatOptional{value}, Unit::Percent}; } + constexpr static StyleSizeLength stretch(float fraction) { + return yoga::isUndefined(fraction) || yoga::isinf(fraction) + ? undefined() + : StyleSizeLength{FloatOptional{fraction}, Unit::Stretch}; + } + constexpr static StyleSizeLength ofAuto() { return StyleSizeLength{{}, Unit::Auto}; } @@ -98,7 +104,7 @@ class StyleSizeLength { return value_; } - constexpr FloatOptional resolve(float referenceLength) { + constexpr FloatOptional resolve(float referenceLength) const { #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wswitch-enum"