From 5f16aaba515ccd4d4c59de29753400bda0c8724c Mon Sep 17 00:00:00 2001 From: Yunfei He Date: Sun, 16 Aug 2026 22:35:37 +0800 Subject: [PATCH 1/2] Add official Yoga compatibility tests --- .agents/docs/taffyjs-yoga-decisions.md | 10 + .agents/docs/taffyjs-yoga-reference.md | 6 + .agents/docs/technology-stack.md | 2 + tests/taffyjs-yoga-wasm/vite.config.ts | 8 +- tests/taffyjs-yoga/tsconfig.json | 2 +- tests/taffyjs-yoga/vite.config.ts | 12 +- tests/taffyjs-yoga/yoga-official.test.mts | 60 + tests/taffyjs-yoga/yoga-official/LICENSE | 21 + tests/taffyjs-yoga/yoga-official/README.md | 15 + .../yoga-official/expected-failures.ts | 137 + tests/taffyjs-yoga/yoga-official/setup.ts | 16 + .../tests/YGAlignBaselineTest.test.ts | 124 + .../tests/YGComputedBorderTest.test.ts | 27 + .../tests/YGComputedMarginTest.test.ts | 27 + .../tests/YGComputedPaddingTest.test.ts | 27 + .../yoga-official/tests/YGDirtiedTest.test.ts | 157 + .../yoga-official/tests/YGErrataTest.test.ts | 40 + .../tests/YGFlexBasisAuto.test.ts | 23 + .../tests/YGHasNewLayout.test.ts | 81 + .../tests/YGMeasureCacheTest.test.ts | 31 + .../yoga-official/tests/YGMeasureTest.test.ts | 70 + .../generated/YGAbsolutePositionTest.test.ts | 1864 +++++ .../generated/YGAlignContentTest.test.ts | 5829 +++++++++++++++ .../tests/generated/YGAlignItemsTest.test.ts | 2444 +++++++ .../tests/generated/YGAlignSelfTest.test.ts | 293 + .../tests/generated/YGAndroidNewsFeed.test.ts | 315 + .../tests/generated/YGAspectRatioTest.test.ts | 231 + .../tests/generated/YGAutoTest.test.ts | 347 + .../tests/generated/YGBorderTest.test.ts | 256 + .../tests/generated/YGBoxSizingTest.test.ts | 2747 +++++++ .../tests/generated/YGDimensionTest.test.ts | 129 + .../generated/YGDisplayContentsTest.test.ts | 109 + .../tests/generated/YGDisplayTest.test.ts | 1097 +++ .../generated/YGFlexDirectionTest.test.ts | 4562 ++++++++++++ .../tests/generated/YGFlexTest.test.ts | 677 ++ .../tests/generated/YGFlexWrapTest.test.ts | 2071 ++++++ .../tests/generated/YGGapTest.test.ts | 3303 +++++++++ .../generated/YGIntrinsicSizeTest.test.ts | 546 ++ .../generated/YGJustifyContentTest.test.ts | 2150 ++++++ .../tests/generated/YGMarginTest.test.ts | 1963 +++++ .../generated/YGMinMaxDimensionTest.test.ts | 1446 ++++ .../tests/generated/YGPaddingTest.test.ts | 354 + .../tests/generated/YGPercentageTest.test.ts | 1760 +++++ .../tests/generated/YGRoundingTest.test.ts | 1161 +++ .../generated/YGSizeOverflowTest.test.ts | 207 + .../generated/YGStaticPositionTest.test.ts | 6338 +++++++++++++++++ .../tests/tools/MeasureCounter.ts | 66 + .../yoga-official/tests/tools/utils.ts | 81 + vite.config.ts | 2 + 49 files changed, 43239 insertions(+), 5 deletions(-) create mode 100644 tests/taffyjs-yoga/yoga-official.test.mts create mode 100644 tests/taffyjs-yoga/yoga-official/LICENSE create mode 100644 tests/taffyjs-yoga/yoga-official/README.md create mode 100644 tests/taffyjs-yoga/yoga-official/expected-failures.ts create mode 100644 tests/taffyjs-yoga/yoga-official/setup.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGAlignBaselineTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGComputedBorderTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGComputedMarginTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGComputedPaddingTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGDirtiedTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGErrataTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGFlexBasisAuto.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGHasNewLayout.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGMeasureCacheTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/YGMeasureTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGAbsolutePositionTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignContentTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignItemsTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignSelfTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGAndroidNewsFeed.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGAspectRatioTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGAutoTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGBorderTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGBoxSizingTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGDimensionTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGDisplayContentsTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGDisplayTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexDirectionTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexWrapTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGGapTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGIntrinsicSizeTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGJustifyContentTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGMarginTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGMinMaxDimensionTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGPaddingTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGPercentageTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGRoundingTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGSizeOverflowTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/generated/YGStaticPositionTest.test.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/tools/MeasureCounter.ts create mode 100644 tests/taffyjs-yoga/yoga-official/tests/tools/utils.ts diff --git a/.agents/docs/taffyjs-yoga-decisions.md b/.agents/docs/taffyjs-yoga-decisions.md index e20f5de..e1f75cb 100644 --- a/.agents/docs/taffyjs-yoga-decisions.md +++ b/.agents/docs/taffyjs-yoga-decisions.md @@ -192,6 +192,16 @@ This ledger records only judgments that Yunfei explicitly expressed about `@taff **Source:** Yunfei (`@hyfdev`), 2026-08-14; required differences to be documented, accepted explicit unsupported behavior, vouched the original consolidated verification rules, and later clarified that the base design must not preselect Ink or another external consumer. +### Official Yoga compatibility corpus + +**Ruling:** Compatibility verification must run the official Yoga JavaScript test snapshot under `tests/taffyjs-yoga/yoga-official/` against every maintained Yoga backend. The directory name remains stable while the exact Yoga version, tag, and commit live in its README. Cases covered by a published Different or Unsupported classification must be registered as explicit expected failures; every other active upstream case must pass. + +**Limits:** The snapshot is a bounded regression corpus, not a compatibility percentage and not a replacement for focused TaffyJS differential, rejection, type, state, or failure-atomicity tests. Yoga's benchmarks and Chrome/Selenium generator are not part of the normal suite. The copied upstream sources stay unchanged, retain their license, and are replaced from one reviewed commit when the compatibility baseline changes. An unexpected failure or an expected failure that begins passing requires reviewing the implementation, classification, focused tests, and documentation together rather than silently changing the expected-failure list. + +**Why:** The official suite provides broad, maintained combinations of Yoga's JavaScript API and layout behavior, while the existing focused tests explain and enforce TaffyJS-specific compatibility boundaries. Keeping the version in the README avoids renaming the directory on a future baseline update. + +**Source:** Yunfei (`@hyfdev`), 2026-08-16; asked to migrate Yoga's official JavaScript tests as compatibility coverage, selected `tests/taffyjs-yoga/yoga-official/`, required the version to live in its README, and accepted the proposed pinned-snapshot and classified-failure approach. + ### Upstream work and current compatibility [VOUCHED @hyfdev 2026-08-16] diff --git a/.agents/docs/taffyjs-yoga-reference.md b/.agents/docs/taffyjs-yoga-reference.md index ef28b28..d2cc456 100644 --- a/.agents/docs/taffyjs-yoga-reference.md +++ b/.agents/docs/taffyjs-yoga-reference.md @@ -454,6 +454,12 @@ For supported APIs, @taffyjs/yoga preserves Yoga 3.2.1's published declaration s - calculateLayout requires width and height arguments in TypeScript while allowing each to be explicitly undefined; the runtime wrapper also permits the arguments to be omitted and supplies NaN, NaN, and LTR defaults. - The generic setter wrapper attempts to accept Value-like objects and comments that a getter result can be passed back to a setter, but the published Value is a plain object without a numeric valueOf implementation. A published 3.2.1 getWidth-to-setWidth round trip resets the value to Unit.Undefined rather than preserving it. +## Official Yoga compatibility corpus + +The package-boundary suite includes an unchanged snapshot of Yoga's official JavaScript tests at [`tests/taffyjs-yoga/yoga-official/`](../../tests/taffyjs-yoga/yoga-official/README.md). It runs through the same bare `yoga-layout` imports against both the native and Wasm packages. + +Cases covered by a published Different or Unsupported classification are explicit expected failures, and every other active upstream case must pass. An expected failure that begins passing is a review signal rather than a reason to silently remove it. This bounded corpus provides broad regression coverage rather than a compatibility percentage; focused local fixtures remain authoritative for the exact TaffyJS rejection or stable Different result. The snapshot README is the single source for its version, provenance, contents, counts, license, and refresh procedure. + ## Ongoing maintenance - Re-audit the complete capability matrix before deliberately adopting a Yoga version newer than 3.2.1; no supported release may contain an unclassified method, value, or result trigger. diff --git a/.agents/docs/technology-stack.md b/.agents/docs/technology-stack.md index 04a88a8..83ea8e5 100644 --- a/.agents/docs/technology-stack.md +++ b/.agents/docs/technology-stack.md @@ -26,6 +26,8 @@ The root Vite+ task graph builds the napi-rs artifacts into `packages/taffyjs-wa For `packages/taffyjs-yoga`, `vp pack` builds the root and `/load` entries plus shared chunks and declarations over the public `@taffyjs/node` dependency. Its `dist` is ignored build output: the native task graph builds it before runtime and declaration tests, and any future publication workflow must build it before packing or publishing. Test-only ambient declarations resolve authored Yoga test types to source so a clean checkout does not require `dist` without remapping the public runtime specifiers that Bun, Deno, and Node resolve; exact Vite aliases, subprocess entry injection, runtime smoke checks, and the dedicated public-declaration check still exercise the built package entries. +The Yoga consumer suite also runs the pinned official JavaScript snapshot under `tests/taffyjs-yoga/yoga-official` through exact bare-import aliases against both Yoga backends. Upstream test sources are excluded from formatting, linting, and TaffyJS type checking to preserve the reviewed snapshot; the local classifier converts only documented Different and Unsupported cases into required failures, while its manifest and setup remain normal maintained TypeScript. + For `packages/taffyjs-yoga-wasm`, Vite+ builds those same sibling source entries and redirects only the exact bare `@taffyjs/node` import to the external public `@taffyjs/wasm` dependency. The package owns no facade source and emits no second Wasm payload. Its `dist` is ignored build output; the Wasm verification graph builds it before type, package, tarball, Node, bundle, or Chromium checks. `tools/api-codegen` owns source generation that must keep Rust and TypeScript API facts aligned. Its first maintained input is `api/numeric-families.json`; `vp run codegen` updates both language outputs. CI runs `vp run check:codegen`, which regenerates and rejects any resulting Git diff. diff --git a/tests/taffyjs-yoga-wasm/vite.config.ts b/tests/taffyjs-yoga-wasm/vite.config.ts index 93f5868..7ed6089 100644 --- a/tests/taffyjs-yoga-wasm/vite.config.ts +++ b/tests/taffyjs-yoga-wasm/vite.config.ts @@ -22,9 +22,15 @@ export default defineConfig({ ], }, test: { - include: ["../taffyjs-yoga/*.test.mts"], + globals: true, + include: [ + "../taffyjs-yoga/*.test.mts", + "../taffyjs-yoga/yoga-official/tests/*.test.ts", + "../taffyjs-yoga/yoga-official/tests/generated/*.test.ts", + ], retry: 0, sequence: { concurrent: true }, + setupFiles: [resolve(import.meta.dirname, "../taffyjs-yoga/yoga-official/setup.ts")], env: { TAFFYJS_TEST_ENTRY: pathToFileURL(wasmEntry).href, TAFFYJS_YOGA_TEST_ENTRY: pathToFileURL(yogaWasmEntry).href, diff --git a/tests/taffyjs-yoga/tsconfig.json b/tests/taffyjs-yoga/tsconfig.json index b8e9546..8f88f0a 100644 --- a/tests/taffyjs-yoga/tsconfig.json +++ b/tests/taffyjs-yoga/tsconfig.json @@ -19,5 +19,5 @@ "verbatimModuleSyntax": true, "skipLibCheck": true }, - "include": ["*.test.mts", "vite.config.ts", "yoga-layout-source.d.ts"] + "include": ["*.test.mts", "vite.config.ts", "yoga-layout-source.d.ts", "yoga-official/*.ts"] } diff --git a/tests/taffyjs-yoga/vite.config.ts b/tests/taffyjs-yoga/vite.config.ts index 84434e8..4ce94fe 100644 --- a/tests/taffyjs-yoga/vite.config.ts +++ b/tests/taffyjs-yoga/vite.config.ts @@ -6,9 +6,9 @@ const yogaEntry = resolve(import.meta.dirname, "../../packages/taffyjs-yoga/dist const yogaLoadEntry = resolve(import.meta.dirname, "../../packages/taffyjs-yoga/dist/load.js"); export default defineConfig({ - fmt: {}, + fmt: { ignorePatterns: ["yoga-official/tests"] }, lint: { - ignorePatterns: ["types/public-api.test-d.ts"], + ignorePatterns: ["types/public-api.test-d.ts", "yoga-official/tests"], options: { typeAware: true, typeCheck: true, @@ -27,8 +27,14 @@ export default defineConfig({ ], }, test: { - include: ["*.test.mts"], + globals: true, + include: [ + "*.test.mts", + "yoga-official/tests/*.test.ts", + "yoga-official/tests/generated/*.test.ts", + ], retry: 0, sequence: { concurrent: true }, + setupFiles: [resolve(import.meta.dirname, "yoga-official/setup.ts")], }, }); diff --git a/tests/taffyjs-yoga/yoga-official.test.mts b/tests/taffyjs-yoga/yoga-official.test.mts new file mode 100644 index 0000000..255a338 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official.test.mts @@ -0,0 +1,60 @@ +import assert from "node:assert/strict"; +import { readFile, readdir } from "node:fs/promises"; + +import { test } from "vite-plus/test"; + +import { + expectedFailureByTitle, + expectedFailureGroups, +} from "./yoga-official/expected-failures.ts"; + +const officialTestRoot = new URL("./yoga-official/tests/", import.meta.url); + +test("official Yoga snapshot and expected failures stay aligned", async () => { + const files = ( + await Promise.all( + [new URL(".", officialTestRoot), new URL("generated/", officialTestRoot)].map( + async (directory) => + (await readdir(directory)) + .filter((name) => name.endsWith(".test.ts")) + .map((name) => new URL(name, directory)), + ), + ) + ).flat(); + const titleCounts = new Map(); + let caseCount = 0; + let skippedCount = 0; + const testPattern = /^test(?\.skip)?\('(?[^']+)'/gmu; + + for (const file of files) { + const source = await readFile(file, "utf8"); + for (const match of source.matchAll(testPattern)) { + const title = match.groups?.title; + assert.ok(title, `missing test title in ${file.pathname}`); + caseCount += 1; + if (match.groups?.skipped !== undefined) skippedCount += 1; + titleCounts.set(title, (titleCounts.get(title) ?? 0) + 1); + } + } + + assert.equal(files.length, 35); + assert.equal(caseCount, 570); + assert.equal(skippedCount, 17); + assert.equal(expectedFailureByTitle.size, 85); + assert.equal( + expectedFailureGroups + .filter((group) => group.classification === "unsupported") + .flatMap((group) => group.titles).length, + 77, + ); + assert.equal( + expectedFailureGroups + .filter((group) => group.classification === "different") + .flatMap((group) => group.titles).length, + 8, + ); + + for (const title of expectedFailureByTitle.keys()) { + assert.equal(titleCounts.get(title), 1, `expected one official test named ${title}`); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/LICENSE b/tests/taffyjs-yoga/yoga-official/LICENSE new file mode 100644 index 0000000..b96dcb0 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Facebook, Inc. and its affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tests/taffyjs-yoga/yoga-official/README.md b/tests/taffyjs-yoga/yoga-official/README.md new file mode 100644 index 0000000..02504b1 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/README.md @@ -0,0 +1,15 @@ +# Yoga official tests + +`tests/` is an unmodified snapshot of Yoga's official JavaScript test sources. TaffyJS runs the snapshot through the public `yoga-layout` alias against both `@taffyjs/yoga` and `@taffyjs/yoga-wasm`. + +- Source repository: [react/yoga](https://github.com/react/yoga) +- Tag: [`v3.2.1`](https://github.com/react/yoga/tree/v3.2.1) +- Commit: [`042f5013152eb81c1552dec945b88f7b95ca350f`](https://github.com/react/yoga/commit/042f5013152eb81c1552dec945b88f7b95ca350f) +- Included upstream paths: the ten handwritten `javascript/tests/*.test.ts` files, all twenty-five `javascript/tests/generated/*.test.ts` files, and their two required helpers +- Excluded upstream paths: benchmarks, the benchmark runner, and the unused benchmark-global helper + +The snapshot contains 570 cases. Yoga 3.2.1 marks 17 of them skipped. `expected-failures.ts` classifies the 85 remaining cases that intentionally cannot pass under the published TaffyJS compatibility boundary: 77 exercise Unsupported capabilities and 8 exercise Known Differences. Vitest treats those cases as required failures, so an unexpected failure or an expected failure that starts passing both stop the suite and require a compatibility review. The maintained TaffyJS tests remain responsible for asserting the exact replacement behavior of Different and Unsupported cases. + +Do not edit files under `tests/` by hand. A Yoga baseline update replaces this snapshot from one reviewed upstream commit, updates the source metadata and expected-failure classifications together, and reruns both backends. Do not copy Yoga's Chrome/Selenium generator into the normal test path; committed generated tests are the stable input. + +The copied sources retain their Meta copyright headers. Yoga's complete MIT license is in [LICENSE](LICENSE). diff --git a/tests/taffyjs-yoga/yoga-official/expected-failures.ts b/tests/taffyjs-yoga/yoga-official/expected-failures.ts new file mode 100644 index 0000000..0d592a5 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/expected-failures.ts @@ -0,0 +1,137 @@ +export interface ExpectedFailureGroup { + readonly classification: "different" | "unsupported"; + readonly capability: string; + readonly titles: readonly string[]; +} + +export const expectedFailureGroups = [ + { + classification: "unsupported", + capability: "PositionType.Static", + titles: [ + "absolute_layout_padding", + "absolute_layout_border", + "box_sizing_content_box_comtaining_block", + "box_sizing_border_box_comtaining_block", + "static_position_insets_have_no_effect_left_top", + "static_position_insets_have_no_effect_right_bottom", + "static_position_absolute_child_insets_relative_to_positioned_ancestor", + "static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse", + "column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse", + "static_position_absolute_child_insets_relative_to_positioned_ancestor_row", + "column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row", + "static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse", + "column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse", + "static_position_absolute_child_insets_relative_to_positioned_ancestor_deep", + "static_position_absolute_child_width_percentage", + "static_position_relative_child_width_percentage", + "static_position_static_child_width_percentage", + "static_position_absolute_child_height_percentage", + "static_position_relative_child_height_percentage", + "static_position_static_child_height_percentage", + "static_position_absolute_child_left_percentage", + "static_position_relative_child_left_percentage", + "static_position_static_child_left_percentage", + "static_position_absolute_child_right_percentage", + "static_position_relative_child_right_percentage", + "static_position_static_child_right_percentage", + "static_position_absolute_child_top_percentage", + "static_position_relative_child_top_percentage", + "static_position_static_child_top_percentage", + "static_position_absolute_child_bottom_percentage", + "static_position_relative_child_bottom_percentage", + "static_position_static_child_bottom_percentage", + "static_position_absolute_child_margin_percentage", + "static_position_relative_child_margin_percentage", + "static_position_static_child_margin_percentage", + "static_position_absolute_child_padding_percentage", + "static_position_relative_child_padding_percentage", + "static_position_static_child_padding_percentage", + "static_position_absolute_child_border_percentage", + "static_position_relative_child_border_percentage", + "static_position_static_child_border_percentage", + "static_position_absolute_child_containing_block_padding_box", + "static_position_relative_child_containing_block_padding_box", + "static_position_static_child_containing_block_padding_box", + "static_position_static_child_containing_block_content_box", + "static_position_containing_block_padding_and_border", + "static_position_amalgamation", + "static_position_no_position_amalgamation", + "static_position_zero_for_inset_amalgamation", + "static_position_start_inset_amalgamation", + "static_position_end_inset_amalgamation", + "static_position_row_reverse_amalgamation", + "static_position_column_reverse_amalgamation", + "static_position_justify_flex_start_amalgamation", + "static_position_justify_flex_start_position_set_amalgamation", + "static_position_no_definite_size_amalgamation", + "static_position_both_insets_set_amalgamation", + "static_position_justify_center_amalgamation", + "static_position_justify_flex_end_amalgamation", + "static_position_align_flex_start_amalgamation", + "static_position_align_center_amalgamation", + "static_position_align_flex_end_amalgamation", + "static_position_static_root", + "static_position_absolute_child_multiple", + ], + }, + { + classification: "unsupported", + capability: "Display.Contents", + titles: [ + "test1", + "display_contents", + "display_contents_fixed_size", + "display_contents_with_margin", + "display_contents_with_padding", + "display_contents_with_position", + "display_contents_with_position_absolute", + "display_contents_nested", + "display_contents_with_siblings", + ], + }, + { + classification: "unsupported", + capability: "nonzero Yoga Errata", + titles: ["errata_all_contains_example_errata", "errata_is_settable"], + }, + { + classification: "unsupported", + capability: "setIsReferenceBaseline(true)", + titles: [ + "align_baseline_parent_using_child_in_column_as_reference", + "align_baseline_parent_using_child_in_row_as_reference", + ], + }, + { + classification: "different", + capability: "Measure callback count and phase trace", + titles: [ + "measure_once_single_flexible_child", + "dont_measure_single_grow_shrink_child", + "dont_fail_with_incomplete_measure_dimensions", + ], + }, + { + classification: "different", + capability: "main-axis auto-margin distribution", + titles: [ + "margin_auto_bottom_and_top_justify_center", + "margin_auto_left_right_child_bigger_than_parent", + "margin_auto_left_child_bigger_than_parent", + "margin_fix_left_auto_right_child_bigger_than_parent", + "margin_auto_left_fix_right_child_bigger_than_parent", + ], + }, +] as const satisfies readonly ExpectedFailureGroup[]; + +export const expectedFailureByTitle = new Map<string, ExpectedFailureGroup>(); + +for (const group of expectedFailureGroups) { + for (const title of group.titles) { + if (expectedFailureByTitle.has(title)) { + throw new Error(`Duplicate Yoga official expected failure: ${title}`); + } + expectedFailureByTitle.set(title, group); + } +} diff --git a/tests/taffyjs-yoga/yoga-official/setup.ts b/tests/taffyjs-yoga/yoga-official/setup.ts new file mode 100644 index 0000000..607364a --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/setup.ts @@ -0,0 +1,16 @@ +import { test } from "vite-plus/test"; + +import { expectedFailureByTitle } from "./expected-failures.ts"; + +type OfficialTestCallback = () => void | Promise<void>; + +const classifiedTest = ((title: string, callback: OfficialTestCallback, timeout?: number) => { + const register = expectedFailureByTitle.has(title) ? test.fails : test; + register(title, callback, timeout); +}) as typeof test; + +Object.defineProperty(classifiedTest, "skip", { value: test.skip }); + +if (!Reflect.set(globalThis, "test", classifiedTest)) { + throw new Error("Unable to install the Yoga official test classifier"); +} diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGAlignBaselineTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGAlignBaselineTest.test.ts new file mode 100644 index 0000000..fd03ddf --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGAlignBaselineTest.test.ts @@ -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. + */ + +import Yoga from 'yoga-layout'; + +test('align_baseline_parent_using_child_in_column_as_reference', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); + root.setWidth(1000); + root.setHeight(1000); + root.setAlignItems(Yoga.ALIGN_BASELINE); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child0.setWidth(500); + root_child0.setHeight(600); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1.setWidth(500); + root_child1.setHeight(800); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1_child0.setWidth(500); + root_child1_child0.setHeight(300); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1_child1.setWidth(500); + root_child1_child1.setHeight(400); + root_child1_child1.setIsReferenceBaseline(true); + root_child1.insertChild(root_child1_child1, 1); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(500); + expect(root_child1.getComputedTop()).toBe(0); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(300); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); + +test('align_baseline_parent_using_child_in_row_as_reference', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); + root.setWidth(1000); + root.setHeight(1000); + root.setAlignItems(Yoga.ALIGN_BASELINE); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child0.setWidth(500); + root_child0.setHeight(600); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); + root_child1.setWidth(500); + root_child1.setHeight(800); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1_child0.setWidth(500); + root_child1_child0.setHeight(500); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setFlexDirection(Yoga.FLEX_DIRECTION_COLUMN); + root_child1_child1.setWidth(500); + root_child1_child1.setHeight(400); + root_child1_child1.setIsReferenceBaseline(true); + root_child1.insertChild(root_child1_child1, 1); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(500); + expect(root_child1.getComputedTop()).toBe(200); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + + expect(root_child1_child1.getComputedLeft()).toBe(500); + expect(root_child1_child1.getComputedTop()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGComputedBorderTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGComputedBorderTest.test.ts new file mode 100644 index 0000000..09e98f6 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGComputedBorderTest.test.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import Yoga from 'yoga-layout'; + +test('border_start', () => { + const root = Yoga.Node.create(); + root.setWidth(100); + root.setHeight(100); + root.setBorder(Yoga.EDGE_START, 10); + + root.calculateLayout(100, 100, Yoga.DIRECTION_LTR); + + expect(root.getComputedBorder(Yoga.EDGE_LEFT)).toBe(10); + expect(root.getComputedBorder(Yoga.EDGE_RIGHT)).toBe(0); + + root.calculateLayout(100, 100, Yoga.DIRECTION_RTL); + + expect(root.getComputedBorder(Yoga.EDGE_LEFT)).toBe(0); + expect(root.getComputedBorder(Yoga.EDGE_RIGHT)).toBe(10); + + root.freeRecursive(); +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGComputedMarginTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGComputedMarginTest.test.ts new file mode 100644 index 0000000..3b3944e --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGComputedMarginTest.test.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import Yoga from 'yoga-layout'; + +test('margin_start', () => { + const root = Yoga.Node.create(); + root.setWidth(100); + root.setHeight(100); + root.setMargin(Yoga.EDGE_START, `10%`); + + root.calculateLayout(100, 100, Yoga.DIRECTION_LTR); + + expect(root.getComputedMargin(Yoga.EDGE_LEFT)).toBe(10); + expect(root.getComputedMargin(Yoga.EDGE_RIGHT)).toBe(0); + + root.calculateLayout(100, 100, Yoga.DIRECTION_RTL); + + expect(root.getComputedMargin(Yoga.EDGE_LEFT)).toBe(0); + expect(root.getComputedMargin(Yoga.EDGE_RIGHT)).toBe(10); + + root.freeRecursive(); +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGComputedPaddingTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGComputedPaddingTest.test.ts new file mode 100644 index 0000000..75653f2 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGComputedPaddingTest.test.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import Yoga from 'yoga-layout'; + +test('padding_start', () => { + const root = Yoga.Node.create(); + root.setWidth(100); + root.setHeight(100); + root.setPadding(Yoga.EDGE_START, `10%`); + + root.calculateLayout(100, 100, Yoga.DIRECTION_LTR); + + expect(root.getComputedPadding(Yoga.EDGE_LEFT)).toBe(10); + expect(root.getComputedPadding(Yoga.EDGE_RIGHT)).toBe(0); + + root.calculateLayout(100, 100, Yoga.DIRECTION_RTL); + + expect(root.getComputedPadding(Yoga.EDGE_LEFT)).toBe(0); + expect(root.getComputedPadding(Yoga.EDGE_RIGHT)).toBe(10); + + root.freeRecursive(); +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGDirtiedTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGDirtiedTest.test.ts new file mode 100644 index 0000000..6d2fa67 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGDirtiedTest.test.ts @@ -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. + */ + +import Yoga from 'yoga-layout'; + +test('dirtied', () => { + const root = Yoga.Node.create(); + root.setAlignItems(Yoga.ALIGN_FLEX_START); + root.setWidth(100); + root.setHeight(100); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + let dirtied = 0; + root.setDirtiedFunc(() => { + dirtied++; + }); + + // only nodes with a measure function can be marked dirty + root.setMeasureFunc(() => ({width: 0, height: 0})); + + expect(dirtied).toBe(0); + + // dirtied func MUST be called in case of explicit dirtying. + root.markDirty(); + expect(dirtied).toBe(1); + + // dirtied func MUST be called ONCE. + root.markDirty(); + expect(dirtied).toBe(1); + + root.freeRecursive(); +}); + +test('dirtied_propagation', () => { + const root = Yoga.Node.create(); + root.setAlignItems(Yoga.ALIGN_FLEX_START); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(); + root_child0.setAlignItems(Yoga.ALIGN_FLEX_START); + root_child0.setWidth(50); + root_child0.setHeight(20); + root_child0.setMeasureFunc(() => ({width: 0, height: 0})); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(); + root_child1.setAlignItems(Yoga.ALIGN_FLEX_START); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 0); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + let dirtied = 0; + root.setDirtiedFunc(() => { + dirtied++; + }); + + expect(dirtied).toBe(0); + + // dirtied func MUST be called for the first time. + root_child0.markDirty(); + expect(dirtied).toBe(1); + + // dirtied func must NOT be called for the second time. + root_child0.markDirty(); + expect(dirtied).toBe(1); + + root.freeRecursive(); +}); + +test('dirtied_hierarchy', () => { + const root = Yoga.Node.create(); + root.setAlignItems(Yoga.ALIGN_FLEX_START); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(); + root_child0.setAlignItems(Yoga.ALIGN_FLEX_START); + root_child0.setWidth(50); + root_child0.setHeight(20); + root_child0.setMeasureFunc(() => ({width: 0, height: 0})); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(); + root_child1.setAlignItems(Yoga.ALIGN_FLEX_START); + root_child1.setWidth(50); + root_child1.setHeight(20); + root_child0.setMeasureFunc(() => ({width: 0, height: 0})); + root.insertChild(root_child1, 0); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + let dirtied = 0; + root_child0.setDirtiedFunc(() => { + dirtied++; + }); + + expect(dirtied).toBe(0); + + // dirtied func must NOT be called for descendants. + // NOTE: nodes without a measure function cannot be marked dirty manually, + // but nodes with a measure function can not have children. + // Update the width to dirty the node instead. + root.setWidth(110); + expect(dirtied).toBe(0); + + // dirtied func MUST be called in case of explicit dirtying. + root_child0.markDirty(); + expect(dirtied).toBe(1); + + root.freeRecursive(); +}); + +test('dirtied_reset', () => { + const root = Yoga.Node.create(); + root.setAlignItems(Yoga.ALIGN_FLEX_START); + root.setWidth(100); + root.setHeight(100); + root.setMeasureFunc(() => ({width: 0, height: 0})); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + let dirtied = 0; + root.setDirtiedFunc(() => { + dirtied++; + }); + + expect(dirtied).toBe(0); + + // dirtied func MUST be called in case of explicit dirtying. + root.markDirty(); + expect(dirtied).toBe(1); + + // recalculate so the root is no longer dirty + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + root.reset(); + root.setAlignItems(Yoga.ALIGN_FLEX_START); + root.setWidth(100); + root.setHeight(100); + root.setMeasureFunc(() => ({width: 0, height: 0})); + + root.markDirty(); + + // dirtied func must NOT be called after reset. + root.markDirty(); + expect(dirtied).toBe(1); + + root.freeRecursive(); +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGErrataTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGErrataTest.test.ts new file mode 100644 index 0000000..da186fc --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGErrataTest.test.ts @@ -0,0 +1,40 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import Yoga from 'yoga-layout'; + +test('errata_all_contains_example_errata', () => { + const config = Yoga.Config.create(); + config.setErrata(Yoga.ERRATA_ALL); + + expect(config.getErrata()).toBe(Yoga.ERRATA_ALL); + expect(config.getErrata() & Yoga.ERRATA_STRETCH_FLEX_BASIS).not.toBe(0); + + config.free(); +}); + +test('errata_none_omits_example_errata', () => { + const config = Yoga.Config.create(); + config.setErrata(Yoga.ERRATA_NONE); + + expect(config.getErrata()).toBe(Yoga.ERRATA_NONE); + expect(config.getErrata() & Yoga.ERRATA_STRETCH_FLEX_BASIS).toBe(0); + + config.free(); +}); + +test('errata_is_settable', () => { + const config = Yoga.Config.create(); + + config.setErrata(Yoga.ERRATA_ALL); + expect(config.getErrata()).toBe(Yoga.ERRATA_ALL); + + config.setErrata(Yoga.ERRATA_NONE); + expect(config.getErrata()).toBe(Yoga.ERRATA_NONE); + + config.free(); +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGFlexBasisAuto.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGFlexBasisAuto.test.ts new file mode 100644 index 0000000..d6e28d6 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGFlexBasisAuto.test.ts @@ -0,0 +1,23 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import Yoga from 'yoga-layout'; + +test('flex_basis_auto', () => { + const root = Yoga.Node.create(); + + expect(root.getFlexBasis().unit).toBe(Yoga.UNIT_AUTO); + + root.setFlexBasis(10); + expect(root.getFlexBasis().unit).toBe(Yoga.UNIT_POINT); + expect(root.getFlexBasis().value).toBe(10); + + root.setFlexBasisAuto(); + expect(root.getFlexBasis().unit).toBe(Yoga.UNIT_AUTO); + + root.freeRecursive(); +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGHasNewLayout.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGHasNewLayout.test.ts new file mode 100644 index 0000000..643823c --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGHasNewLayout.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. + */ + +import Yoga from 'yoga-layout'; + +test('new_layout_can_be_marked_seen', () => { + const root = Yoga.Node.create(); + root.markLayoutSeen(); + expect(root.hasNewLayout()).toBe(false); +}); + +test('new_layout_calculating_layout_marks_layout_as_unseen', () => { + const root = Yoga.Node.create(); + root.markLayoutSeen(); + root.calculateLayout(undefined, undefined); + expect(root.hasNewLayout()).toBe(true); +}); + +test('new_layout_calculated_layout_can_be_marked_seen', () => { + const root = Yoga.Node.create(); + root.calculateLayout(undefined, undefined); + root.markLayoutSeen(); + expect(root.hasNewLayout()).toBe(false); +}); + +test('new_layout_recalculating_layout_does_mark_as_unseen', () => { + const root = Yoga.Node.create(); + root.calculateLayout(undefined, undefined); + root.markLayoutSeen(); + root.calculateLayout(undefined, undefined); + expect(root.hasNewLayout()).toBe(true); +}); + +test('new_layout_reset_also_resets_layout_seen', () => { + const root = Yoga.Node.create(); + root.markLayoutSeen(); + root.reset(); + expect(root.hasNewLayout()).toBe(true); +}); + +test('new_layout_children_sets_new_layout', () => { + const root = Yoga.Node.create(); + root.setAlignItems(Yoga.ALIGN_FLEX_START); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(); + root_child0.setAlignItems(Yoga.ALIGN_FLEX_START); + root_child0.setWidth(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(); + root_child1.setAlignItems(Yoga.ALIGN_FLEX_START); + root_child1.setWidth(50); + root_child1.setHeight(20); + root.insertChild(root_child1, 0); + + expect(root.hasNewLayout()).toEqual(true); + expect(root_child0.hasNewLayout()).toEqual(true); + expect(root_child1.hasNewLayout()).toEqual(true); + + root.markLayoutSeen(); + root_child0.markLayoutSeen(); + root_child1.markLayoutSeen(); + + expect(root.hasNewLayout()).toEqual(false); + expect(root_child0.hasNewLayout()).toEqual(false); + expect(root_child1.hasNewLayout()).toEqual(false); + + root_child1.setHeight(30); + root.calculateLayout(undefined, undefined); + + expect(root.hasNewLayout()).toEqual(true); + expect(root_child0.hasNewLayout()).toEqual(true); + expect(root_child1.hasNewLayout()).toEqual(true); +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGMeasureCacheTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGMeasureCacheTest.test.ts new file mode 100644 index 0000000..4a95d1c --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGMeasureCacheTest.test.ts @@ -0,0 +1,31 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import Yoga from 'yoga-layout'; + +import {getMeasureCounterMax} from './tools/MeasureCounter.ts'; + +test('measure_once_single_flexible_child', () => { + const root = Yoga.Node.create(); + root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW); + root.setAlignItems(Yoga.ALIGN_FLEX_START); + root.setWidth(100); + root.setHeight(100); + + const measureCounter = getMeasureCounterMax(); + + const root_child0 = Yoga.Node.create(); + root_child0.setMeasureFunc(measureCounter.inc); + root_child0.setFlexGrow(1); + root.insertChild(root_child0, 0); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + expect(measureCounter.get()).toBe(1); + + root.freeRecursive(); +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/YGMeasureTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/YGMeasureTest.test.ts new file mode 100644 index 0000000..941d424 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/YGMeasureTest.test.ts @@ -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. + */ + +import Yoga from 'yoga-layout'; +import {getMeasureCounter} from './tools/MeasureCounter.ts'; + +test('dont_measure_single_grow_shrink_child', () => { + const root = Yoga.Node.create(); + root.setWidth(100); + root.setHeight(100); + + const measureCounter = getMeasureCounter(null, 100, 100); + + const root_child0 = Yoga.Node.create(); + root_child0.setMeasureFunc(measureCounter.inc); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + expect(measureCounter.get()).toBe(0); + + root.freeRecursive(); +}); + +test('dont_fail_with_incomplete_measure_dimensions', () => { + // @ts-expect-error Testing bad usage + const heightOnlyCallback = getMeasureCounter(() => ({height: 10})); + // @ts-expect-error Testing bad usage + const widthOnlyCallback = getMeasureCounter(() => ({width: 10})); + // @ts-expect-error Testing bad usage + const emptyCallback = getMeasureCounter(() => ({})); + + const root = Yoga.Node.create(); + root.setWidth(100); + root.setHeight(100); + + const node1 = Yoga.Node.create(); + const node2 = Yoga.Node.create(); + const node3 = Yoga.Node.create(); + + root.insertChild(node1, root.getChildCount()); + root.insertChild(node2, root.getChildCount()); + root.insertChild(node3, root.getChildCount()); + + node1.setMeasureFunc(heightOnlyCallback.inc); + node2.setMeasureFunc(widthOnlyCallback.inc); + node3.setMeasureFunc(emptyCallback.inc); + + root.calculateLayout(undefined, undefined, Yoga.DIRECTION_LTR); + + expect(heightOnlyCallback.get()).toBe(1); + expect(widthOnlyCallback.get()).toBe(1); + expect(emptyCallback.get()).toBe(1); + + expect(node1.getComputedWidth()).toBe(100); + expect(node1.getComputedHeight()).toBe(10); + + expect(node2.getComputedWidth()).toBe(100); + expect(node2.getComputedHeight()).toBe(0); + + expect(node3.getComputedWidth()).toBe(100); + expect(node3.getComputedHeight()).toBe(0); + + root.freeRecursive(); +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGAbsolutePositionTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAbsolutePositionTest.test.ts new file mode 100644 index 0000000..694086e --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAbsolutePositionTest.test.ts @@ -0,0 +1,1864 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('absolute_layout_width_height_start_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Start, 10); + root_child0.setPosition(Edge.Top, 10); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_width_height_left_auto_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPositionAuto(Edge.Left); + root_child0.setPosition(Edge.Right, 10); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_width_height_left_right_auto', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 10); + root_child0.setPositionAuto(Edge.Right); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_width_height_left_auto_right_auto', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPositionAuto(Edge.Left); + root_child0.setPositionAuto(Edge.Right); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_width_height_end_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.End, 10); + root_child0.setPosition(Edge.Bottom, 10); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_start_top_end_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Start, 10); + root_child0.setPosition(Edge.Top, 10); + root_child0.setPosition(Edge.End, 10); + root_child0.setPosition(Edge.Bottom, 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.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(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_width_height_start_top_end_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Start, 10); + root_child0.setPosition(Edge.Top, 10); + root_child0.setPosition(Edge.End, 10); + root_child0.setPosition(Edge.Bottom, 10); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setOverflow(Overflow.Hidden); + root.setWidth(50); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Start, 0); + root_child0.setPosition(Edge.Top, 0); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + 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(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(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_within_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Left, 10); + root.setMargin(Edge.Top, 10); + root.setMargin(Edge.Right, 10); + root.setMargin(Edge.Bottom, 10); + 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); + + 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(10); + expect(root.getComputedTop()).toBe(10); + 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(10); + expect(root.getComputedTop()).toBe(10); + 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(); + } +}); +test('absolute_layout_align_items_and_justify_content_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + 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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_align_items_and_justify_content_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.FlexEnd); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(60); + 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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_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.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + 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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_align_items_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + 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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_align_items_center_on_child_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Center); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(60); + root_child0.setHeight(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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + 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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_align_items_and_justify_content_center_and_top_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, 10); + root_child0.setWidth(60); + root_child0.setHeight(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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(60); + 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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_align_items_and_justify_content_center_and_bottom_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Bottom, 10); + root_child0.setWidth(60); + root_child0.setHeight(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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(60); + 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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_align_items_and_justify_content_center_and_left_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 5); + root_child0.setWidth(60); + root_child0.setHeight(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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + 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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_align_items_and_justify_content_center_and_right_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(110); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Right, 5); + root_child0.setWidth(60); + root_child0.setHeight(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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + 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(110); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('position_root_with_rtl_should_position_withoutdirection', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPosition(Edge.Left, 72); + root.setWidth(52); + root.setHeight(52); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(72); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(72); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_percentage_bottom_based_on_parent_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Top, "50%"); + root_child0.setWidth(10); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Bottom, "50%"); + root_child1.setWidth(10); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setPositionType(PositionType.Absolute); + root_child2.setPosition(Edge.Top, "10%"); + root_child2.setPosition(Edge.Bottom, "10%"); + root_child2.setWidth(10); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(160); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_in_wrap_reverse_column_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + 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(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + 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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_in_wrap_reverse_row_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + 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(80); + expect(root_child0.getComputedWidth()).toBe(20); + 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(80); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_in_wrap_reverse_column_container_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + 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(20); + 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(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_in_wrap_reverse_row_container_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(20); + root_child0.setHeight(20); + 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(20); + 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(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percent_absolute_position_infinite_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(300); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPositionType(PositionType.Absolute); + root_child1.setPosition(Edge.Left, "20%"); + root_child1.setPosition(Edge.Top, "20%"); + root_child1.setWidth("20%"); + 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(300); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + 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(300); + expect(root.getComputedHeight()).toBe(0); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(300); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_percentage_height_based_on_padded_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Top, 10); + root.setBorder(Edge.Top, 10); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(100); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(45); + + 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(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(45); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_percentage_height_based_on_padded_parent_and_align_items_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(100); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(25); + 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(25); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_padding_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 100); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(100); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(150); + 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(); + } +}); +test('absolute_layout_padding_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Right, 100); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + 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); + + 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(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(); + } +}); +test('absolute_layout_padding_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Top, 100); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_padding_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Bottom, 100); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + 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); + + 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(150); + 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(); + } +}); +test('absolute_layout_padding', () => { + 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.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(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setPadding(Edge.Left, 50); + root_child0_child0.setPadding(Edge.Top, 50); + root_child0_child0.setPadding(Edge.Right, 50); + root_child0_child0.setPadding(Edge.Bottom, 50); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(220); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(220); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_border', () => { + 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.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(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setBorder(Edge.Left, 10); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 10); + root_child0_child0.setBorder(Edge.Bottom, 10); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(220); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(220); + expect(root.getComputedHeight()).toBe(220); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(140); + expect(root_child0_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('absolute_layout_column_reverse_margin_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, 5); + root_child0.setPosition(Edge.Right, 3); + root_child0.setMargin(Edge.Left, 3); + root_child0.setMargin(Edge.Right, 4); + root_child0.setBorder(Edge.Left, 1); + root_child0.setBorder(Edge.Right, 7); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(8); + expect(root_child0.getComputedTop()).toBe(150); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(143); + expect(root_child0.getComputedTop()).toBe(150); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignContentTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignContentTest.test.ts new file mode 100644 index 0000000..aecef1a --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignContentTest.test.ts @@ -0,0 +1,5829 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<ae2a56d91c60e30ea10b12d6d143ff73>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('align_content_flex_start_nowrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_start_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_start_wrap_singleline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_start_wrapped_negative_space', () => { + 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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_start_wrapped_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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_start_without_height_on_children', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(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(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(50); + 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(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(0); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_start_with_flex', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("0%"); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexBasis("0%"); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root_child3.setFlexShrink(1); + root_child3.setFlexBasis("0%"); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(100); + expect(root.getComputedHeight()).toBe(120); + + 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_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(120); + expect(root_child4.getComputedWidth()).toBe(50); + 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(100); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(120); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_end_nowrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_end_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(90); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.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(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(90); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_end_wrap_singleline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(110); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(110); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(110); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_end_wrapped_negative_space', () => { + 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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.FlexEnd); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_end_wrapped_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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.FlexEnd); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-70); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-40); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-70); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-40); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(-10); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_center_nowrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_center_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(45); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(45); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(65); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(45); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(45); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(65); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_center_wrap_singleline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_center_wrapped_negative_space', () => { + 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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.Center); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-25); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-5); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(15); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-25); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-5); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(15); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_center_wrapped_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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.Center); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-35); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-5); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(25); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(-35); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(-5); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(25); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_between_nowrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_between_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_between_wrap_singleline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_between_wrapped_negative_space', () => { + 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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceBetween); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_between_wrapped_negative_space_row_reverse', () => { + 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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceBetween); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_between_wrapped_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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceBetween); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around_nowrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(15); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(95); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(15); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(95); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around_wrap_singleline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around_wrapped_negative_space', () => { + 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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceAround); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around_wrapped_negative_space_row_reverse', () => { + 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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceAround); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around_wrapped_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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceAround); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_nowrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(10); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + root_child4.setHeight(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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(23); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(23); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(88); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(23); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(23); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(55); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(10); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(55); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(88); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_wrap_singleline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(140); + root.setHeight(120); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(10); + 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(140); + expect(root.getComputedHeight()).toBe(120); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + + 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(90); + expect(root_child0.getComputedTop()).toBe(55); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_wrapped_negative_space', () => { + 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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceEvenly); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(20); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(40); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_wrapped_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(320); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.Center); + root_child0.setAlignContent(Align.SpaceEvenly); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setHeight(10); + root_child0.setGap(Gutter.Column, 10); + root_child0.setGap(Gutter.Row, 10); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("80%"); + root_child0_child0.setHeight(20); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth("80%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth("80%"); + root_child0_child2.setHeight(20); + 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(320); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_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(320); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(60); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child1.getComputedLeft()).toBe(20); + expect(root_child0_child1.getComputedTop()).toBe(30); + expect(root_child0_child1.getComputedWidth()).toBe(160); + expect(root_child0_child1.getComputedHeight()).toBe(20); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(60); + expect(root_child0_child2.getComputedWidth()).toBe(160); + expect(root_child0_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('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.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + 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(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + 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(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + 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(0); + 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(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row_with_children', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0.insertChild(root_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + 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(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + 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(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + 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(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row_with_flex', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root_child3.setFlexShrink(1); + root_child3.setFlexBasis("0%"); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(0); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + 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(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + 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(0); + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row_with_flex_no_shrink', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root_child3.setFlexBasis("0%"); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(0); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(0); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + 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(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + 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(0); + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row_with_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Left, 10); + root_child1.setMargin(Edge.Top, 10); + root_child1.setMargin(Edge.Right, 10); + root_child1.setMargin(Edge.Bottom, 10); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + 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_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(40); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(40); + + expect(root_child3.getComputedLeft()).toBe(40); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(100); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row_with_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + root_child1.setWidth(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setPadding(Edge.Left, 10); + root_child3.setPadding(Edge.Top, 10); + root_child3.setPadding(Edge.Right, 10); + root_child3.setPadding(Edge.Bottom, 10); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + 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(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + 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(0); + 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(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row_with_single_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + 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(150); + 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(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(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + 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(50); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row_with_fixed_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(80); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(60); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(80); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row_with_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setMaxHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + 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(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + 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(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(50); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(50); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_row_with_min_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setMinHeight(80); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(50); + 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(150); + 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(90); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(90); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(90); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(90); + + expect(root_child3.getComputedLeft()).toBe(100); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(10); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(90); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(150); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0.insertChild(root_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setHeight(50); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setHeight(50); + 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(100); + expect(root.getComputedHeight()).toBe(150); + + 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(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + 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(100); + expect(root.getComputedHeight()).toBe(150); + + 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(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + expect(root_child3.getComputedLeft()).toBe(50); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(50); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(50); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_is_not_overriding_align_items', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setAlignContent(Align.Stretch); + root_child0.setAlignItems(Align.Center); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + 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(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(45); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(45); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_with_min_cross_axis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMinHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(400); + 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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_with_max_cross_axis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + 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(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_with_max_cross_axis_and_border_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 2); + root.setPadding(Edge.Top, 2); + root.setPadding(Edge.Right, 2); + root.setPadding(Edge.Bottom, 2); + root.setBorder(Edge.Left, 5); + root.setBorder(Edge.Top, 5); + root.setBorder(Edge.Right, 5); + root.setBorder(Edge.Bottom, 5); + root.setWidth(500); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + 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(414); + + expect(root_child0.getComputedLeft()).toBe(7); + expect(root_child0.getComputedTop()).toBe(7); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(7); + expect(root_child1.getComputedTop()).toBe(207); + expect(root_child1.getComputedWidth()).toBe(400); + 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(500); + expect(root.getComputedHeight()).toBe(414); + + expect(root_child0.getComputedLeft()).toBe(93); + expect(root_child0.getComputedTop()).toBe(7); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(93); + expect(root_child1.getComputedTop()).toBe(207); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_with_min_cross_axis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMinHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(33); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(267); + expect(root_child1.getComputedWidth()).toBe(400); + 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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(33); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(267); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_with_max_cross_axis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + 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(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_with_max_cross_axis_violated', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMaxHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + 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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + 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(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_with_max_cross_axis_violated_padding_and_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 2); + root.setPadding(Edge.Top, 2); + root.setPadding(Edge.Right, 2); + root.setPadding(Edge.Bottom, 2); + root.setBorder(Edge.Left, 5); + root.setBorder(Edge.Top, 5); + root.setBorder(Edge.Right, 5); + root.setBorder(Edge.Bottom, 5); + root.setWidth(500); + root.setMaxHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + 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(300); + + expect(root_child0.getComputedLeft()).toBe(7); + expect(root_child0.getComputedTop()).toBe(7); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(7); + expect(root_child1.getComputedTop()).toBe(207); + expect(root_child1.getComputedWidth()).toBe(400); + 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(500); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(93); + expect(root_child0.getComputedTop()).toBe(7); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(93); + expect(root_child1.getComputedTop()).toBe(207); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around_and_align_items_flex_end_with_flex_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setHeight(50); + 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(120); + root_child2.setHeight(50); + 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(88); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(150); + expect(root_child0.getComputedTop()).toBe(88); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around_and_align_items_center_with_flex_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setHeight(50); + 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(120); + root_child2.setHeight(50); + 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(63); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(150); + expect(root_child0.getComputedTop()).toBe(63); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_around_and_align_items_flex_start_with_flex_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(150); + root_child0.setHeight(50); + 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(120); + root_child2.setHeight(50); + 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(38); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(150); + expect(root_child0.getComputedTop()).toBe(38); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_flex_start_stretch_doesnt_influence_line_box_dim', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Right, 20); + root_child1_child0.setWidth(30); + root_child1_child0.setHeight(30); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setMargin(Edge.Right, 20); + root_child1_child1.setWidth(30); + root_child1_child1.setHeight(30); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setMargin(Edge.Right, 20); + root_child1_child2.setWidth(30); + root_child1_child2.setHeight(30); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setMargin(Edge.Right, 20); + root_child1_child3.setWidth(30); + root_child1_child3.setHeight(30); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setMargin(Edge.Right, 20); + root_child1_child4.setWidth(30); + root_child1_child4.setHeight(30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Left, 20); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(140); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(100); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(30); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(30); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(330); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.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(140); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(120); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(70); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(20); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(120); + expect(root_child1_child3.getComputedTop()).toBe(30); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(70); + expect(root_child1_child4.getComputedTop()).toBe(30); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_stretch_does_influence_line_box_dim', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setAlignContent(Align.Stretch); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Right, 20); + root_child1_child0.setWidth(30); + root_child1_child0.setHeight(30); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setMargin(Edge.Right, 20); + root_child1_child1.setWidth(30); + root_child1_child1.setHeight(30); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setMargin(Edge.Right, 20); + root_child1_child2.setWidth(30); + root_child1_child2.setHeight(30); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setMargin(Edge.Right, 20); + root_child1_child3.setWidth(30); + root_child1_child3.setHeight(30); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setMargin(Edge.Right, 20); + root_child1_child4.setWidth(30); + root_child1_child4.setHeight(30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Left, 20); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(140); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(100); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(330); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.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(140); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(120); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(70); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(20); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(120); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(70); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_stretch_does_influence_line_box_dim', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setAlignContent(Align.Stretch); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Right, 20); + root_child1_child0.setWidth(30); + root_child1_child0.setHeight(30); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setMargin(Edge.Right, 20); + root_child1_child1.setWidth(30); + root_child1_child1.setHeight(30); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setMargin(Edge.Right, 20); + root_child1_child2.setWidth(30); + root_child1_child2.setHeight(30); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setMargin(Edge.Right, 20); + root_child1_child3.setWidth(30); + root_child1_child3.setHeight(30); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setMargin(Edge.Right, 20); + root_child1_child4.setWidth(30); + root_child1_child4.setHeight(30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Left, 20); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(140); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(100); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(330); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.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(140); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(120); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(70); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(20); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(120); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(70); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_and_align_items_flex_end_with_flex_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexStart); + root_child0.setWidth(150); + root_child0.setHeight(50); + 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(120); + root_child2.setHeight(50); + 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(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(250); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(250); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_and_align_items_flex_start_with_flex_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(150); + root_child0.setHeight(50); + 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(120); + root_child2.setHeight(50); + 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(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(175); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(150); + expect(root_child0.getComputedTop()).toBe(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(175); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_and_align_items_center_with_flex_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(150); + root_child0.setHeight(50); + 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(120); + root_child2.setHeight(50); + 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(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(150); + expect(root_child0.getComputedTop()).toBe(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(38); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_and_align_items_stretch_with_flex_wrap', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(150); + root_child0.setHeight(50); + 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(120); + root_child2.setHeight(50); + 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(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(175); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(150); + expect(root_child0.getComputedTop()).toBe(125); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(120); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(180); + expect(root_child2.getComputedTop()).toBe(175); + expect(root_child2.getComputedWidth()).toBe(120); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignItemsTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignItemsTest.test.ts new file mode 100644 index 0000000..39c013a --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignItemsTest.test.ts @@ -0,0 +1,2444 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<075a0b67003e5c4a1f51bd99da71c700>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('align_items_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(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(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(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(0); + 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(); + } +}); +test('align_items_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_items_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_items_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_baseline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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(50); + 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(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(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(0); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_baseline_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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(50); + root_child1.setHeight(20); + 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.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(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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_baseline_child_multiline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setWidth(50); + root_child1.setHeight(25); + 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.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.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.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.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(50); + expect(root_child1.getComputedTop()).toBe(40); + 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(0); + expect(root_child1.getComputedTop()).toBe(40); + 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(); + } +}); +test('align_baseline_child_multiline_override', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setWidth(50); + root_child1.setHeight(25); + 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.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.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.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.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(50); + expect(root_child1.getComputedTop()).toBe(50); + 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(0); + expect(root_child1.getComputedTop()).toBe(50); + 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(); + } +}); +test('align_baseline_child_multiline_no_override_on_secondline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setWidth(50); + root_child1.setHeight(25); + 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.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.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.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.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(50); + expect(root_child1.getComputedTop()).toBe(40); + 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(0); + expect(root_child1.getComputedTop()).toBe(40); + 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(); + } +}); +test('align_baseline_child_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Top, 10); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + 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.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(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); + + 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(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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_baseline_child_top2', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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.setPosition(Edge.Top, 5); + root_child1.setWidth(50); + root_child1.setHeight(20); + 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.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(50); + expect(root_child1.getComputedTop()).toBe(45); + 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(0); + expect(root_child1.getComputedTop()).toBe(45); + 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(); + } +}); +test('align_baseline_double_nested_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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.insertChild(root_child0_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + 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.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(50); + expect(root_child1.getComputedTop()).toBe(5); + 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(0); + expect(root_child1.getComputedTop()).toBe(5); + 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(); + } +}); +test('align_baseline_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); + + 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(50); + 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(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(); + } +}); +test('align_baseline_child_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(20); + 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.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(60); + expect(root_child1.getComputedTop()).toBe(44); + 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(45); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(-10); + expect(root_child1.getComputedTop()).toBe(44); + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_baseline_child_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + 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); + + 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.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.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth(50); + root_child1_child0.setHeight(10); + 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(55); + expect(root_child1.getComputedTop()).toBe(40); + 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(-5); + expect(root_child1.getComputedTop()).toBe(40); + 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(); + } +}); +test('align_baseline_multiline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + 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(50); + root_child1.setHeight(20); + 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.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(20); + 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.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + 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(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(); + } +}); +test.skip('align_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.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + 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(30); + root_child1.setHeight(50); + 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.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root_child2.setHeight(70); + 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.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(20); + 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(0); + expect(root_child1.getComputedTop()).toBe(50); + 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(50); + expect(root_child2.getComputedTop()).toBe(0); + 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(70); + 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(50); + expect(root_child1.getComputedTop()).toBe(50); + 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(0); + expect(root_child2.getComputedTop()).toBe(0); + 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(70); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('align_baseline_multiline_column2', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + 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(30); + root_child1.setHeight(50); + 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.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(40); + root_child2.setHeight(70); + 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.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(20); + 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(0); + expect(root_child1.getComputedTop()).toBe(50); + 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(50); + expect(root_child2.getComputedTop()).toBe(0); + 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(70); + 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(50); + expect(root_child1.getComputedTop()).toBe(50); + 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(0); + expect(root_child2.getComputedTop()).toBe(0); + 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(70); + expect(root_child3.getComputedWidth()).toBe(50); + expect(root_child3.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_baseline_multiline_row_and_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Baseline); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + + 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(50); + root_child1.setHeight(50); + 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.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(20); + 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.insertChild(root_child2_child0, 0); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(50); + root_child3.setHeight(20); + 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(); + } +}); +test('align_items_center_child_with_margin_bigger_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.Center); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setMargin(Edge.Left, 10); + root_child0_child0.setMargin(Edge.Right, 10); + root_child0_child0.setWidth(52); + root_child0_child0.setHeight(52); + 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(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(52); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(52); + expect(root_child0_child0.getComputedHeight()).toBe(52); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(52); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(52); + expect(root_child0_child0.getComputedHeight()).toBe(52); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_items_flex_end_child_with_margin_bigger_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.FlexEnd); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setMargin(Edge.Left, 10); + root_child0_child0.setMargin(Edge.Right, 10); + root_child0_child0.setWidth(52); + root_child0_child0.setHeight(52); + 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(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(52); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(52); + expect(root_child0_child0.getComputedHeight()).toBe(52); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(52); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(52); + expect(root_child0_child0.getComputedHeight()).toBe(52); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_items_center_child_without_margin_bigger_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.Center); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(72); + root_child0_child0.setHeight(72); + 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(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0.getComputedHeight()).toBe(72); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_items_flex_end_child_without_margin_bigger_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.FlexEnd); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(72); + root_child0_child0.setHeight(72); + 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(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0.getComputedHeight()).toBe(72); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_center_should_size_based_on_content', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setFlexShrink(1); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(20); + root_child0_child0_child0.setHeight(20); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(20); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(20); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_stretch_should_size_based_on_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setJustifyContent(Justify.Center); + root_child0.setFlexShrink(1); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(20); + root_child0_child0_child0.setHeight(20); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(20); + 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(20); + + 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(20); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(20); + 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(20); + + 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(20); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_flex_start_with_shrinking_children', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.FlexStart); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(1); + root_child0_child0_child0.setFlexShrink(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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + 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); + + 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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(500); + 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(); + } +}); +test('align_flex_start_with_stretching_children', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(1); + root_child0_child0_child0.setFlexShrink(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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + 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(500); + 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(500); + 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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + 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(500); + 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(500); + expect(root_child0_child0_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_flex_start_with_shrinking_children_with_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignItems(Align.FlexStart); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(1); + root_child0_child0_child0.setFlexShrink(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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + 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); + + 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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(500); + 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(); + } +}); +test('align_flex_end_with_row_reverse', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(75); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 3); + root_child0.setMargin(Edge.Right, 5); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(75); + + expect(root_child0.getComputedLeft()).toBe(3); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(58); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + 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(75); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(-8); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_stretch_with_row_reverse', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(75); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 3); + root_child0.setMargin(Edge.Right, 5); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(75); + + expect(root_child0.getComputedLeft()).toBe(3); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(58); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + 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(75); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(-8); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignSelfTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignSelfTest.test.ts new file mode 100644 index 0000000..5d2e49e --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAlignSelfTest.test.ts @@ -0,0 +1,293 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGAlignSelfTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('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(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Center); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_self_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_self_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexStart); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_self_flex_end_override_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.FlexEnd); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_self_baseline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setAlignSelf(Align.Baseline); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setAlignSelf(Align.Baseline); + root_child1.setWidth(50); + root_child1.setHeight(20); + 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.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(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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGAndroidNewsFeed.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAndroidNewsFeed.test.ts new file mode 100644 index 0000000..488ed8d --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAndroidNewsFeed.test.ts @@ -0,0 +1,315 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<e79ac212057a324d3ce2808face5a71c>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAndroidNewsFeed.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('android_news_feed', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(1080); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignContent(Align.Stretch); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0.setAlignItems(Align.FlexStart); + root_child0_child0_child0_child0.setMargin(Edge.Start, 36); + root_child0_child0_child0_child0.setMargin(Edge.Top, 24); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0_child0_child0.setWidth(120); + root_child0_child0_child0_child0_child0_child0.setHeight(120); + root_child0_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child1.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0_child1.setFlexShrink(1); + root_child0_child0_child0_child0_child1.setMargin(Edge.Right, 36); + root_child0_child0_child0_child0_child1.setPadding(Edge.Left, 36); + root_child0_child0_child0_child0_child1.setPadding(Edge.Top, 21); + root_child0_child0_child0_child0_child1.setPadding(Edge.Right, 36); + root_child0_child0_child0_child0_child1.setPadding(Edge.Bottom, 18); + root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child1, 1); + + const root_child0_child0_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child1_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0_child0_child1_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0_child1_child0.setFlexShrink(1); + root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child0, 0); + + const root_child0_child0_child0_child0_child1_child1 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child1_child1.setAlignContent(Align.Stretch); + root_child0_child0_child0_child0_child1_child1.setFlexShrink(1); + root_child0_child0_child0_child0_child1.insertChild(root_child0_child0_child0_child0_child1_child1, 1); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setAlignContent(Align.Stretch); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child1_child0.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0.setAlignItems(Align.FlexStart); + root_child0_child0_child1_child0.setMargin(Edge.Start, 174); + root_child0_child0_child1_child0.setMargin(Edge.Top, 24); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child1_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child1_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child0, 0); + + const root_child0_child0_child1_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0_child0_child0.setWidth(72); + root_child0_child0_child1_child0_child0_child0.setHeight(72); + root_child0_child0_child1_child0_child0.insertChild(root_child0_child0_child1_child0_child0_child0, 0); + + const root_child0_child0_child1_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child1.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0_child1.setFlexShrink(1); + root_child0_child0_child1_child0_child1.setMargin(Edge.Right, 36); + root_child0_child0_child1_child0_child1.setPadding(Edge.Left, 36); + root_child0_child0_child1_child0_child1.setPadding(Edge.Top, 21); + root_child0_child0_child1_child0_child1.setPadding(Edge.Right, 36); + root_child0_child0_child1_child0_child1.setPadding(Edge.Bottom, 18); + root_child0_child0_child1_child0.insertChild(root_child0_child0_child1_child0_child1, 1); + + const root_child0_child0_child1_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child1_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child1_child0_child1_child0.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0_child1_child0.setFlexShrink(1); + root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child0, 0); + + const root_child0_child0_child1_child0_child1_child1 = Yoga.Node.create(config); + root_child0_child0_child1_child0_child1_child1.setAlignContent(Align.Stretch); + root_child0_child0_child1_child0_child1_child1.setFlexShrink(1); + root_child0_child0_child1_child0_child1.insertChild(root_child0_child0_child1_child0_child1_child1, 1); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1080); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1080); + expect(root_child0.getComputedHeight()).toBe(240); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1080); + expect(root_child0_child0.getComputedHeight()).toBe(240); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(1080); + expect(root_child0_child0_child0.getComputedHeight()).toBe(144); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(24); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(1044); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); + expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); + expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child1.getComputedLeft()).toBe(120); + expect(root_child0_child0_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child1.getComputedWidth()).toBe(72); + expect(root_child0_child0_child0_child0_child1.getComputedHeight()).toBe(39); + + expect(root_child0_child0_child0_child0_child1_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0_child1_child0.getComputedTop()).toBe(21); + expect(root_child0_child0_child0_child0_child1_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0_child0_child1_child1.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0_child1_child1.getComputedTop()).toBe(21); + expect(root_child0_child0_child0_child0_child1_child1.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0_child1_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1.getComputedTop()).toBe(144); + expect(root_child0_child0_child1.getComputedWidth()).toBe(1080); + expect(root_child0_child0_child1.getComputedHeight()).toBe(96); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(174); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(24); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(906); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child0_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child1.getComputedLeft()).toBe(72); + expect(root_child0_child0_child1_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child1.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child1.getComputedHeight()).toBe(39); + + expect(root_child0_child0_child1_child0_child1_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child1_child0_child1_child0.getComputedTop()).toBe(21); + expect(root_child0_child0_child1_child0_child1_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child1_child0_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child1_child0_child1_child1.getComputedLeft()).toBe(36); + expect(root_child0_child0_child1_child0_child1_child1.getComputedTop()).toBe(21); + expect(root_child0_child0_child1_child0_child1_child1.getComputedWidth()).toBe(0); + expect(root_child0_child0_child1_child0_child1_child1.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1080); + expect(root.getComputedHeight()).toBe(240); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1080); + expect(root_child0.getComputedHeight()).toBe(240); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(1080); + expect(root_child0_child0.getComputedHeight()).toBe(240); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(1080); + expect(root_child0_child0_child0.getComputedHeight()).toBe(144); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(24); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(1044); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(924); + expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); + expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(120); + expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(120); + + expect(root_child0_child0_child0_child0_child1.getComputedLeft()).toBe(816); + expect(root_child0_child0_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child1.getComputedWidth()).toBe(72); + expect(root_child0_child0_child0_child0_child1.getComputedHeight()).toBe(39); + + expect(root_child0_child0_child0_child0_child1_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0_child1_child0.getComputedTop()).toBe(21); + expect(root_child0_child0_child0_child0_child1_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child0_child0_child1_child1.getComputedLeft()).toBe(36); + expect(root_child0_child0_child0_child0_child1_child1.getComputedTop()).toBe(21); + expect(root_child0_child0_child0_child0_child1_child1.getComputedWidth()).toBe(0); + expect(root_child0_child0_child0_child0_child1_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1.getComputedTop()).toBe(144); + expect(root_child0_child0_child1.getComputedWidth()).toBe(1080); + expect(root_child0_child0_child1.getComputedHeight()).toBe(96); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(24); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(906); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child0.getComputedLeft()).toBe(834); + expect(root_child0_child0_child1_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child0_child0.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child0_child0.getComputedHeight()).toBe(72); + + expect(root_child0_child0_child1_child0_child1.getComputedLeft()).toBe(726); + expect(root_child0_child0_child1_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1_child0_child1.getComputedWidth()).toBe(72); + expect(root_child0_child0_child1_child0_child1.getComputedHeight()).toBe(39); + + expect(root_child0_child0_child1_child0_child1_child0.getComputedLeft()).toBe(36); + expect(root_child0_child0_child1_child0_child1_child0.getComputedTop()).toBe(21); + expect(root_child0_child0_child1_child0_child1_child0.getComputedWidth()).toBe(0); + expect(root_child0_child0_child1_child0_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child1_child0_child1_child1.getComputedLeft()).toBe(36); + expect(root_child0_child0_child1_child0_child1_child1.getComputedTop()).toBe(21); + expect(root_child0_child0_child1_child0_child1_child1.getComputedWidth()).toBe(0); + expect(root_child0_child0_child1_child0_child1_child1.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGAspectRatioTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAspectRatioTest.test.ts new file mode 100644 index 0000000..69a7427 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAspectRatioTest.test.ts @@ -0,0 +1,231 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGAspectRatioTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test.skip('aspect_ratio_does_not_stretch_cross_axis_dim', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setOverflow(Overflow.Scroll); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(2); + root_child0_child0_child0.setFlexShrink(1); + root_child0_child0_child0.setFlexBasis("0%"); + root_child0_child0_child0.setAspectRatio(1 / 1); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setWidth(5); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setFlexGrow(1); + root_child0_child0_child2.setFlexShrink(1); + root_child0_child0_child2.setFlexBasis("0%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setFlexGrow(1); + root_child0_child0_child2_child0.setFlexShrink(1); + root_child0_child0_child2_child0.setFlexBasis("0%"); + root_child0_child0_child2_child0.setAspectRatio(1 / 1); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + + const root_child0_child0_child2_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0_child0.setWidth(5); + root_child0_child0_child2_child0.insertChild(root_child0_child0_child2_child0_child0, 0); + + const root_child0_child0_child2_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child2_child0_child1.setFlexGrow(1); + root_child0_child0_child2_child0_child1.setFlexShrink(1); + root_child0_child0_child2_child0_child1.setFlexBasis("0%"); + root_child0_child0_child2_child0_child1.setAspectRatio(1 / 1); + root_child0_child0_child2_child0.insertChild(root_child0_child0_child2_child0_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(300); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(300); + expect(root_child0_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(197); + expect(root_child0_child0_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(197); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(5); + expect(root_child0_child0_child1.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(202); + expect(root_child0_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child0_child2.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0_child0.getComputedWidth()).toBe(5); + expect(root_child0_child0_child2_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child2_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0_child1.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2_child0_child1.getComputedHeight()).toBe(197); + + 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(300); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(300); + expect(root_child0_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(103); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(197); + expect(root_child0_child0_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(98); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(5); + expect(root_child0_child0_child1.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child0_child2.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(197); + + expect(root_child0_child0_child2_child0_child0.getComputedLeft()).toBe(93); + expect(root_child0_child0_child2_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0_child0.getComputedWidth()).toBe(5); + expect(root_child0_child0_child2_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0_child2_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child2_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child2_child0_child1.getComputedWidth()).toBe(98); + expect(root_child0_child0_child2_child0_child1.getComputedHeight()).toBe(197); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('zero_aspect_ratio_behaves_like_auto', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setAspectRatio(0 / 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(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + 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(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGAutoTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAutoTest.test.ts new file mode 100644 index 0000000..5e9557d --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGAutoTest.test.ts @@ -0,0 +1,347 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGAutoTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('auto_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth('auto'); + root.setHeight(50); + + 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(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(150); + 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(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(100); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(150); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(100); + 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(0); + 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(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setHeight('auto'); + + 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(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(50); + expect(root.getComputedHeight()).toBe(150); + + 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(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(150); + + 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(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_flex_basis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + + 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(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(50); + expect(root.getComputedHeight()).toBe(150); + + 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(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(150); + + 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(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionAuto(Edge.Right); + root_child0.setWidth(25); + root_child0.setHeight(25); + 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(25); + 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(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('auto_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setWidth(25); + root_child0.setHeight(25); + 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(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + 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(50); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGBorderTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGBorderTest.test.ts new file mode 100644 index 0000000..ddbdd2a --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGBorderTest.test.ts @@ -0,0 +1,256 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<b1aa13bd88fcb494afb2db9bd80c40e0>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBorderTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('border_no_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('border_container_match_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 10); + root.setBorder(Edge.Top, 10); + root.setBorder(Edge.Right, 10); + root.setBorder(Edge.Bottom, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(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(30); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + 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(30); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('border_flex_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + 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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.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(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('border_stretch_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + 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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('border_center_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Start, 10); + root.setBorder(Edge.End, 20); + root.setBorder(Edge.Bottom, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(35); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(35); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGBoxSizingTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGBoxSizingTest.test.ts new file mode 100644 index 0000000..d967870 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGBoxSizingTest.test.ts @@ -0,0 +1,2747 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<a841bb29f095097bae9635f62b9fb16d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGBoxSizingTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('box_sizing_content_box_simple', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + 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.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.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_simple', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + 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.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.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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_percent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 4); + root_child0.setPadding(Edge.Top, 4); + root_child0.setPadding(Edge.Right, 4); + root_child0.setPadding(Edge.Bottom, 4); + root_child0.setBorder(Edge.Left, 16); + root_child0.setBorder(Edge.Top, 16); + root_child0.setBorder(Edge.Right, 16); + root_child0.setBorder(Edge.Bottom, 16); + root_child0.setWidth("50%"); + root_child0.setHeight("25%"); + root_child0.setBoxSizing(BoxSizing.ContentBox); + 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(90); + expect(root_child0.getComputedHeight()).toBe(65); + + 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(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(65); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_percent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 4); + root_child0.setPadding(Edge.Top, 4); + root_child0.setPadding(Edge.Right, 4); + root_child0.setPadding(Edge.Bottom, 4); + root_child0.setBorder(Edge.Left, 16); + root_child0.setBorder(Edge.Top, 16); + root_child0.setBorder(Edge.Right, 16); + root_child0.setBorder(Edge.Bottom, 16); + root_child0.setWidth("50%"); + root_child0.setHeight("25%"); + 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(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(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_absolute', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPadding(Edge.Left, 12); + root_child0.setPadding(Edge.Top, 12); + root_child0.setPadding(Edge.Right, 12); + root_child0.setPadding(Edge.Bottom, 12); + root_child0.setBorder(Edge.Left, 8); + root_child0.setBorder(Edge.Top, 8); + root_child0.setBorder(Edge.Right, 8); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setHeight("25%"); + root_child0.setBoxSizing(BoxSizing.ContentBox); + 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(40); + expect(root_child0.getComputedHeight()).toBe(65); + + 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(65); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_absolute', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPadding(Edge.Left, 12); + root_child0.setPadding(Edge.Top, 12); + root_child0.setPadding(Edge.Right, 12); + root_child0.setPadding(Edge.Bottom, 12); + root_child0.setBorder(Edge.Left, 8); + root_child0.setBorder(Edge.Top, 8); + root_child0.setBorder(Edge.Right, 8); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setHeight("25%"); + 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(40); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_comtaining_block', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 12); + root.setPadding(Edge.Top, 12); + root.setPadding(Edge.Right, 12); + root.setPadding(Edge.Bottom, 12); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 8); + root.setBorder(Edge.Right, 8); + root.setBorder(Edge.Bottom, 8); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Static); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight("25%"); + 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(140); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + 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(50); + expect(root_child0_child0.getComputedHeight()).toBe(31); + + 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(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(31); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_comtaining_block', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 12); + root.setPadding(Edge.Top, 12); + root.setPadding(Edge.Right, 12); + root.setPadding(Edge.Bottom, 12); + root.setBorder(Edge.Left, 8); + root.setBorder(Edge.Top, 8); + root.setBorder(Edge.Right, 8); + root.setBorder(Edge.Bottom, 8); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Static); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight("25%"); + 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(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(60); + 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(50); + expect(root_child0_child0.getComputedHeight()).toBe(21); + + 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(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(21); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_padding_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + 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.setBoxSizing(BoxSizing.ContentBox); + 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(110); + + 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(110); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_padding_only_percent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(150); + + 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.setWidth(50); + root_child0.setHeight(75); + root_child0.setBoxSizing(BoxSizing.ContentBox); + 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(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(70); + expect(root_child0.getComputedHeight()).toBe(95); + + 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(150); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(70); + expect(root_child0.getComputedHeight()).toBe(95); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_padding_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + 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.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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_padding_only_percent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(150); + + 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.setWidth(50); + root_child0.setHeight(75); + 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(150); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(75); + + 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(150); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(75); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_border_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + 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.setBoxSizing(BoxSizing.ContentBox); + 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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_border_only_percent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setBoxSizing(BoxSizing.ContentBox); + 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(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(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_border_only', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + 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.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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_border_only_percent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + 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(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(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(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_no_padding_no_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + 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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_no_padding_no_border', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + 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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_children', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + 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.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.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + 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(130); + expect(root.getComputedHeight()).toBe(130); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(15); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(15); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(15); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(130); + expect(root.getComputedHeight()).toBe(130); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(90); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_children', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + 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.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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + 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(15); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(15); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(15); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(15); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.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(60); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(60); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_siblings', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + root_child1.setBorder(Edge.Left, 10); + root_child1.setBorder(Edge.Top, 10); + root_child1.setBorder(Edge.Right, 10); + root_child1.setBorder(Edge.Bottom, 10); + root_child1.setWidth(25); + root_child1.setHeight(25); + root_child1.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + 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(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(65); + expect(root_child1.getComputedHeight()).toBe(65); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(115); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.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(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(35); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(65); + expect(root_child1.getComputedHeight()).toBe(65); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(90); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(75); + expect(root_child3.getComputedTop()).toBe(115); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_siblings', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(25); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + root_child1.setBorder(Edge.Left, 10); + root_child1.setBorder(Edge.Top, 10); + root_child1.setBorder(Edge.Right, 10); + root_child1.setBorder(Edge.Bottom, 10); + root_child1.setWidth(25); + root_child1.setHeight(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(25); + root_child2.setHeight(25); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(25); + root_child3.setHeight(25); + 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(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.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(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(25); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(25); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(40); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(65); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(25); + + expect(root_child3.getComputedLeft()).toBe(75); + expect(root_child3.getComputedTop()).toBe(90); + expect(root_child3.getComputedWidth()).toBe(25); + expect(root_child3.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMaxWidth(50); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + 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(90); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.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(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMaxWidth(50); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + 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(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.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(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMaxHeight(50); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + 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(90); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.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(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMaxHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + 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(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.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(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMinWidth(50); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + 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(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setMinWidth(50); + root_child0.setHeight(25); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + 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(100); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMinHeight(50); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + 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(90); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.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(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(90); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(90); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 15); + root_child0.setBorder(Edge.Top, 15); + root_child0.setBorder(Edge.Right, 15); + root_child0.setBorder(Edge.Bottom, 15); + root_child0.setWidth(50); + root_child0.setMinHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(25); + root_child1.setHeight(25); + 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(25); + expect(root_child1.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(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_no_height_no_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root_child0.setBoxSizing(BoxSizing.ContentBox); + 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(18); + + 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(18); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_no_height_no_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + 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(18); + + 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(18); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_nested', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 15); + root.setPadding(Edge.Top, 15); + root.setPadding(Edge.Right, 15); + root.setPadding(Edge.Bottom, 15); + root.setBorder(Edge.Left, 3); + root.setBorder(Edge.Top, 3); + root.setBorder(Edge.Right, 3); + root.setBorder(Edge.Bottom, 3); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root_child0.setWidth(20); + root_child0.setHeight(20); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0.setBorder(Edge.Top, 2); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 2); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(5); + root_child0_child0.setBoxSizing(BoxSizing.ContentBox); + 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(136); + expect(root.getComputedHeight()).toBe(136); + + expect(root_child0.getComputedLeft()).toBe(18); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(38); + expect(root_child0.getComputedHeight()).toBe(38); + + expect(root_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(16); + expect(root_child0_child0.getComputedHeight()).toBe(11); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(136); + expect(root.getComputedHeight()).toBe(136); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(38); + expect(root_child0.getComputedHeight()).toBe(38); + + expect(root_child0_child0.getComputedLeft()).toBe(13); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(16); + expect(root_child0_child0.getComputedHeight()).toBe(11); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_nested', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 15); + root.setPadding(Edge.Top, 15); + root.setPadding(Edge.Right, 15); + root.setPadding(Edge.Bottom, 15); + root.setBorder(Edge.Left, 3); + root.setBorder(Edge.Top, 3); + root.setBorder(Edge.Right, 3); + root.setBorder(Edge.Bottom, 3); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 2); + root_child0.setPadding(Edge.Right, 2); + root_child0.setPadding(Edge.Bottom, 2); + root_child0.setBorder(Edge.Left, 7); + root_child0.setBorder(Edge.Top, 7); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 7); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0.setBorder(Edge.Top, 2); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 2); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(5); + 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(18); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child0_child0.getComputedLeft()).toBe(1); + expect(root_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(6); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_nested_alternating', () => { + 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.setBorder(Edge.Left, 2); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 2); + root.setBorder(Edge.Bottom, 2); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 8); + root_child0.setPadding(Edge.Top, 8); + root_child0.setPadding(Edge.Right, 8); + root_child0.setPadding(Edge.Bottom, 8); + root_child0.setBorder(Edge.Left, 2); + root_child0.setBorder(Edge.Top, 2); + root_child0.setBorder(Edge.Right, 2); + root_child0.setBorder(Edge.Bottom, 2); + root_child0.setWidth(40); + root_child0.setHeight(40); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + 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.setBorder(Edge.Left, 6); + root_child0_child0.setBorder(Edge.Top, 6); + root_child0_child0.setBorder(Edge.Right, 6); + root_child0_child0.setBorder(Edge.Bottom, 6); + root_child0_child0.setWidth(20); + root_child0_child0.setHeight(25); + root_child0_child0.setBoxSizing(BoxSizing.ContentBox); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0_child0.setBorder(Edge.Left, 1); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 1); + root_child0_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0_child0.setWidth(10); + root_child0_child0_child0.setHeight(5); + 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(110); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(38); + expect(root_child0_child0.getComputedHeight()).toBe(43); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0_child0.getComputedHeight()).toBe(5); + + 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(110); + + expect(root_child0.getComputedLeft()).toBe(65); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0.getComputedLeft()).toBe(-8); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(38); + expect(root_child0_child0.getComputedHeight()).toBe(43); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(19); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0_child0.getComputedHeight()).toBe(5); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_nested_alternating', () => { + 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.setBorder(Edge.Left, 2); + root.setBorder(Edge.Top, 2); + root.setBorder(Edge.Right, 2); + root.setBorder(Edge.Bottom, 2); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 8); + root_child0.setPadding(Edge.Top, 8); + root_child0.setPadding(Edge.Right, 8); + root_child0.setPadding(Edge.Bottom, 8); + root_child0.setBorder(Edge.Left, 2); + root_child0.setBorder(Edge.Top, 2); + root_child0.setBorder(Edge.Right, 2); + root_child0.setBorder(Edge.Bottom, 2); + root_child0.setWidth(40); + root_child0.setHeight(40); + root_child0.setBoxSizing(BoxSizing.ContentBox); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + 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.setBorder(Edge.Left, 6); + root_child0_child0.setBorder(Edge.Top, 6); + root_child0_child0.setBorder(Edge.Right, 6); + root_child0_child0.setBorder(Edge.Bottom, 6); + root_child0_child0.setWidth(20); + root_child0_child0.setHeight(25); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0_child0.setPadding(Edge.Top, 1); + root_child0_child0_child0.setPadding(Edge.Right, 1); + root_child0_child0_child0.setPadding(Edge.Bottom, 1); + root_child0_child0_child0.setBorder(Edge.Left, 1); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 1); + root_child0_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0_child0.setWidth(10); + root_child0_child0_child0.setHeight(5); + root_child0_child0_child0.setBoxSizing(BoxSizing.ContentBox); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(14); + expect(root_child0_child0_child0.getComputedHeight()).toBe(9); + + 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(35); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child0_child0.getComputedLeft()).toBe(30); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-3); + expect(root_child0_child0_child0.getComputedTop()).toBe(9); + expect(root_child0_child0_child0.getComputedWidth()).toBe(14); + expect(root_child0_child0_child0.getComputedHeight()).toBe(9); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_flex_basis_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 10); + root_child0.setBorder(Edge.Top, 10); + root_child0.setBorder(Edge.Right, 10); + root_child0.setBorder(Edge.Bottom, 10); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + 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(80); + expect(root_child0.getComputedHeight()).toBe(55); + + 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(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(55); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_flex_basis_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 10); + root_child0.setBorder(Edge.Top, 10); + root_child0.setBorder(Edge.Right, 10); + root_child0.setBorder(Edge.Bottom, 10); + root_child0.setHeight(25); + 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(30); + + 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(30); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('box_sizing_content_box_flex_basis_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 10); + root_child0.setBorder(Edge.Top, 10); + root_child0.setBorder(Edge.Right, 10); + root_child0.setBorder(Edge.Bottom, 10); + root_child0.setHeight(25); + root_child0.setBoxSizing(BoxSizing.ContentBox); + 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(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(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_flex_basis_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setPadding(Edge.Left, 5); + root_child0.setPadding(Edge.Top, 5); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 5); + root_child0.setBorder(Edge.Left, 10); + root_child0.setBorder(Edge.Top, 10); + root_child0.setBorder(Edge.Right, 10); + root_child0.setBorder(Edge.Bottom, 10); + root_child0.setHeight(25); + 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(); + } +}); +test('box_sizing_content_box_padding_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Start, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_padding_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Start, 5); + root.setWidth(100); + root.setHeight(100); + 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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_padding_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.End, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_padding_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.End, 5); + root.setWidth(100); + root.setHeight(100); + 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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_border_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Start, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_border_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Start, 5); + root.setWidth(100); + root.setHeight(100); + 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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_content_box_border_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.End, 5); + root.setWidth(100); + root.setHeight(100); + root.setBoxSizing(BoxSizing.ContentBox); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(105); + expect(root.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('box_sizing_border_box_border_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.End, 5); + root.setWidth(100); + root.setHeight(100); + 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); + + 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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGDimensionTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGDimensionTest.test.ts new file mode 100644 index 0000000..39c140d --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGDimensionTest.test.ts @@ -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. + * + * @generated SignedSource<<719c8f3b9fea672881a47f593f4aabd0>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDimensionTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('wrap_child', () => { + 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.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_grandchild', () => { + 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.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + 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(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + 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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGDisplayContentsTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGDisplayContentsTest.test.ts new file mode 100644 index 0000000..e687846 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGDisplayContentsTest.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<<64d58fa2d33230f4eafc9ecbb6012a0d>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayContentsTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('test1', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_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(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(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_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(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(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGDisplayTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGDisplayTest.test.ts new file mode 100644 index 0000000..9c6cd8d --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGDisplayTest.test.ts @@ -0,0 +1,1097 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<ef1ab99e8f13c0a59342ca17f63181ef>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('display_none', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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.setFlexGrow(1); + 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(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); + + 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(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(); + } +}); +test('display_none_fixed_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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(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); + + 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(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(); + } +}); +test('display_none_with_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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(20); + root_child0.setHeight(20); + root_child0.setDisplay(Display.None); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(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(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(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(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(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_none_with_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setDisplay(Display.None); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setFlexShrink(1); + root_child1_child0.setFlexBasis("0%"); + root_child1_child0.setWidth(20); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + 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(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(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(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(0); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(50); + 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(0); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(0); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_none_with_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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.setFlexGrow(1); + root_child1.setPosition(Edge.Top, 10); + 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(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); + + 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(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(); + } +}); +test('display_none_with_position_absolute', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setDisplay(Display.None); + 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(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(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); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_contents', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_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(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(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_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(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(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_contents_fixed_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_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(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(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_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(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(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_contents_with_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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(20); + root_child0.setHeight(20); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(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(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(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(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(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_contents_with_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_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(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(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_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(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(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_contents_with_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Top, 10); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_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(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(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_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(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(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_contents_with_position_absolute', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth(50); + root_child0.setHeight(50); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis("0%"); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(1); + root_child0_child1.setFlexShrink(1); + root_child0_child1.setFlexBasis("0%"); + root_child0_child1.setHeight(20); + root_child0.insertChild(root_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(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(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_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(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(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_contents_nested', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setDisplay(Display.Contents); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setDisplay(Display.Contents); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexGrow(1); + root_child0_child0_child0.setFlexShrink(1); + root_child0_child0_child0.setFlexBasis("0%"); + root_child0_child0_child0.setHeight(10); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setFlexGrow(1); + root_child0_child0_child1.setFlexShrink(1); + root_child0_child0_child1.setFlexBasis("0%"); + root_child0_child0_child1.setHeight(20); + root_child0_child0.insertChild(root_child0_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(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); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child0_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(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); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child0_child1.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('display_contents_with_siblings', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setHeight(30); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setDisplay(Display.Contents); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setFlexShrink(1); + root_child1_child0.setFlexBasis("0%"); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setFlexGrow(1); + root_child1_child1.setFlexShrink(1); + root_child1_child1.setFlexBasis("0%"); + root_child1_child1.setHeight(20); + root_child1.insertChild(root_child1_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + root_child2.setHeight(30); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(30); + + 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(25); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(25); + expect(root_child1_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(30); + + 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(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(25); + expect(root_child0.getComputedHeight()).toBe(30); + + 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(50); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(25); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + 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(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(30); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexDirectionTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexDirectionTest.test.ts new file mode 100644 index 0000000..2999bef --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexDirectionTest.test.ts @@ -0,0 +1,4562 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGFlexDirectionTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('flex_direction_column_no_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(30); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(30); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_no_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(30); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(30); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column_reverse', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(90); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(70); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(0); + expect(root_child0.getComputedTop()).toBe(90); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(80); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(70); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_margin_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Left, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(100); + 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(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_margin_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Start, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_margin_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Right, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_margin_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.End, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(100); + 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(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column_reverse_margin_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column_reverse_margin_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Bottom, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_padding_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_padding_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Start, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_padding_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Right, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_padding_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.End, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column_reverse_padding_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Top, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column_reverse_padding_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Bottom, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_border_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Left, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_border_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Start, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(80); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_border_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Right, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_border_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.End, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(-10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(-20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(120); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column_reverse_border_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Top, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(100); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column_reverse_border_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.ColumnReverse); + root.setPositionType(PositionType.Absolute); + root.setBorder(Edge.Bottom, 100); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(90); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_pos_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPosition(Edge.Left, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(100); + 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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(80); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(70); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(100); + 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_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(100); + + expect(root_child0_child1.getComputedLeft()).toBe(10); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_pos_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPosition(Edge.Start, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(100); + 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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(80); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(70); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(100); + 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_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(100); + + expect(root_child0_child1.getComputedLeft()).toBe(10); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_pos_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPosition(Edge.Right, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(100); + 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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(80); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(70); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(100); + 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_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(100); + + expect(root_child0_child1.getComputedLeft()).toBe(10); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_pos_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPosition(Edge.End, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(100); + 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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(80); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(70); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(100); + 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_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(100); + + expect(root_child0_child1.getComputedLeft()).toBe(10); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(20); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column_reverse_pos_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPosition(Edge.Top, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + 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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_column_reverse_pos_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPosition(Edge.Bottom, 100); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + 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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(-100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(0); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_pos_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_pos_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_pos_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_pos_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('flex_direction_row_reverse_inner_pos_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Start, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('flex_direction_row_reverse_inner_pos_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.End, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_margin_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_margin_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_margin_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_margin_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_marign_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Start, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_margin_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.End, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_border_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_border_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_border_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_border_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_border_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_border_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_padding_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_padding_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_padding_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_padding_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_padding_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Start, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_padding_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.End, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setWidth(10); + 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(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_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + 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(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_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(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_alternating_with_percent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setPosition(Edge.Left, "10%"); + root_child0.setPosition(Edge.Top, "10%"); + root_child0.setWidth("50%"); + root_child0.setHeight("50%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(30); + 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(200); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(120); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexTest.test.ts new file mode 100644 index 0000000..6eee8e8 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexTest.test.ts @@ -0,0 +1,677 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGFlexTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('flex_basis_flex_grow_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(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(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(75); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(75); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_shrink_flex_grow_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setWidth(500); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexShrink(1); + root_child1.setWidth(500); + 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(500); + 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(100); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + 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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(250); + 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(250); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_shrink_flex_grow_child_flex_shrink_other_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setWidth(500); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setWidth(500); + 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(500); + 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(100); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(250); + 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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(250); + 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(250); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_basis_flex_grow_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(75); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(25); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(25); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(75); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_basis_flex_shrink_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexBasis(50); + 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(100); + 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(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); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_basis_flex_shrink_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexBasis(50); + 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(100); + + expect(root_child1.getComputedLeft()).toBe(50); + 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(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(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('flex_shrink_to_zero', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(75); + + 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.setFlexShrink(1); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(50); + expect(root.getComputedHeight()).toBe(75); + + 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(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(75); + + 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(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_basis_overrides_main_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(100); + 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(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(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_shrink_at_most', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexShrink(1); + 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(100); + 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(100); + 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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + 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(100); + expect(root_child0_child0.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_less_than_factor_one', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(0.2); + root_child0.setFlexBasis(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(0.2); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(0.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(200); + 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(132); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(132); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(92); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(224); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(184); + + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(132); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(132); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(92); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(224); + expect(root_child2.getComputedWidth()).toBe(200); + expect(root_child2.getComputedHeight()).toBe(184); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexWrapTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexWrapTest.test.ts new file mode 100644 index 0000000..28ee4ce --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGFlexWrapTest.test.ts @@ -0,0 +1,2071 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGFlexWrapTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('wrap_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(30); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(30); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + 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(60); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(60); + expect(root_child2.getComputedWidth()).toBe(30); + 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); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(30); + expect(root_child2.getComputedTop()).toBe(60); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(30); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(30); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + 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(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + 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(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(30); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_row_align_items_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + 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(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + 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(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_row_align_items_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + 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(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(5); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + 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(100); + expect(root.getComputedHeight()).toBe(60); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(5); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(30); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(30); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_wrap_children_with_min_main_overriding_flex_basis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexBasis(50); + root_child0.setMinWidth(55); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexBasis(50); + root_child1.setMinWidth(55); + root_child1.setHeight(50); + 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(55); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(55); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(45); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(55); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(45); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(55); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_wrap_wrap_to_child_height', () => { + 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.setFlexDirection(FlexDirection.Row); + root_child0.setAlignItems(Align.FlexStart); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(100); + root_child0_child0_child0.setHeight(100); + root_child0_child0.insertChild(root_child0_child0_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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + 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(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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_wrap_align_stretch_fits_one_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(150); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + 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(150); + 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(0); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + 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(150); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_reverse_row_align_content_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + 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(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + 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(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_reverse_row_align_content_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + 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(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + 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(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_reverse_row_single_line_different_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + 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(300); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(90); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(120); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + 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(300); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(270); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(240); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(210); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(180); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(150); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_reverse_row_align_content_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + 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(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + 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(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_reverse_row_align_content_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + 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(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + 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(100); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(70); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(10); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(40); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_reverse_column_fixed_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.WrapReverse); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(30); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(30); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + root_child2.setHeight(30); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(30); + root_child3.setHeight(40); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(30); + root_child4.setHeight(50); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(170); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(170); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(170); + expect(root_child2.getComputedTop()).toBe(30); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(170); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(140); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + 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(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(30); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(30); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(30); + expect(root_child3.getComputedHeight()).toBe(40); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(30); + expect(root_child4.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrapped_row_within_align_items_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(150); + root_child0_child0.setHeight(80); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(80); + root_child0_child1.setHeight(80); + root_child0.insertChild(root_child0_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(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(120); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrapped_row_within_align_items_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(150); + root_child0_child0.setHeight(80); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(80); + root_child0_child1.setHeight(80); + root_child0.insertChild(root_child0_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(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(120); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrapped_row_within_align_items_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(150); + root_child0_child0.setHeight(80); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(80); + root_child0_child1.setHeight(80); + root_child0.insertChild(root_child0_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(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(160); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(150); + expect(root_child0_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child1.getComputedLeft()).toBe(120); + expect(root_child0_child1.getComputedTop()).toBe(80); + expect(root_child0_child1.getComputedWidth()).toBe(80); + expect(root_child0_child1.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrapped_column_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignContent(Align.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(700); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(500); + root_child0.setMaxHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Left, 20); + root_child1.setMargin(Edge.Top, 20); + root_child1.setMargin(Edge.Right, 20); + root_child1.setMargin(Edge.Bottom, 20); + root_child1.setWidth(200); + root_child1.setHeight(200); + 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(700); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(250); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(200); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(420); + 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(700); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(350); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(300); + expect(root_child1.getComputedTop()).toBe(250); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(200); + + expect(root_child2.getComputedLeft()).toBe(180); + 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('wrapped_column_max_height_flex', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignContent(Align.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(700); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setWidth(100); + root_child0.setHeight(500); + root_child0.setMaxHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setMargin(Edge.Left, 20); + root_child1.setMargin(Edge.Top, 20); + root_child1.setMargin(Edge.Right, 20); + root_child1.setMargin(Edge.Bottom, 20); + root_child1.setWidth(200); + root_child1.setHeight(200); + 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(700); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(180); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(180); + + expect(root_child2.getComputedLeft()).toBe(300); + 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(700); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(300); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(180); + + expect(root_child1.getComputedLeft()).toBe(250); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(180); + + expect(root_child2.getComputedLeft()).toBe(300); + 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('wrap_nodes_with_content_sizing_overflowing_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth(85); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(40); + root_child0_child0_child0.setHeight(40); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setMargin(Edge.Right, 10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child1_child0.setWidth(40); + root_child0_child1_child0.setHeight(40); + root_child0_child1.insertChild(root_child0_child1_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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(85); + 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(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(40); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(40); + expect(root_child0_child1_child0.getComputedHeight()).toBe(40); + + 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(415); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(85); + expect(root_child0.getComputedHeight()).toBe(80); + + expect(root_child0_child0.getComputedLeft()).toBe(45); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(35); + expect(root_child0_child1.getComputedTop()).toBe(40); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(40); + expect(root_child0_child1_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_nodes_with_content_sizing_margin_cross', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setFlexWrap(Wrap.Wrap); + root_child0.setWidth(70); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(40); + root_child0_child0_child0.setHeight(40); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setMargin(Edge.Top, 10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child1_child0.setWidth(40); + root_child0_child1_child0.setHeight(40); + root_child0_child1.insertChild(root_child0_child1_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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(70); + expect(root_child0.getComputedHeight()).toBe(90); + + 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_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(40); + expect(root_child0_child1_child0.getComputedHeight()).toBe(40); + + 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(430); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(70); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child0_child0.getComputedLeft()).toBe(30); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(40); + + expect(root_child0_child1.getComputedLeft()).toBe(30); + expect(root_child0_child1.getComputedTop()).toBe(50); + expect(root_child0_child1.getComputedWidth()).toBe(40); + expect(root_child0_child1.getComputedHeight()).toBe(40); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(40); + expect(root_child0_child1_child0.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_with_min_cross_axis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMinHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + 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(500); + expect(root.getComputedHeight()).toBe(500); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_with_max_cross_axis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(500); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(400); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(400); + root_child1.setHeight(200); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + 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(500); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(100); + expect(root_child1.getComputedTop()).toBe(200); + expect(root_child1.getComputedWidth()).toBe(400); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('nowrap_expands_flexline_box_to_min_cross', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinHeight(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(400); + + 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(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(400); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('wrap_does_not_impose_min_cross_onto_single_flexline', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setMinHeight(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + 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(400); + + 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(400); + + 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/tests/taffyjs-yoga/yoga-official/tests/generated/YGGapTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGGapTest.test.ts new file mode 100644 index 0000000..d38f592 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGGapTest.test.ts @@ -0,0 +1,3303 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGGapTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('column_gap_flexible', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(80); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_inflexible', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(80); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_mixed_flexible', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(80); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_child_margins', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(80); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setMargin(Edge.Left, 2); + root_child0.setMargin(Edge.Right, 2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setMargin(Edge.Left, 10); + root_child1.setMargin(Edge.Right, 10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + root_child2.setMargin(Edge.Left, 15); + root_child2.setMargin(Edge.Right, 15); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(2); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(26); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(2); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(63); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(2); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(76); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(52); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(2); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(15); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(2); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_row_gap_wrapping', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(80); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + 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_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + 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_child7 = Yoga.Node.create(config); + root_child7.setWidth(20); + root_child7.setHeight(20); + root.insertChild(root_child7, 7); + + 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(80); + expect(root.getComputedHeight()).toBe(100); + + 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(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + 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(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + 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(80); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(30); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(20); + expect(root_child7.getComputedHeight()).toBe(20); + + expect(root_child8.getComputedLeft()).toBe(60); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + 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(60); + expect(root_child3.getComputedTop()).toBe(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(0); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + + expect(root_child6.getComputedLeft()).toBe(60); + expect(root_child6.getComputedTop()).toBe(80); + expect(root_child6.getComputedWidth()).toBe(20); + expect(root_child6.getComputedHeight()).toBe(20); + + expect(root_child7.getComputedLeft()).toBe(30); + expect(root_child7.getComputedTop()).toBe(80); + expect(root_child7.getComputedWidth()).toBe(20); + expect(root_child7.getComputedHeight()).toBe(20); + + expect(root_child8.getComputedLeft()).toBe(0); + 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(); + } +}); +test('column_gap_start_index', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(80); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + 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.setWidth(20); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root_child3.setHeight(20); + 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(80); + expect(root.getComputedHeight()).toBe(20); + + 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(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(30); + 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(20); + 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(80); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(60); + 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(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(30); + 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(20); + expect(root_child3.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_justify_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_justify_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(70); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_justify_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_justify_space_between', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_justify_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(3); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(77); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(77); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(3); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_justify_space_evenly', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(5); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_wrap_align_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + 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_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + 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); + 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(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + 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(40); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(40); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.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(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(20); + 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(20); + expect(root_child3.getComputedHeight()).toBe(20); + + 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(20); + expect(root_child5.getComputedTop()).toBe(40); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_wrap_align_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + 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_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + 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); + 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(20); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + 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(60); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(60); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(60); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.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(80); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + 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(80); + expect(root_child3.getComputedTop()).toBe(60); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(60); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(60); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_wrap_align_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + 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_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + 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); + 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(40); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.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(80); + expect(root_child0.getComputedTop()).toBe(40); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(40); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(40); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(80); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_wrap_align_space_between', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + 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_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + 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); + 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(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + 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(80); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.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(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(20); + 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(80); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(80); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(80); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_wrap_align_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + 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_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root_child2.setHeight(20); + root.insertChild(root_child2, 2); + + 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); + 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(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(10); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(20); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(70); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(70); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(70); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.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(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(20); + + 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_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(70); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(20); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(70); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(20); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(70); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_wrap_align_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setHeight(300); + root.setGap(Gutter.Column, 5); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinWidth(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setMinWidth(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setMinWidth(60); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root_child3.setMinWidth(60); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setFlexGrow(1); + root_child4.setMinWidth(60); + 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(300); + expect(root.getComputedHeight()).toBe(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(71); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(76); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(72); + expect(root_child1.getComputedHeight()).toBe(150); + + expect(root_child2.getComputedLeft()).toBe(153); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(71); + expect(root_child2.getComputedHeight()).toBe(150); + + expect(root_child3.getComputedLeft()).toBe(229); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(71); + expect(root_child3.getComputedHeight()).toBe(150); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(150); + expect(root_child4.getComputedWidth()).toBe(300); + expect(root_child4.getComputedHeight()).toBe(150); + + 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(229); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(71); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(153); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(71); + expect(root_child1.getComputedHeight()).toBe(150); + + expect(root_child2.getComputedLeft()).toBe(76); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(72); + expect(root_child2.getComputedHeight()).toBe(150); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(71); + expect(root_child3.getComputedHeight()).toBe(150); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(150); + expect(root_child4.getComputedWidth()).toBe(300); + expect(root_child4.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_gap_determines_parent_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setHeight(100); + root.setGap(Gutter.Column, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(30); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(50); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + 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(80); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(70); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_align_items_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(200); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + 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(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(90); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(110); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(90); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(90); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(110); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.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(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(90); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(90); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(90); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(110); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(90); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(110); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(90); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(110); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(90); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_align_items_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(200); + root.setGap(Gutter.Column, 10); + root.setGap(Gutter.Row, 20); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setWidth(20); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(20); + root.insertChild(root_child4, 4); + + const root_child5 = Yoga.Node.create(config); + root_child5.setWidth(20); + 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(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(0); + expect(root_child3.getComputedTop()).toBe(20); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(30); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(60); + expect(root_child5.getComputedTop()).toBe(20); + expect(root_child5.getComputedWidth()).toBe(20); + 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(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(0); + + expect(root_child3.getComputedLeft()).toBe(80); + expect(root_child3.getComputedTop()).toBe(20); + expect(root_child3.getComputedWidth()).toBe(20); + expect(root_child3.getComputedHeight()).toBe(0); + + expect(root_child4.getComputedLeft()).toBe(50); + expect(root_child4.getComputedTop()).toBe(20); + expect(root_child4.getComputedWidth()).toBe(20); + expect(root_child4.getComputedHeight()).toBe(0); + + expect(root_child5.getComputedLeft()).toBe(20); + expect(root_child5.getComputedTop()).toBe(20); + expect(root_child5.getComputedWidth()).toBe(20); + expect(root_child5.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_column_child_margins', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(200); + root.setGap(Gutter.Row, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setMargin(Edge.Top, 2); + root_child0.setMargin(Edge.Bottom, 2); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root_child1.setMargin(Edge.Top, 10); + root_child1.setMargin(Edge.Bottom, 10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + root_child2.setMargin(Edge.Top, 15); + root_child2.setMargin(Edge.Bottom, 15); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(42); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(66); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(42); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(143); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(42); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(42); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(66); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(42); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(143); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(42); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_row_wrap_child_margins', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(100); + root.setHeight(200); + root.setGap(Gutter.Row, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 2); + root_child0.setMargin(Edge.Bottom, 2); + root_child0.setWidth(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Top, 10); + root_child1.setMargin(Edge.Bottom, 10); + root_child1.setWidth(60); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Top, 15); + root_child2.setMargin(Edge.Bottom, 15); + root_child2.setWidth(60); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(24); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(59); + expect(root_child2.getComputedWidth()).toBe(60); + 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(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(2); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(0); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(24); + expect(root_child1.getComputedWidth()).toBe(60); + expect(root_child1.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(59); + expect(root_child2.getComputedWidth()).toBe(60); + expect(root_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_determines_parent_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setGap(Gutter.Row, 10); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(30); + 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(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(30); + + 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(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(50); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(30); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_percent_wrapping', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + 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); + + const root_child4 = Yoga.Node.create(config); + 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(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(138); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(138); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(10); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + 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(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(190); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(62); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(190); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(62); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(190); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_percent_determines_parent_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setWidth(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + 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); + + const root_child4 = Yoga.Node.create(config); + 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(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(130); + 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(100); + + expect(root_child3.getComputedLeft()).toBe(130); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(200); + expect(root_child4.getComputedWidth()).toBe(100); + 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(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(70); + 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(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(200); + expect(root_child4.getComputedTop()).toBe(200); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_percent_wrapping_with_both_content_padding_and_item_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + 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.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setPadding(Edge.Left, 10); + root_child1.setPadding(Edge.Top, 10); + root_child1.setPadding(Edge.Right, 10); + root_child1.setPadding(Edge.Bottom, 10); + 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, 10); + root_child2.setPadding(Edge.Top, 10); + root_child2.setPadding(Edge.Right, 10); + root_child2.setPadding(Edge.Bottom, 10); + root_child2.setWidth(100); + root_child2.setHeight(100); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setPadding(Edge.Left, 10); + root_child3.setPadding(Edge.Top, 10); + root_child3.setPadding(Edge.Right, 10); + root_child3.setPadding(Edge.Bottom, 10); + root_child3.setWidth(100); + root_child3.setHeight(100); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setPadding(Edge.Left, 10); + root_child4.setPadding(Edge.Top, 10); + root_child4.setPadding(Edge.Right, 10); + root_child4.setPadding(Edge.Bottom, 10); + 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(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(138); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(138); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(10); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + 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(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(190); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(62); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(190); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(62); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(190); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_percent_wrapping_with_both_content_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + 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); + + const root_child4 = Yoga.Node.create(config); + 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(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(138); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(138); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(10); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + 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(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(190); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(62); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(190); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(62); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(190); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_percent_wrapping_with_content_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setMargin(Edge.Left, 10); + root.setMargin(Edge.Top, 10); + root.setMargin(Edge.Right, 10); + root.setMargin(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + 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); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(100); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + 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(130); + 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(170); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(130); + expect(root_child3.getComputedTop()).toBe(170); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(340); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + 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(70); + 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(170); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(170); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(200); + expect(root_child4.getComputedTop()).toBe(340); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_percent_wrapping_with_content_margin_and_padding', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setMargin(Edge.Left, 10); + root.setMargin(Edge.Top, 10); + root.setMargin(Edge.Right, 10); + root.setMargin(Edge.Bottom, 10); + root.setPadding(Edge.Left, 10); + root.setPadding(Edge.Top, 10); + root.setPadding(Edge.Right, 10); + root.setPadding(Edge.Bottom, 10); + root.setWidth(300); + root.setHeight(700); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + 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); + + const root_child4 = Yoga.Node.create(config); + root_child4.setWidth(100); + root_child4.setHeight(100); + root.insertChild(root_child4, 4); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(138); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(10); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(138); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(10); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(10); + expect(root.getComputedTop()).toBe(10); + expect(root.getComputedWidth()).toBe(300); + expect(root.getComputedHeight()).toBe(700); + + expect(root_child0.getComputedLeft()).toBe(190); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(62); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(190); + expect(root_child2.getComputedTop()).toBe(178); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(62); + expect(root_child3.getComputedTop()).toBe(178); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(190); + expect(root_child4.getComputedTop()).toBe(346); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_percent_wrapping_with_flexible_content', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setFlexShrink(1); + root_child2.setFlexBasis("0%"); + 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(80); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(220); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(80); + expect(root_child2.getComputedHeight()).toBe(300); + + 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(220); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child1.getComputedLeft()).toBe(110); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(80); + expect(root_child2.getComputedHeight()).toBe(300); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('row_gap_percent_wrapping_with_mixed_flexible_content', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + root.setHeight(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root_child1.setFlexBasis("0%"); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("10%"); + 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(10); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(270); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(300); + + 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(290); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(300); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(300); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(300); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('row_gap_percent_wrapping_with_min_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setFlexWrap(Wrap.Wrap); + root.setMinWidth(300); + root.setGap(Gutter.Column, "10%"); + root.setGap(Gutter.Row, "10%"); + + 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); + + const root_child4 = Yoga.Node.create(config); + 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(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(130); + 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(100); + + expect(root_child3.getComputedLeft()).toBe(130); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(200); + expect(root_child4.getComputedWidth()).toBe(100); + 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(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(70); + 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(100); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(70); + expect(root_child3.getComputedTop()).toBe(100); + expect(root_child3.getComputedWidth()).toBe(100); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(200); + expect(root_child4.getComputedTop()).toBe(200); + expect(root_child4.getComputedWidth()).toBe(100); + expect(root_child4.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGIntrinsicSizeTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGIntrinsicSizeTest.test.ts new file mode 100644 index 0000000..b0f27c0 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGIntrinsicSizeTest.test.ts @@ -0,0 +1,546 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<a72fad411393a654b0a1e819be511d73>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGIntrinsicSizeTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('contains_inner_text_long_word', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("LoremipsumdolorsitametconsecteturadipiscingelitSedeleifasdfettortoracauctorFuscerhoncusipsumtemporerosaliquamconsequatPraesentsoda")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1300); + 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(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(700); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1300); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_no_width_no_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(70); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(70); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_no_width_no_height_long_word_in_paragraph', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus loremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumlorem Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(70); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(70); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_fixed_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(100); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(1290); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1900); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(1290); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_no_width_fixed_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + 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(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_fixed_width_fixed_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + 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(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1950); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_max_width_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(50); + root_child0.setMaxHeight(20); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + 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(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1950); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(100); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(1290); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1900); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(1290); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_fixed_width_shorter_text', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(100); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + 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(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1900); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_fixed_height_shorter_text', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(110); + 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(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(1890); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(110); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('contains_inner_text_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(2000); + root.setHeight(2000); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxHeight(20); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + 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(2000); + expect(root.getComputedHeight()).toBe(2000); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(2000); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGJustifyContentTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGJustifyContentTest.test.ts new file mode 100644 index 0000000..63f814f --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGJustifyContentTest.test.ts @@ -0,0 +1,2150 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<d9c3d3430edadef3cd6ba8bbacbb31a2>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGJustifyContentTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('justify_content_row_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(20); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(92); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(82); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(72); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_row_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(72); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(82); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(92); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(10); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_row_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(36); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(56); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(56); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(36); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_row_space_between', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(92); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(92); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_row_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(12); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(46); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(12); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_column_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(10); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_column_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(72); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(82); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(92); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(72); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(82); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(92); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_column_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(36); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(56); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(36); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(56); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_column_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(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(92); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(92); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_column_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(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_row_min_width_and_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Left, 100); + root.setMinWidth(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(50); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(15); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_row_max_width_and_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Left, 100); + root.setWidth(100); + root.setMaxWidth(80); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(100); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(80); + expect(root.getComputedHeight()).toBe(20); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_column_min_height_and_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 100); + root.setMinHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(15); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_column_max_height_and_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMargin(Edge.Top, 100); + root.setHeight(100); + root.setMaxHeight(80); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(100); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(80); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(30); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_column_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(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(74); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(18); + expect(root_child0.getComputedWidth()).toBe(102); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(46); + expect(root_child1.getComputedWidth()).toBe(102); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(74); + expect(root_child2.getComputedWidth()).toBe(102); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_row_space_evenly', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setHeight(10); + 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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(26); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(51); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(77); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(77); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(51); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(26); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(0); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_min_width_with_padding_child_width_greater_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(1000); + root.setHeight(1584); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setAlignContent(Align.Stretch); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0.setJustifyContent(Justify.Center); + root_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0.setPadding(Edge.Left, 100); + root_child0_child0.setPadding(Edge.Right, 100); + root_child0_child0.setMinWidth(400); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0.setWidth(300); + root_child0_child0_child0.setHeight(100); + 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(1000); + expect(root.getComputedHeight()).toBe(1584); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1000); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(300); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1000); + expect(root.getComputedHeight()).toBe(1584); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1000); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(500); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(500); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(300); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_min_width_with_padding_child_width_lower_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignContent(Align.Stretch); + root.setPositionType(PositionType.Absolute); + root.setWidth(1080); + root.setHeight(1584); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setAlignContent(Align.Stretch); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0.setJustifyContent(Justify.Center); + root_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0.setPadding(Edge.Left, 100); + root_child0_child0.setPadding(Edge.Right, 100); + root_child0_child0.setMinWidth(400); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0_child0.setAlignContent(Align.Stretch); + root_child0_child0_child0.setWidth(199); + root_child0_child0_child0.setHeight(100); + 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(1080); + expect(root.getComputedHeight()).toBe(1584); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1080); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(400); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(101); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(199); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(1080); + expect(root.getComputedHeight()).toBe(1584); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(1080); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(680); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(400); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(101); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(199); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_space_between_indefinite_container_dim_with_free_space', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(300); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setJustifyContent(Justify.SpaceBetween); + root_child0.setMinWidth(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(50); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0_child1.setHeight(50); + root_child0.insertChild(root_child0_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(50); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + 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(50); + + expect(root_child0_child1.getComputedLeft()).toBe(150); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(50); + + 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(50); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0.getComputedLeft()).toBe(150); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_flex_start_row_reverse', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_flex_end_row_reverse', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(60); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(20); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(20); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(20); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(20); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_overflow_row_flex_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_overflow_row_flex_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(-18); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(62); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_overflow_row_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(-9); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(31); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(71); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(71); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(31); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-9); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_overflow_row_space_between', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceBetween); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_overflow_row_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_overflow_row_space_evenly', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('justify_content_overflow_row_reverse_space_around', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setJustifyContent(Justify.SpaceAround); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(-18); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(62); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('justify_content_overflow_row_reverse_space_evenly', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.RowReverse); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(-18); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(62); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_overflow_row_space_evenly_auto_margin', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.SpaceEvenly); + root.setPositionType(PositionType.Absolute); + root.setWidth(102); + root.setHeight(102); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(40); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(40); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(80); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(102); + expect(root.getComputedHeight()).toBe(102); + + expect(root_child0.getComputedLeft()).toBe(62); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(40); + expect(root_child0.getComputedHeight()).toBe(102); + + expect(root_child1.getComputedLeft()).toBe(22); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(102); + + expect(root_child2.getComputedLeft()).toBe(-18); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(40); + expect(root_child2.getComputedHeight()).toBe(102); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGMarginTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGMarginTest.test.ts new file mode 100644 index 0000000..8046de5 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGMarginTest.test.ts @@ -0,0 +1,1963 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGMarginTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('margin_start', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Start, 10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.End, 10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Bottom, 10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(80); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_and_flex_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Start, 10); + root_child0.setMargin(Edge.End, 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_and_flex_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Top, 10); + root_child0.setMargin(Edge.Bottom, 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.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(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_and_stretch_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Top, 10); + root_child0.setMargin(Edge.Bottom, 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.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(10); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_and_stretch_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Start, 10); + root_child0.setMargin(Edge.End, 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_with_sibling_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.End, 10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(45); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(55); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(45); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(55); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(45); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(45); + expect(root_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_with_sibling_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMargin(Edge.Bottom, 10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(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(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(45); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(45); + + 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(45); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(55); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(45); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(75); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_bottom_and_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + 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(50); + 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); + 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(75); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_bottom_and_top_justify_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); + + 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(50); + 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); + 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(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_multiple_children_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Top, 'auto'); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(25); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(25); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(100); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(75); + expect(root_child2.getComputedTop()).toBe(150); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_multiple_children_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setMargin(Edge.Right, 'auto'); + root_child1.setWidth(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(150); + expect(root_child2.getComputedTop()).toBe(75); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(125); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(50); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(75); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_left_and_right_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_left_and_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(75); + 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(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + 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(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_start_and_end_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Start, 'auto'); + root_child0.setMargin(Edge.End, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(75); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_start_and_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Start, 'auto'); + root_child0.setMargin(Edge.End, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(75); + 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(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + 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(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_left_and_right_column_and_center', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_left', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + 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(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(75); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_left_and_right_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(50); + 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); + 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(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(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(100); + 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(0); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_top_and_bottom_stretch', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + 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(50); + 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); + 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(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(50); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(150); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_should_not_be_part_of_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(250); + root.setHeight(250); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Top, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root_child0.setMaxHeight(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(250); + expect(root.getComputedHeight()).toBe(250); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(250); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_should_not_be_part_of_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(250); + root.setHeight(250); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 20); + root_child0.setWidth(100); + root_child0.setMaxWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(250); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(250); + expect(root.getComputedHeight()).toBe(250); + + expect(root_child0.getComputedLeft()).toBe(150); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_left_right_child_bigger_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(72); + root_child0.setHeight(72); + 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(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-20); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_left_child_bigger_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setWidth(72); + root_child0.setHeight(72); + 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(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-20); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_fix_left_auto_right_child_bigger_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 10); + root_child0.setMargin(Edge.Right, 'auto'); + root_child0.setWidth(72); + root_child0.setHeight(72); + 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(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-20); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_left_fix_right_child_bigger_than_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(52); + root.setHeight(52); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Left, 'auto'); + root_child0.setMargin(Edge.Right, 10); + root_child0.setWidth(72); + root_child0.setHeight(72); + 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(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(52); + expect(root.getComputedHeight()).toBe(52); + + expect(root_child0.getComputedLeft()).toBe(-30); + expect(root_child0.getComputedTop()).toBe(-10); + expect(root_child0.getComputedWidth()).toBe(72); + expect(root_child0.getComputedHeight()).toBe(72); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_top_stretching_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setMargin(Edge.Top, 'auto'); + 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); + 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(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_left_stretching_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis("0%"); + root_child0.setMargin(Edge.Left, 'auto'); + 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); + 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(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(200); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('margin_auto_overflowing_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Bottom, 'auto'); + root_child0.setWidth(50); + root_child0.setHeight(150); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth(50); + root_child1.setHeight(150); + 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(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(150); + + expect(root_child1.getComputedLeft()).toBe(75); + expect(root_child1.getComputedTop()).toBe(150); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGMinMaxDimensionTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGMinMaxDimensionTest.test.ts new file mode 100644 index 0000000..dfe3773 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGMinMaxDimensionTest.test.ts @@ -0,0 +1,1446 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMaxWidth(50); + root_child0.setHeight(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(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(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(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setMaxHeight(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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinHeight(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(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(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(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(100); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(60); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('min_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinWidth(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + 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(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + 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(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_min_max', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setMinHeight(100); + root.setMaxHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(60); + root_child0.setHeight(60); + 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(20); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.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(40); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_items_min_max', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(100); + root.setMaxWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(60); + root_child0.setHeight(60); + 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(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.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(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('justify_content_overflow_min_max', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setPositionType(PositionType.Absolute); + root.setMinHeight(100); + root.setMaxHeight(110); + + 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(50); + root_child1.setHeight(50); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(50); + root_child2.setHeight(50); + 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(50); + expect(root.getComputedHeight()).toBe(110); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-20); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + 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(110); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(-20); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(30); + expect(root_child1.getComputedWidth()).toBe(50); + expect(root_child1.getComputedHeight()).toBe(50); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(80); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_to_min', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setMinHeight(100); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexShrink(1); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(50); + 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(100); + 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(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); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_in_at_most_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexBasis(0); + 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(); + } +}); +test('flex_grow_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(0); + 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(0); + 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(100); + + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_within_constrained_min_max_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMinHeight(100); + root.setMaxHeight(200); + + 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.setHeight(50); + 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(0); + 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(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + 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(0); + 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(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_within_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setHeight(20); + 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(100); + + 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_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(20); + + 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(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(20); + + 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(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_within_constrained_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(300); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setHeight(20); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + 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(20); + + 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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(20); + + 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(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_root_ignored', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setFlexGrow(1); + root.setWidth(100); + root.setMinHeight(100); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(200); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + 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(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(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(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(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('flex_grow_root_minimized', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setMinHeight(100); + root.setMaxHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinHeight(100); + root_child0.setMaxHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexBasis(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(300); + + 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(200); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_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(300); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(300); + + 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(200); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_height_maximized', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinHeight(100); + root_child0.setMaxHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexBasis(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(500); + + 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(400); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(400); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_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(500); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(500); + + 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(400); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(400); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_within_constrained_min_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(100); + root.setHeight(100); + + 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(50); + 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(100); + + expect(root_child1.getComputedLeft()).toBe(50); + 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(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(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('flex_grow_within_constrained_min_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMinHeight(100); + + 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.setHeight(50); + 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(0); + 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(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + 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(0); + 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(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(0); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_within_constrained_max_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setMaxWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexShrink(1); + root_child0_child0.setFlexBasis(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setWidth(50); + root_child0.insertChild(root_child0_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(100); + expect(root_child0.getComputedHeight()).toBe(100); + + 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(100); + + expect(root_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_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(100); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child1.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_grow_within_constrained_max_column', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setMaxHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setHeight(50); + 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(100); + 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(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); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('child_min_max_width_flexing', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(120); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(0); + root_child0.setMinWidth(60); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexBasis("50%"); + root_child1.setMaxWidth(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(120); + 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(120); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + 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('min_width_overrides_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(50); + root.setMinWidth(100); + 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(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(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('max_width_overrides_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setMaxWidth(100); + 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(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(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('min_height_overrides_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(50); + root.setMinHeight(100); + 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(100); + + 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(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('max_height_overrides_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(200); + root.setMaxHeight(100); + 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(100); + + 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(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('min_max_percent_no_width_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMinWidth("10%"); + root_child0.setMaxWidth("10%"); + root_child0.setMinHeight("10%"); + root_child0.setMaxHeight("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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGPaddingTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGPaddingTest.test.ts new file mode 100644 index 0000000..474a808 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGPaddingTest.test.ts @@ -0,0 +1,354 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGPaddingTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('padding_no_size', () => { + 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.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(20); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(20); + expect(root.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('padding_container_match_child', () => { + 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); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(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(30); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + 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(30); + expect(root.getComputedHeight()).toBe(30); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('padding_flex_child', () => { + 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.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.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(80); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('padding_stretch_child', () => { + 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.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(10); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(80); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('padding_center_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Start, 10); + root.setPadding(Edge.End, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(10); + root_child0.setHeight(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(35); + expect(root_child0.getComputedWidth()).toBe(10); + 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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(35); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('child_with_padding_align_end', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.FlexEnd); + root.setAlignItems(Align.FlexEnd); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + 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(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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(100); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(100); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('physical_and_relative_edge_defined', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.End, 50); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("100%"); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(130); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(150); + expect(root_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGPercentageTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGPercentageTest.test.ts new file mode 100644 index 0000000..4f95fb2 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGPercentageTest.test.ts @@ -0,0 +1,1760 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('percentage_width_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("30%"); + root_child0.setHeight("30%"); + 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(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.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(200); + + expect(root_child0.getComputedLeft()).toBe(140); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + expect(root_child0.getComputedHeight()).toBe(60); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_position_left_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(400); + root.setHeight(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Left, "10%"); + root_child0.setPosition(Edge.Top, "20%"); + root_child0.setWidth("45%"); + root_child0.setHeight("55%"); + 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(400); + + expect(root_child0.getComputedLeft()).toBe(40); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(180); + expect(root_child0.getComputedHeight()).toBe(220); + + 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(260); + expect(root_child0.getComputedTop()).toBe(80); + expect(root_child0.getComputedWidth()).toBe(180); + expect(root_child0.getComputedHeight()).toBe(220); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_position_bottom_right', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(500); + root.setHeight(500); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPosition(Edge.Right, "20%"); + root_child0.setPosition(Edge.Bottom, "10%"); + root_child0.setWidth("55%"); + root_child0.setHeight("15%"); + 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(500); + + expect(root_child0.getComputedLeft()).toBe(-100); + expect(root_child0.getComputedTop()).toBe(-50); + expect(root_child0.getComputedWidth()).toBe(275); + expect(root_child0.getComputedHeight()).toBe(75); + + 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(125); + expect(root_child0.getComputedTop()).toBe(-50); + expect(root_child0.getComputedWidth()).toBe(275); + expect(root_child0.getComputedHeight()).toBe(75); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_flex_basis', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("50%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexBasis("25%"); + 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(125); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(125); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(75); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(75); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(125); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(75); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_flex_basis_cross', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("50%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setFlexBasis("25%"); + 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(200); + expect(root_child0.getComputedHeight()).toBe(125); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(125); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(75); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(125); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(125); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(75); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('percentage_flex_basis_cross_min_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setMinHeight("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(2); + root_child1.setMinHeight("10%"); + 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(200); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(120); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(120); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(80); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_flex_basis_main_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + root_child0.setMaxHeight("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("10%"); + root_child1.setMaxHeight("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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(52); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(52); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(148); + 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(148); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(52); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(148); + expect(root_child1.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_flex_basis_cross_max_height', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + root_child0.setMaxHeight("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("10%"); + root_child1.setMaxHeight("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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(120); + 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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(120); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(120); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(40); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_flex_basis_main_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("15%"); + root_child0.setMaxWidth("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("10%"); + root_child1.setMaxWidth("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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(40); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_flex_basis_cross_max_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + root_child0.setMaxWidth("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("15%"); + root_child1.setMaxWidth("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(200); + expect(root.getComputedHeight()).toBe(200); + + 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(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(40); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(160); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(40); + expect(root_child1.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_flex_basis_main_min_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("15%"); + root_child0.setMinWidth("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("10%"); + root_child1.setMinWidth("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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(120); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(80); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(120); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(80); + expect(root_child1.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_flex_basis_cross_min_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + root_child0.setMinWidth("60%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(4); + root_child1.setFlexBasis("15%"); + root_child1.setMinWidth("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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + 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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(50); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(50); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(150); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_multiple_nested_with_padding_margin_and_percentage_values', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis("10%"); + 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.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.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_child1.setFlexGrow(4); + root_child1.setFlexBasis("15%"); + root_child1.setMinWidth("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(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(190); + expect(root_child0.getComputedHeight()).toBe(48); + + expect(root_child0_child0.getComputedLeft()).toBe(8); + expect(root_child0_child0.getComputedTop()).toBe(8); + expect(root_child0_child0.getComputedWidth()).toBe(92); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0_child0.getComputedWidth()).toBe(36); + expect(root_child0_child0_child0.getComputedHeight()).toBe(6); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(58); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(142); + + 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(5); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(190); + expect(root_child0.getComputedHeight()).toBe(48); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(8); + expect(root_child0_child0.getComputedWidth()).toBe(92); + expect(root_child0_child0.getComputedHeight()).toBe(25); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(46); + expect(root_child0_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0_child0.getComputedWidth()).toBe(36); + expect(root_child0_child0_child0.getComputedHeight()).toBe(6); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(58); + expect(root_child1.getComputedWidth()).toBe(200); + expect(root_child1.getComputedHeight()).toBe(142); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_margin_should_calculate_based_only_on_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + 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.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(160); + expect(root_child0.getComputedHeight()).toBe(60); + + 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(10); + + 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(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(160); + expect(root_child0.getComputedHeight()).toBe(60); + + expect(root_child0_child0.getComputedLeft()).toBe(150); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_padding_should_calculate_based_only_on_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + 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.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + 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(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_child0_child0.getComputedLeft()).toBe(20); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + 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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(170); + expect(root_child0_child0.getComputedTop()).toBe(20); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_absolute_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, "30%"); + root_child0.setPosition(Edge.Top, "10%"); + root_child0.setWidth(10); + root_child0.setHeight(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(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + 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(200); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(60); + expect(root_child0.getComputedTop()).toBe(10); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percentage_width_height_undefined_parent_size', () => { + 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.setWidth("50%"); + root_child0.setHeight("50%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(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(); + } +}); +test('percent_within_flex_grow', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(350); + root.setHeight(100); + + 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.setFlexGrow(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setWidth("100%"); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth(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(350); + 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(150); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(150); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + expect(root_child2.getComputedLeft()).toBe(250); + 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(350); + 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(100); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(150); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(150); + expect(root_child1_child0.getComputedHeight()).toBe(0); + + 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('percentage_container_in_wrapping_container', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setJustifyContent(Justify.Center); + root.setAlignItems(Align.Center); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.Row); + root_child0_child0.setJustifyContent(Justify.Center); + root_child0_child0.setWidth("100%"); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setWidth(50); + root_child0_child0_child1.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_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(50); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(100); + 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(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(50); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child0_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(200); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(75); + expect(root_child0.getComputedWidth()).toBe(100); + 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(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child0_child1.getComputedWidth()).toBe(50); + expect(root_child0_child0_child1.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percent_absolute_position', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.Row); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setPosition(Edge.Left, "50%"); + root_child0.setWidth("100%"); + root_child0.setHeight(50); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("100%"); + 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); + 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(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + 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(60); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + 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(50); + + 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(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(60); + 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(60); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + 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(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percent_of_minmax_main', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('percent_of_min_main', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('percent_of_min_main_multiple', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setWidth("50%"); + root_child1.setHeight(20); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setWidth("50%"); + root_child2.setHeight(20); + 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(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(30); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(60); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(30); + expect(root_child1.getComputedHeight()).toBe(20); + + expect(root_child2.getComputedLeft()).toBe(-30); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(30); + expect(root_child2.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('percent_of_max_main', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + 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(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + 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(0); + 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(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percent_of_minmax_cross_stretched', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percent_absolute_of_minmax_cross_stretched', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percent_of_minmax_cross_unstretched', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('percent_of_min_cross_unstretched', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setMinWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + 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(60); + expect(root.getComputedHeight()).toBe(50); + + expect(root_child0.getComputedLeft()).toBe(30); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(30); + expect(root_child0.getComputedHeight()).toBe(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('percent_of_max_cross_unstretched', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setAlignItems(Align.FlexStart); + root.setPositionType(PositionType.Absolute); + root.setMaxWidth(60); + root.setHeight(50); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth("50%"); + root_child0.setHeight(20); + 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(50); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(0); + 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(0); + 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(20); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGRoundingTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGRoundingTest.test.ts new file mode 100644 index 0000000..ca653f1 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGRoundingTest.test.ts @@ -0,0 +1,1161 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * 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 by gentest/gentest-driver.ts from gentest/fixtures/YGRoundingTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('rounding_flex_basis_flex_grow_row_width_of_100', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + 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.setFlexGrow(1); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(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(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(33); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(33); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(34); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(67); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(33); + 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(100); + + expect(root_child0.getComputedLeft()).toBe(67); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(33); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(33); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(34); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(33); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_flex_basis_flex_grow_row_prime_number_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(113); + root.setHeight(100); + + 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.setFlexGrow(1); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root.insertChild(root_child2, 2); + + const root_child3 = Yoga.Node.create(config); + root_child3.setFlexGrow(1); + root.insertChild(root_child3, 3); + + const root_child4 = Yoga.Node.create(config); + root_child4.setFlexGrow(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(113); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(23); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(23); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(22); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(45); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(23); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(68); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(22); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(90); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(23); + 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(113); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(90); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(23); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(68); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(22); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(45); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(23); + expect(root_child2.getComputedHeight()).toBe(100); + + expect(root_child3.getComputedLeft()).toBe(23); + expect(root_child3.getComputedTop()).toBe(0); + expect(root_child3.getComputedWidth()).toBe(22); + expect(root_child3.getComputedHeight()).toBe(100); + + expect(root_child4.getComputedLeft()).toBe(0); + expect(root_child4.getComputedTop()).toBe(0); + expect(root_child4.getComputedWidth()).toBe(23); + expect(root_child4.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_flex_basis_flex_shrink_row', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(101); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexShrink(1); + root_child0.setFlexBasis(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexBasis(25); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexBasis(25); + 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(101); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(51); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(51); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(76); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + 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(101); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(50); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(51); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(25); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(25); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(25); + expect(root_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_flex_basis_overrides_main_size', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(113); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + 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(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); + + 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(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_total_fractial', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(87.4); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(0.7); + root_child0.setFlexBasis(50.3); + root_child0.setHeight(20.3); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1.6); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1.1); + root_child2.setHeight(10.7); + 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(87); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(87); + expect(root_child0.getComputedHeight()).toBe(59); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(59); + expect(root_child1.getComputedWidth()).toBe(87); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(87); + expect(root_child2.getComputedHeight()).toBe(24); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(87); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(87); + expect(root_child0.getComputedHeight()).toBe(59); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(59); + expect(root_child1.getComputedWidth()).toBe(87); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(87); + expect(root_child2.getComputedHeight()).toBe(24); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_total_fractial_nested', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(87.4); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(0.7); + root_child0.setFlexBasis(50.3); + root_child0.setHeight(20.3); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexGrow(1); + root_child0_child0.setFlexBasis(0.3); + root_child0_child0.setPosition(Edge.Bottom, 13.3); + root_child0_child0.setHeight(9.9); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setFlexGrow(4); + root_child0_child1.setFlexBasis(0.3); + root_child0_child1.setPosition(Edge.Top, 13.3); + root_child0_child1.setHeight(1.1); + root_child0.insertChild(root_child0_child1, 1); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1.6); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1.1); + root_child2.setHeight(10.7); + 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(87); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(87); + expect(root_child0.getComputedHeight()).toBe(59); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(-13); + expect(root_child0_child0.getComputedWidth()).toBe(87); + expect(root_child0_child0.getComputedHeight()).toBe(12); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(25); + expect(root_child0_child1.getComputedWidth()).toBe(87); + expect(root_child0_child1.getComputedHeight()).toBe(47); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(59); + expect(root_child1.getComputedWidth()).toBe(87); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(87); + expect(root_child2.getComputedHeight()).toBe(24); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(87); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(87); + expect(root_child0.getComputedHeight()).toBe(59); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(-13); + expect(root_child0_child0.getComputedWidth()).toBe(87); + expect(root_child0_child0.getComputedHeight()).toBe(12); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(25); + expect(root_child0_child1.getComputedWidth()).toBe(87); + expect(root_child0_child1.getComputedHeight()).toBe(47); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(59); + expect(root_child1.getComputedWidth()).toBe(87); + expect(root_child1.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(87); + expect(root_child2.getComputedHeight()).toBe(24); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_fractial_input_1', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + 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(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); + + 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(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_fractial_input_2', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(113.6); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + 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(114); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(24); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(114); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(65); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(24); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_fractial_input_3', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPosition(Edge.Top, 0.3); + root.setWidth(100); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + 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(114); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(24); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.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(114); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(65); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(24); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(25); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_fractial_input_4', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setPosition(Edge.Top, 0.7); + root.setWidth(100); + root.setHeight(113.4); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setFlexBasis(50); + root_child0.setHeight(20); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(1); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(1); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(113); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(64); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(64); + expect(root_child1.getComputedWidth()).toBe(100); + expect(root_child1.getComputedHeight()).toBe(25); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(89); + expect(root_child2.getComputedWidth()).toBe(100); + expect(root_child2.getComputedHeight()).toBe(24); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_inner_node_controversy_horizontal', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setHeight(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight(10); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setHeight(10); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setHeight(10); + 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(10); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(107); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(107); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(106); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(106); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(213); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(107); + expect(root_child2.getComputedHeight()).toBe(10); + + 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(10); + + expect(root_child0.getComputedLeft()).toBe(213); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(107); + expect(root_child0.getComputedHeight()).toBe(10); + + expect(root_child1.getComputedLeft()).toBe(107); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(106); + expect(root_child1.getComputedHeight()).toBe(10); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(106); + expect(root_child1_child0.getComputedHeight()).toBe(10); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(107); + expect(root_child2.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_inner_node_controversy_vertical', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setWidth(10); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setWidth(10); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setWidth(10); + root_child1.insertChild(root_child1_child0, 0); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + root_child2.setWidth(10); + 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(10); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(107); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(107); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(106); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(10); + expect(root_child1_child0.getComputedHeight()).toBe(106); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(107); + + 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(320); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10); + expect(root_child0.getComputedHeight()).toBe(107); + + expect(root_child1.getComputedLeft()).toBe(0); + expect(root_child1.getComputedTop()).toBe(107); + expect(root_child1.getComputedWidth()).toBe(10); + expect(root_child1.getComputedHeight()).toBe(106); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(10); + expect(root_child1_child0.getComputedHeight()).toBe(106); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(213); + expect(root_child2.getComputedWidth()).toBe(10); + expect(root_child2.getComputedHeight()).toBe(107); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('rounding_inner_node_controversy_combined', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setWidth(640); + root.setHeight(320); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexGrow(1); + root_child0.setHeight("100%"); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexGrow(1); + root_child1.setHeight("100%"); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setFlexGrow(1); + root_child1_child0.setWidth("100%"); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setFlexGrow(1); + root_child1_child1.setWidth("100%"); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child1_child0 = Yoga.Node.create(config); + root_child1_child1_child0.setFlexGrow(1); + root_child1_child1_child0.setWidth("100%"); + root_child1_child1.insertChild(root_child1_child1_child0, 0); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setFlexGrow(1); + root_child1_child2.setWidth("100%"); + root_child1.insertChild(root_child1_child2, 2); + + const root_child2 = Yoga.Node.create(config); + root_child2.setFlexGrow(1); + 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(640); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(213); + expect(root_child0.getComputedHeight()).toBe(320); + + expect(root_child1.getComputedLeft()).toBe(213); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(214); + expect(root_child1.getComputedHeight()).toBe(320); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(214); + expect(root_child1_child0.getComputedHeight()).toBe(107); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(107); + expect(root_child1_child1.getComputedWidth()).toBe(214); + expect(root_child1_child1.getComputedHeight()).toBe(106); + + expect(root_child1_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child1_child0.getComputedWidth()).toBe(214); + expect(root_child1_child1_child0.getComputedHeight()).toBe(106); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(213); + expect(root_child1_child2.getComputedWidth()).toBe(214); + expect(root_child1_child2.getComputedHeight()).toBe(107); + + expect(root_child2.getComputedLeft()).toBe(427); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(213); + expect(root_child2.getComputedHeight()).toBe(320); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(640); + expect(root.getComputedHeight()).toBe(320); + + expect(root_child0.getComputedLeft()).toBe(427); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(213); + expect(root_child0.getComputedHeight()).toBe(320); + + expect(root_child1.getComputedLeft()).toBe(213); + expect(root_child1.getComputedTop()).toBe(0); + expect(root_child1.getComputedWidth()).toBe(214); + expect(root_child1.getComputedHeight()).toBe(320); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(214); + expect(root_child1_child0.getComputedHeight()).toBe(107); + + expect(root_child1_child1.getComputedLeft()).toBe(0); + expect(root_child1_child1.getComputedTop()).toBe(107); + expect(root_child1_child1.getComputedWidth()).toBe(214); + expect(root_child1_child1.getComputedHeight()).toBe(106); + + expect(root_child1_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child1_child0.getComputedWidth()).toBe(214); + expect(root_child1_child1_child0.getComputedHeight()).toBe(106); + + expect(root_child1_child2.getComputedLeft()).toBe(0); + expect(root_child1_child2.getComputedTop()).toBe(213); + expect(root_child1_child2.getComputedWidth()).toBe(214); + expect(root_child1_child2.getComputedHeight()).toBe(107); + + expect(root_child2.getComputedLeft()).toBe(0); + expect(root_child2.getComputedTop()).toBe(0); + expect(root_child2.getComputedWidth()).toBe(213); + expect(root_child2.getComputedHeight()).toBe(320); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGSizeOverflowTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGSizeOverflowTest.test.ts new file mode 100644 index 0000000..325dd26 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGSizeOverflowTest.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<<d4b41aec2c4130f06b3ee9e76d70d944>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGSizeOverflowTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('nested_overflowing_child', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + 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(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(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(200); + + expect(root_child0_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('nested_overflowing_child_in_constraint_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + 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(100); + expect(root_child0.getComputedHeight()).toBe(100); + + 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(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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('parent_wrap_child_size_overflowing_parent', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(200); + 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(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(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(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/generated/YGStaticPositionTest.test.ts b/tests/taffyjs-yoga/yoga-official/tests/generated/YGStaticPositionTest.test.ts new file mode 100644 index 0000000..0c2bd37 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/generated/YGStaticPositionTest.test.ts @@ -0,0 +1,6338 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @generated SignedSource<<b9c3f55a558b356deeee072355ea1bbb>> + * generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html + */ + +import { instrinsicSizeMeasureFunc } from '../tools/utils.ts' +import Yoga from 'yoga-layout'; +import { + Align, + BoxSizing, + Direction, + Display, + Edge, + Errata, + ExperimentalFeature, + FlexDirection, + Gutter, + Justify, + MeasureMode, + Overflow, + PositionType, + Unit, + Wrap, +} from 'yoga-layout'; + +test('static_position_insets_have_no_effect_left_top', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Static); + root_child0.setPosition(Edge.Left, 50); + root_child0.setPosition(Edge.Top, 50); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_insets_have_no_effect_right_bottom', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Static); + root_child0.setPosition(Edge.Right, 50); + root_child0.setPosition(Edge.Bottom, 50); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_insets_relative_to_positioned_ancestor', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, 50); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse', () => { + 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.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, 50); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row_reverse', () => { + 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.setFlexDirection(FlexDirection.RowReverse); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, 50); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_insets_relative_to_positioned_ancestor_row', () => { + 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.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setPosition(Edge.Right, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_row', () => { + 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.setFlexDirection(FlexDirection.Row); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setPosition(Edge.Right, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse', () => { + 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.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setPosition(Edge.Right, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('column_reverse_static_position_absolute_child_insets_relative_to_positioned_ancestor_column_reverse', () => { + 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.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0.setPosition(Edge.Right, 50); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_insets_relative_to_positioned_ancestor_deep', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0_child0.setWidth(100); + root_child0_child0_child0.setHeight(100); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(100); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0_child0_child0.setMargin(Edge.Left, 100); + root_child0_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0_child0.setHeight(100); + root_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0, 0); + + const root_child0_child0_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0_child0_child0_child0.setPosition(Edge.Left, 50); + root_child0_child0_child0_child0_child0_child0.setPosition(Edge.Top, 50); + root_child0_child0_child0_child0_child0_child0.setWidth(50); + root_child0_child0_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0_child0_child0.insertChild(root_child0_child0_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(-350); + expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_width_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_width_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_width_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_height_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight("50%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_height_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight("50%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_height_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight("50%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_left_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_left_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPosition(Edge.Left, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_left_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPosition(Edge.Left, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_right_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Right, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_right_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPosition(Edge.Right, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_right_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPosition(Edge.Right, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_top_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Top, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_top_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPosition(Edge.Top, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_top_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPosition(Edge.Top, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_bottom_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_bottom_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPosition(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(-50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_bottom_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPosition(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_margin_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, "50%"); + root_child0_child0_child0.setMargin(Edge.Top, "50%"); + root_child0_child0_child0.setMargin(Edge.Right, "50%"); + root_child0_child0_child0.setMargin(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-50); + expect(root_child0_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_margin_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setMargin(Edge.Left, "50%"); + root_child0_child0_child0.setMargin(Edge.Top, "50%"); + root_child0_child0_child0.setMargin(Edge.Right, "50%"); + root_child0_child0_child0.setMargin(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_margin_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setMargin(Edge.Left, "50%"); + root_child0_child0_child0.setMargin(Edge.Top, "50%"); + root_child0_child0_child0.setMargin(Edge.Right, "50%"); + root_child0_child0_child0.setMargin(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(50); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_padding_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPadding(Edge.Left, "50%"); + root_child0_child0_child0.setPadding(Edge.Top, "50%"); + root_child0_child0_child0.setPadding(Edge.Right, "50%"); + root_child0_child0_child0.setPadding(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(200); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(200); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_padding_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPadding(Edge.Left, "50%"); + root_child0_child0_child0.setPadding(Edge.Top, "50%"); + root_child0_child0_child0.setPadding(Edge.Right, "50%"); + root_child0_child0_child0.setPadding(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_padding_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setPadding(Edge.Left, "50%"); + root_child0_child0_child0.setPadding(Edge.Top, "50%"); + root_child0_child0_child0.setPadding(Edge.Right, "50%"); + root_child0_child0_child0.setPadding(Edge.Bottom, "50%"); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_border_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_border_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_border_percentage', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setHeight(200); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setWidth(50); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(200); + expect(root_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_containing_block_padding_box', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_containing_block_padding_box', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_containing_block_padding_box', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Static); + root_child0_child0_child0.setWidth("50%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(50); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(50); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_containing_block_content_box', () => { + 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, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setWidth("50%"); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_relative_child_containing_block_content_box', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setWidth("50%"); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_child_containing_block_content_box', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPadding(Edge.Left, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth("50%"); + root_child0_child0.setHeight(50); + root_child0.insertChild(root_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_containing_block_padding_and_border', () => { + 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, 9); + root_child0.setPadding(Edge.Top, 8); + root_child0.setPadding(Edge.Right, 1); + root_child0.setPadding(Edge.Bottom, 4); + root_child0.setBorder(Edge.Left, 2); + root_child0.setBorder(Edge.Top, 5); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 4); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("61%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(11); + expect(root_child0_child0.getComputedTop()).toBe(13); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0_child0.getComputedHeight()).toBe(239); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(292); + expect(root_child0_child0.getComputedTop()).toBe(13); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-60); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(160); + expect(root_child0_child0_child0.getComputedHeight()).toBe(239); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, 2); + root_child0_child0_child0.setPosition(Edge.Right, 12); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + 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(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(1); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-2); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_no_position_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + 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(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-15); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_zero_for_inset_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, "0%"); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + 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(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-1); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-265); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_start_inset_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Start, 12); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + 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(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(11); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-2); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_end_inset_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root_child0.setWidth(500); + root_child0.setHeight(500); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0_child0.setWidth(200); + root_child0_child0.setHeight(200); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.End, 4); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("41%"); + root_child0_child0_child0.setHeight("63%"); + 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(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(270); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(513); + expect(root.getComputedHeight()).toBe(506); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(500); + expect(root_child0.getComputedHeight()).toBe(500); + + expect(root_child0_child0.getComputedLeft()).toBe(279); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0.getComputedHeight()).toBe(200); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-261); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(200); + expect(root_child0_child0_child0.getComputedHeight()).toBe(306); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_row_reverse_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setHeight("12%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-128); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(133); + expect(root_child0_child0_child0.getComputedHeight()).toBe(23); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(133); + expect(root_child0_child0_child0.getComputedHeight()).toBe(23); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_column_reverse_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(-82); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-15); + expect(root_child0_child0_child0.getComputedTop()).toBe(-82); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_justify_flex_start_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_justify_flex_start_position_set_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Right, 30); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(106); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(106); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_no_definite_size_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, "23%"); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(133); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(133); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_both_insets_set_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setPosition(Edge.Left, "23%"); + root_child0_child0_child0.setPosition(Edge.Right, 13); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(9); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(69); + expect(root.getComputedHeight()).toBe(79); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(56); + expect(root_child0.getComputedHeight()).toBe(73); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0.getComputedHeight()).toBe(22); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(-3); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(20); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_justify_center_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setJustifyContent(Justify.Center); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(85); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(85); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_justify_flex_end_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setJustifyContent(Justify.FlexEnd); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(140); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(140); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_align_flex_start_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignItems(Align.FlexStart); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_align_center_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignItems(Align.Center); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(65); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(39); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(75); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(75); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(65); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(39); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(75); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(75); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_align_flex_end_amalgamation', () => { + 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.setMargin(Edge.Left, 4); + root_child0.setMargin(Edge.Top, 5); + root_child0.setMargin(Edge.Right, 9); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 2); + root_child0.setPadding(Edge.Top, 9); + root_child0.setPadding(Edge.Right, 11); + root_child0.setPadding(Edge.Bottom, 13); + root_child0.setBorder(Edge.Left, 5); + root_child0.setBorder(Edge.Top, 6); + root_child0.setBorder(Edge.Right, 7); + root_child0.setBorder(Edge.Bottom, 8); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setAlignItems(Align.FlexEnd); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setMargin(Edge.Left, 8); + root_child0_child0.setMargin(Edge.Top, 6); + root_child0_child0.setMargin(Edge.Right, 3); + root_child0_child0.setMargin(Edge.Bottom, 9); + root_child0_child0.setPadding(Edge.Left, 1); + root_child0_child0.setPadding(Edge.Top, 7); + root_child0_child0.setPadding(Edge.Right, 9); + root_child0_child0.setPadding(Edge.Bottom, 4); + root_child0_child0.setBorder(Edge.Left, 8); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setBorder(Edge.Right, 2); + root_child0_child0.setBorder(Edge.Bottom, 1); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0.setWidth("21%"); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0_child0.setMargin(Edge.Left, 9); + root_child0_child0_child0_child0.setMargin(Edge.Top, 12); + root_child0_child0_child0_child0.setMargin(Edge.Right, 4); + root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child0_child0.setPadding(Edge.Left, 5); + root_child0_child0_child0_child0.setPadding(Edge.Top, 3); + root_child0_child0_child0_child0.setPadding(Edge.Right, 8); + root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child0_child0.setBorder(Edge.Left, 2); + root_child0_child0_child0_child0.setBorder(Edge.Top, 1); + root_child0_child0_child0_child0.setBorder(Edge.Right, 5); + root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child0_child0.setWidth(100); + root_child0_child0_child0_child0.setHeight(50); + root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0); + + const root_child0_child0_child1 = Yoga.Node.create(config); + root_child0_child0_child1.setMargin(Edge.Left, 9); + root_child0_child0_child1.setMargin(Edge.Top, 12); + root_child0_child0_child1.setMargin(Edge.Right, 4); + root_child0_child0_child1.setMargin(Edge.Bottom, 7); + root_child0_child0_child1.setPadding(Edge.Left, 5); + root_child0_child0_child1.setPadding(Edge.Top, 3); + root_child0_child0_child1.setPadding(Edge.Right, 8); + root_child0_child0_child1.setPadding(Edge.Bottom, 10); + root_child0_child0_child1.setBorder(Edge.Left, 2); + root_child0_child0_child1.setBorder(Edge.Top, 1); + root_child0_child0_child1.setBorder(Edge.Right, 5); + root_child0_child0_child1.setBorder(Edge.Bottom, 9); + root_child0_child0_child1.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child1, 1); + + const root_child0_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child0_child1_child0.setMargin(Edge.Left, 9); + root_child0_child0_child1_child0.setMargin(Edge.Top, 12); + root_child0_child0_child1_child0.setMargin(Edge.Right, 4); + root_child0_child0_child1_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child1_child0.setPadding(Edge.Left, 5); + root_child0_child0_child1_child0.setPadding(Edge.Top, 3); + root_child0_child0_child1_child0.setPadding(Edge.Right, 8); + root_child0_child0_child1_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child1_child0.setBorder(Edge.Left, 2); + root_child0_child0_child1_child0.setBorder(Edge.Top, 1); + root_child0_child0_child1_child0.setBorder(Edge.Right, 5); + root_child0_child0_child1_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child1_child0.setWidth(100); + root_child0_child0_child1_child0.setHeight(50); + root_child0_child0_child1.insertChild(root_child0_child0_child1_child0, 0); + + const root_child0_child0_child2 = Yoga.Node.create(config); + root_child0_child0_child2.setMargin(Edge.Left, 9); + root_child0_child0_child2.setMargin(Edge.Top, 12); + root_child0_child0_child2.setMargin(Edge.Right, 4); + root_child0_child0_child2.setMargin(Edge.Bottom, 7); + root_child0_child0_child2.setPadding(Edge.Left, 5); + root_child0_child0_child2.setPadding(Edge.Top, 3); + root_child0_child0_child2.setPadding(Edge.Right, 8); + root_child0_child0_child2.setPadding(Edge.Bottom, 10); + root_child0_child0_child2.setBorder(Edge.Left, 2); + root_child0_child0_child2.setBorder(Edge.Top, 1); + root_child0_child0_child2.setBorder(Edge.Right, 5); + root_child0_child0_child2.setBorder(Edge.Bottom, 9); + root_child0_child0_child2.setWidth("10%"); + root_child0_child0.insertChild(root_child0_child0_child2, 2); + + const root_child0_child0_child2_child0 = Yoga.Node.create(config); + root_child0_child0_child2_child0.setMargin(Edge.Left, 9); + root_child0_child0_child2_child0.setMargin(Edge.Top, 12); + root_child0_child0_child2_child0.setMargin(Edge.Right, 4); + root_child0_child0_child2_child0.setMargin(Edge.Bottom, 7); + root_child0_child0_child2_child0.setPadding(Edge.Left, 5); + root_child0_child0_child2_child0.setPadding(Edge.Top, 3); + root_child0_child0_child2_child0.setPadding(Edge.Right, 8); + root_child0_child0_child2_child0.setPadding(Edge.Bottom, 10); + root_child0_child0_child2_child0.setBorder(Edge.Left, 2); + root_child0_child0_child2_child0.setBorder(Edge.Top, 1); + root_child0_child0_child2_child0.setBorder(Edge.Right, 5); + root_child0_child0_child2_child0.setBorder(Edge.Bottom, 9); + root_child0_child0_child2_child0.setWidth(100); + root_child0_child0_child2_child0.setHeight(50); + root_child0_child0_child2.insertChild(root_child0_child0_child2_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(111); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(131); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(131); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(215); + expect(root.getComputedHeight()).toBe(301); + + expect(root_child0.getComputedLeft()).toBe(4); + expect(root_child0.getComputedTop()).toBe(5); + expect(root_child0.getComputedWidth()).toBe(202); + expect(root_child0.getComputedHeight()).toBe(295); + + expect(root_child0_child0.getComputedLeft()).toBe(15); + expect(root_child0_child0.getComputedTop()).toBe(21); + expect(root_child0_child0.getComputedWidth()).toBe(166); + expect(root_child0_child0.getComputedHeight()).toBe(244); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(18); + expect(root_child0_child0_child0.getComputedTop()).toBe(29); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-77); + expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child1.getComputedLeft()).toBe(18); + expect(root_child0_child0_child1.getComputedTop()).toBe(29); + expect(root_child0_child0_child1.getComputedWidth()).toBe(20); + expect(root_child0_child0_child1.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child1_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child1_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child1_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child0_child2.getComputedLeft()).toBe(18); + expect(root_child0_child0_child2.getComputedTop()).toBe(140); + expect(root_child0_child0_child2.getComputedWidth()).toBe(20); + expect(root_child0_child0_child2.getComputedHeight()).toBe(92); + + expect(root_child0_child0_child2_child0.getComputedLeft()).toBe(-97); + expect(root_child0_child0_child2_child0.getComputedTop()).toBe(16); + expect(root_child0_child0_child2_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0_child2_child0.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_static_root', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Static); + root.setPadding(Edge.Left, 6); + root.setPadding(Edge.Top, 1); + root.setPadding(Edge.Right, 11); + root.setPadding(Edge.Bottom, 4); + root.setWidth(100); + root.setHeight(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setPositionType(PositionType.Absolute); + root_child0.setMargin(Edge.Left, 12); + root_child0.setMargin(Edge.Top, 11); + root_child0.setMargin(Edge.Right, 15); + root_child0.setMargin(Edge.Bottom, 1); + root_child0.setPadding(Edge.Left, 3); + root_child0.setPadding(Edge.Top, 7); + root_child0.setPadding(Edge.Right, 5); + root_child0.setPadding(Edge.Bottom, 4); + root_child0.setBorder(Edge.Left, 4); + root_child0.setBorder(Edge.Top, 3); + root_child0.setBorder(Edge.Right, 2); + root_child0.setBorder(Edge.Bottom, 1); + root_child0.setWidth("50%"); + root_child0.setHeight("50%"); + root.insertChild(root_child0, 0); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(18); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(200); + + expect(root_child0.getComputedLeft()).toBe(24); + expect(root_child0.getComputedTop()).toBe(12); + expect(root_child0.getComputedWidth()).toBe(50); + expect(root_child0.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('static_position_absolute_child_multiple', () => { + 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, 100); + root_child0.setPadding(Edge.Top, 100); + root_child0.setPadding(Edge.Right, 100); + root_child0.setPadding(Edge.Bottom, 100); + root_child0.setWidth(400); + root_child0.setHeight(400); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Static); + root_child0_child0.setWidth(100); + root_child0_child0.setHeight(100); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child0_child0 = Yoga.Node.create(config); + root_child0_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0_child0.setWidth("10%"); + root_child0_child0_child0.setHeight(50); + root_child0_child0.insertChild(root_child0_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Static); + root_child0_child1.setWidth(100); + root_child0_child1.setHeight(100); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child1_child0 = Yoga.Node.create(config); + root_child0_child1_child0.setPositionType(PositionType.Absolute); + root_child0_child1_child0.setWidth("50%"); + root_child0_child1_child0.setHeight(50); + root_child0_child1.insertChild(root_child0_child1_child0, 0); + + const root_child0_child1_child1 = Yoga.Node.create(config); + root_child0_child1_child1.setPositionType(PositionType.Absolute); + root_child0_child1_child1.setWidth("50%"); + root_child0_child1_child1.setHeight(50); + root_child0_child1.insertChild(root_child0_child1_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Absolute); + root_child0_child2.setWidth(25); + root_child0_child2.setHeight(50); + 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(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(100); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(100); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(0); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(200); + expect(root_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1_child1.getComputedTop()).toBe(0); + expect(root_child0_child1_child1.getComputedWidth()).toBe(200); + expect(root_child0_child1_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(100); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(400); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(400); + expect(root_child0.getComputedHeight()).toBe(400); + + expect(root_child0_child0.getComputedLeft()).toBe(200); + expect(root_child0_child0.getComputedTop()).toBe(100); + expect(root_child0_child0.getComputedWidth()).toBe(100); + expect(root_child0_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0_child0.getComputedLeft()).toBe(60); + expect(root_child0_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0_child0.getComputedWidth()).toBe(40); + expect(root_child0_child0_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1.getComputedLeft()).toBe(200); + expect(root_child0_child1.getComputedTop()).toBe(200); + expect(root_child0_child1.getComputedWidth()).toBe(100); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child1_child0.getComputedLeft()).toBe(-100); + expect(root_child0_child1_child0.getComputedTop()).toBe(0); + expect(root_child0_child1_child0.getComputedWidth()).toBe(200); + expect(root_child0_child1_child0.getComputedHeight()).toBe(50); + + expect(root_child0_child1_child1.getComputedLeft()).toBe(-100); + expect(root_child0_child1_child1.getComputedTop()).toBe(0); + expect(root_child0_child1_child1.getComputedWidth()).toBe(200); + expect(root_child0_child1_child1.getComputedHeight()).toBe(50); + + expect(root_child0_child2.getComputedLeft()).toBe(275); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(25); + expect(root_child0_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/taffyjs-yoga/yoga-official/tests/tools/MeasureCounter.ts b/tests/taffyjs-yoga/yoga-official/tests/tools/MeasureCounter.ts new file mode 100644 index 0000000..d7af473 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/tools/MeasureCounter.ts @@ -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. + * + * @format + */ + +import type {MeasureFunction} from 'yoga-layout'; +import Yoga from 'yoga-layout'; + +export type MeasureCounter = { + inc: MeasureFunction; + get: () => number; +}; + +export function getMeasureCounter( + cb?: MeasureFunction | null, + staticWidth = 0, + staticHeight = 0, +): MeasureCounter { + let counter = 0; + + return { + inc: function (width, widthMode, height, heightMode) { + counter += 1; + + return cb + ? cb(width, widthMode, height, heightMode) + : {width: staticWidth, height: staticHeight}; + }, + + get: function () { + return counter; + }, + }; +} + +export function getMeasureCounterMax(): MeasureCounter { + return getMeasureCounter((width, widthMode, height, heightMode) => { + const measuredWidth = + widthMode === Yoga.MEASURE_MODE_UNDEFINED ? 10 : width; + const measuredHeight = + heightMode === Yoga.MEASURE_MODE_UNDEFINED ? 10 : height; + + return {width: measuredWidth, height: measuredHeight}; + }); +} + +export function getMeasureCounterMin(): MeasureCounter { + return getMeasureCounter((width, widthMode, height, heightMode) => { + const measuredWidth = + widthMode === Yoga.MEASURE_MODE_UNDEFINED || + (widthMode == Yoga.MEASURE_MODE_AT_MOST && width > 10) + ? 10 + : width; + const measuredHeight = + heightMode === Yoga.MEASURE_MODE_UNDEFINED || + (heightMode == Yoga.MEASURE_MODE_AT_MOST && height > 10) + ? 10 + : height; + + return {width: measuredWidth, height: measuredHeight}; + }); +} diff --git a/tests/taffyjs-yoga/yoga-official/tests/tools/utils.ts b/tests/taffyjs-yoga/yoga-official/tests/tools/utils.ts new file mode 100644 index 0000000..f555429 --- /dev/null +++ b/tests/taffyjs-yoga/yoga-official/tests/tools/utils.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. + */ + +import {MeasureMode} from 'yoga-layout'; + +export function instrinsicSizeMeasureFunc( + this: string, + width: number, + widthMode: MeasureMode, + height: number, + heightMode: MeasureMode, +): {width: number; height: number} { + const textLength = this.length; + const words = this.split(' '); + const widthPerChar = 10; + const heightPerChar = 10; + + let measuredWidth: number; + let measuredHeight: number; + + switch (widthMode) { + case MeasureMode.Exactly: + measuredWidth = width; + break; + case MeasureMode.AtMost: + measuredWidth = Math.min(width, textLength * widthPerChar); + break; + default: + measuredWidth = textLength * widthPerChar; + } + + switch (heightMode) { + case MeasureMode.Exactly: + measuredHeight = height; + break; + case MeasureMode.AtMost: + measuredHeight = Math.min(height, calculateHeight()); + break; + default: + measuredHeight = calculateHeight(); + } + + function longestWordWidth() { + return Math.max(...words.map(word => word.length)) * widthPerChar; + } + + function calculateHeight() { + if (textLength * widthPerChar <= measuredWidth) { + return heightPerChar; + } + + const maxLineWidth = Math.max(longestWordWidth(), measuredWidth); + + //if fixed width < width of widest word, take width of widest word + + let lines = 1; + let currentLineLength = 0; + for (const word of words) { + const wordWidth = word.length * widthPerChar; + if (wordWidth > maxLineWidth) { + if (currentLineLength > 0) { + lines++; + } + lines++; + currentLineLength = 0; + } else if (currentLineLength + wordWidth <= maxLineWidth) { + currentLineLength += widthPerChar + wordWidth; + } else { + lines++; + currentLineLength = widthPerChar + wordWidth; + } + } + return (currentLineLength === 0 ? lines - 1 : lines) * heightPerChar; + } + + return {width: measuredWidth, height: measuredHeight}; +} diff --git a/vite.config.ts b/vite.config.ts index bfbfc7f..da21385 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -83,6 +83,7 @@ export default defineConfig({ "packages/.taffyjs-*.napi-stage-*", "packages/**/.napi-rs-filesystem-transaction*", "tests/taffyjs-wasm/browser/dist", + "tests/taffyjs-yoga/yoga-official/tests", "packages/taffyjs-yoga/dist", "packages/taffyjs-yoga-wasm/dist", "benchmarks/results/published.json", @@ -104,6 +105,7 @@ export default defineConfig({ "packages/.taffyjs-*.napi-stage-*", "packages/**/.napi-rs-filesystem-transaction*", "tests/taffyjs-wasm/browser/dist", + "tests/taffyjs-yoga/yoga-official/tests", "tests/taffyjs-yoga/types/public-api.test-d.ts", "packages/taffyjs-yoga/dist", "packages/taffyjs-yoga-wasm/dist", From efb36cd0c7ff3bb8eaee9cbc98f7a05b598bc9b3 Mon Sep 17 00:00:00 2001 From: Yunfei He <i.heyunfei@gmail.com> Date: Sun, 16 Aug 2026 23:27:41 +0800 Subject: [PATCH 2/2] Harden official Yoga compatibility tests --- .agents/docs/taffyjs-yoga-reference.md | 3 +- packages/taffyjs-yoga/COMPATIBILITY.md | 1 + tests/taffyjs-yoga-wasm/vite.config.ts | 55 ++++++++++------ tests/taffyjs-yoga/differences.test.mts | 66 +++++++++++++++++++ tests/taffyjs-yoga/vite.config.ts | 53 ++++++++++----- tests/taffyjs-yoga/yoga-official.test.mts | 36 +++++----- .../yoga-official/expected-failures.ts | 6 +- 7 files changed, 161 insertions(+), 59 deletions(-) diff --git a/.agents/docs/taffyjs-yoga-reference.md b/.agents/docs/taffyjs-yoga-reference.md index d2cc456..ae60615 100644 --- a/.agents/docs/taffyjs-yoga-reference.md +++ b/.agents/docs/taffyjs-yoga-reference.md @@ -219,7 +219,7 @@ This matrix answers whether the public capability has a credible implementation No first-release feasibility blocker remains in the inventoried Yoga 3.2.1 surface. The grouped result is: - Package entries, factories, ordinary Config state, tree ownership and mutation, declaration getters and setters, calculation on any live Node, logical dirty and new-layout flags, ordinary measure callbacks, Yoga-shaped computed output, and per-Node point-grid rounding are Compatible through bounded JavaScript or TypeScript mapping. -- Yoga cache artifacts, MeasureMode-sensitive measurement results, aspect-ratio layout, min/max combined with flex growth or shrinkage, shrink factors totaling below one, percentage main-axis gaps in auto-sized containers, main-axis auto margins combined with justification offsets, and the documented reversed-axis, overflowing, or zero-size distribution cases are Different. The same API remains callable and returns Taffy's stable geometry under the documented trigger. +- Yoga cache artifacts, MeasureMode-sensitive measurement results, aspect-ratio layout, min/max combined with flex growth or shrinkage, shrink factors totaling below one, percentage main-axis gaps in auto-sized containers, main-axis auto margins combined with justification offsets, oversized cross-axis auto margins, and the documented reversed-axis, overflowing, or zero-size distribution cases are Different. The same API remains callable and returns Taffy's stable geometry under the documented trigger. - Display.Contents, PositionType.Static, non-None Errata values, reference-baseline selection, property-invalid Align values, positive or negative infinite calculation owner dimensions, and undeclared broken setter coercions are Unsupported. Omit a wholly unsupported member where practical and always reject it at runtime. ### Package entries, factories, and public value shapes @@ -356,6 +356,7 @@ Compatible numeric comparisons allow an absolute error below `0.0001` for finite | Oversized single line on a reversed main axis with distribution-style justifyContent | Different | When a RowReverse or ColumnReverse no-wrap line overflows and justifyContent is SpaceBetween, SpaceAround, or SpaceEvenly, Yoga and Taffy choose different negative-free-space fallback placement. In a 240-point RowReverse line with 140, 130, and 120-point children, Yoga left positions are 100, -30, and -150 while Taffy reports 250, 120, and 0. This affects sibling distribution and is not an output-only correction. | | Zero-cross-size wrapped line under Stretch item alignment | Different | A wrapped line whose items all resolve to zero cross size stays on Yoga's cross-start or cross-end edge, while Taffy distributes the zero-size line under FlexEnd, Center, SpaceAround, or SpaceEvenly alignContent. For a 180-point cross axis, ordinary Wrap plus Center places Yoga at 0 and Taffy at 90; WrapReverse plus Center places Yoga at 180 and Taffy at 90. Reconstructing this degenerate line placement would duplicate Flex logic. | | Main-axis auto margins on a reversed axis or combined with a nonzero justifyContent offset | Different | Yoga lets positive-free-space main-axis auto margins consume the remaining space and can suppress justifyContent, while Taffy can distribute the margin and retain an additional offset. In a width-240 RowReverse, a width-60 child with margin-left auto has left 180 in Yoga and 360 in Taffy even under FlexStart. In a 240x180 Column with justifyContent Center, Yoga child tops are 65 and 160 while Taffy reports 130 and 225. Correcting either sibling distribution would duplicate Flex logic, so Taffy's geometry is retained and computed auto margins remain masked to zero. | +| Oversized child with one or both cross-axis margins set to auto | Different | In a 52x52 default Column with justifyContent Center, a 72x72 child with auto left and right margins has left 0 in Yoga LTR and -20 in Yoga RTL, while Taffy centers it at -10 in both directions; the top remains -10. The one-auto and mixed fixed/auto variants follow the same overflow-alignment split. Correcting them would reproduce cross-axis Flex alignment after negative free-space resolution, so Taffy's stable geometry is retained. | | Relative insets, including reversed axes | Compatible | Relative positioning does not participate in normal-flow sizing. When Taffy and Yoga apply opposite signs on a reversed axis, the projection can remove Taffy's declaration-derived offset and apply Yoga's declaration-derived offset to the Node's projected position and descendant absolute accumulation without redistributing siblings or calculating Flex geometry. A combination that also triggers the main-axis auto-margin difference remains covered by the Different row above. | ### Yoga-shaped output projection diff --git a/packages/taffyjs-yoga/COMPATIBILITY.md b/packages/taffyjs-yoga/COMPATIBILITY.md index 535d249..81f9805 100644 --- a/packages/taffyjs-yoga/COMPATIBILITY.md +++ b/packages/taffyjs-yoga/COMPATIBILITY.md @@ -91,6 +91,7 @@ These rows are deliberate, version-specific differences with regression fixtures | An oversized no-wrap reversed main axis with `SpaceBetween`, `SpaceAround`, or `SpaceEvenly` | Keeps Taffy's negative-free-space fallback. Widths 140, 130, and 120 in a width-240 `RowReverse` with `SpaceBetween` have left positions 250, 120, and 0. | The same left positions are 100, -30, and -150. | | A wrapped line whose stretched items resolve to zero cross size under distribution-style `alignContent` | Keeps Taffy's line distribution. Two 60-point, flex-basis-zero children in a 100-by-180 Row with `alignContent: Center` both have top 90 for Wrap and WrapReverse. | Both children have top 0 for Wrap and 180 for WrapReverse. | | Main-axis auto margins on a reversed axis or combined with a nonzero `justifyContent` offset | Keeps Taffy's distribution and masks computed auto margins to zero. A width-60 child with `margin-left: auto` in a width-240 `RowReverse` has left 360; the Center fixture has child tops 130 and 225. | Yoga places the reversed child at left 180; auto margins suppress the Center offset and produce tops 65 and 160. | +| An oversized child with one or both cross-axis margins set to auto | Keeps Taffy's overflow alignment. For both-auto, left-auto, left-10/right-auto, and left-auto/right-10 fixtures, left is respectively -10, -20, 10, and -30 in both LTR and RTL. Their top is -10. | The same left positions are respectively 0/-20, 0/-20, 10/-20, and 0/-30 in LTR/RTL. Their top remains -10. | | Measure callback count, order, and exact mode trace | Maps every Taffy request independently. A constant 30-by-10 callback for a child in a 100-by-40 Row runs four times in the pinned fixture and still produces the same 30-by-40 layout. | Runs once with width `AtMost(100)` and height `Exactly(40)` in the same fixture. | | A Measure callback whose result changes with `MeasureMode` | Keeps Taffy's multi-stage result. In the pinned 100-by-40 Row, a callback returning width 80 for `Undefined` and 20 for `AtMost` produces width 80. | Calls the callback with `AtMost(100)` and produces width 20. | | Replace or remove a Measure callback on an otherwise clean Node | Privately invalidates Taffy's measurement cache. Replacing a cached width-10 callback with width 20 produces 20 on the next calculation; removing it then produces zero. | Leaves the Node publicly clean and reuses the cached width 10 after both operations. | diff --git a/tests/taffyjs-yoga-wasm/vite.config.ts b/tests/taffyjs-yoga-wasm/vite.config.ts index 7ed6089..35dd5f8 100644 --- a/tests/taffyjs-yoga-wasm/vite.config.ts +++ b/tests/taffyjs-yoga-wasm/vite.config.ts @@ -14,26 +14,43 @@ const yogaWasmLoadEntry = resolve( ); export default defineConfig({ - resolve: { - alias: [ - { find: /^yoga-layout$/, replacement: yogaWasmEntry }, - { find: /^yoga-layout\/load$/, replacement: yogaWasmLoadEntry }, - { find: /^@taffyjs\/node$/, replacement: wasmEntry }, - ], - }, test: { - globals: true, - include: [ - "../taffyjs-yoga/*.test.mts", - "../taffyjs-yoga/yoga-official/tests/*.test.ts", - "../taffyjs-yoga/yoga-official/tests/generated/*.test.ts", + projects: [ + { + resolve: { + alias: [ + { find: /^yoga-layout$/, replacement: yogaWasmEntry }, + { find: /^yoga-layout\/load$/, replacement: yogaWasmLoadEntry }, + { find: /^@taffyjs\/node$/, replacement: wasmEntry }, + ], + }, + test: { + name: "maintained", + include: ["../taffyjs-yoga/*.test.mts"], + retry: 0, + sequence: { concurrent: true }, + env: { + TAFFYJS_TEST_ENTRY: pathToFileURL(wasmEntry).href, + TAFFYJS_YOGA_TEST_ENTRY: pathToFileURL(yogaWasmEntry).href, + }, + }, + }, + { + resolve: { + alias: [{ find: /^yoga-layout$/, replacement: yogaWasmEntry }], + }, + test: { + name: "official", + globals: true, + include: [ + "../taffyjs-yoga/yoga-official/tests/*.test.ts", + "../taffyjs-yoga/yoga-official/tests/generated/*.test.ts", + ], + retry: 0, + sequence: { concurrent: true }, + setupFiles: [resolve(import.meta.dirname, "../taffyjs-yoga/yoga-official/setup.ts")], + }, + }, ], - retry: 0, - sequence: { concurrent: true }, - setupFiles: [resolve(import.meta.dirname, "../taffyjs-yoga/yoga-official/setup.ts")], - env: { - TAFFYJS_TEST_ENTRY: pathToFileURL(wasmEntry).href, - TAFFYJS_YOGA_TEST_ENTRY: pathToFileURL(yogaWasmEntry).href, - }, }, }); diff --git a/tests/taffyjs-yoga/differences.test.mts b/tests/taffyjs-yoga/differences.test.mts index 535d634..ecc30fa 100644 --- a/tests/taffyjs-yoga/differences.test.mts +++ b/tests/taffyjs-yoga/differences.test.mts @@ -694,6 +694,72 @@ test("Different: main-axis auto margins retain Taffy's justify offset", () => { } }); +for (const fixture of [ + { name: "both auto", left: "auto", right: "auto", taffyLeft: -10, yogaLeft: [0, -20] }, + { name: "left auto", left: "auto", right: undefined, taffyLeft: -20, yogaLeft: [0, -20] }, + { name: "left 10, right auto", left: 10, right: "auto", taffyLeft: 10, yogaLeft: [10, -20] }, + { name: "left auto, right 10", left: "auto", right: 10, taffyLeft: -30, yogaLeft: [0, -30] }, +] as const) { + test(`Different: oversized cross-axis auto margins keep Taffy's alignment (${fixture.name})`, () => { + const config = Yoga.Config.create(); + const oracleConfig = OracleYoga.Config.create(); + config.setPointScaleFactor(0); + oracleConfig.setPointScaleFactor(0); + const root = Yoga.Node.createWithConfig(config); + const child = Yoga.Node.createWithConfig(config); + const oracleRoot = OracleYoga.Node.createWithConfig(oracleConfig); + const oracleChild = OracleYoga.Node.createWithConfig(oracleConfig); + try { + root.setWidth(52); + root.setHeight(52); + root.setJustifyContent(Justify.Center); + child.setWidth(72); + child.setHeight(72); + oracleRoot.setWidth(52); + oracleRoot.setHeight(52); + oracleRoot.setJustifyContent(OracleJustify.Center); + oracleChild.setWidth(72); + oracleChild.setHeight(72); + + for (const [value, edge, oracleEdge] of [ + [fixture.left, Edge.Left, OracleEdge.Left], + [fixture.right, Edge.Right, OracleEdge.Right], + ] as const) { + if (value === "auto") { + child.setMarginAuto(edge); + oracleChild.setMarginAuto(oracleEdge); + } else if (value !== undefined) { + child.setMargin(edge, value); + oracleChild.setMargin(oracleEdge, value); + } + } + + root.insertChild(child, 0); + oracleRoot.insertChild(oracleChild, 0); + for (const [index, direction, oracleDirection] of [ + [0, Direction.LTR, OracleDirection.LTR], + [1, Direction.RTL, OracleDirection.RTL], + ] as const) { + root.calculateLayout(undefined, undefined, direction); + oracleRoot.calculateLayout(undefined, undefined, oracleDirection); + assert.deepEqual( + [child.getComputedLeft(), child.getComputedTop()], + [fixture.taffyLeft, -10], + ); + assert.deepEqual( + [oracleChild.getComputedLeft(), oracleChild.getComputedTop()], + [fixture.yogaLeft[index], -10], + ); + } + } finally { + root.freeRecursive(); + oracleRoot.freeRecursive(); + config.free(); + oracleConfig.free(); + } + }); +} + test("Different: reversed-axis auto margins keep Taffy's distribution", () => { const config = Yoga.Config.create(); const oracleConfig = OracleYoga.Config.create(); diff --git a/tests/taffyjs-yoga/vite.config.ts b/tests/taffyjs-yoga/vite.config.ts index 4ce94fe..8fb646b 100644 --- a/tests/taffyjs-yoga/vite.config.ts +++ b/tests/taffyjs-yoga/vite.config.ts @@ -14,27 +14,46 @@ export default defineConfig({ typeCheck: true, }, }, - resolve: { - alias: [ + test: { + projects: [ { - find: /^yoga-layout$/, - replacement: yogaEntry, + resolve: { + alias: [ + { + find: /^yoga-layout$/, + replacement: yogaEntry, + }, + { + find: /^yoga-layout\/load$/, + replacement: yogaLoadEntry, + }, + ], + }, + test: { + name: "maintained", + include: ["*.test.mts"], + retry: 0, + sequence: { concurrent: true }, + }, }, { - find: /^yoga-layout\/load$/, - replacement: yogaLoadEntry, + resolve: { + alias: [ + { + find: /^yoga-layout$/, + replacement: yogaEntry, + }, + ], + }, + test: { + name: "official", + globals: true, + include: ["yoga-official/tests/*.test.ts", "yoga-official/tests/generated/*.test.ts"], + retry: 0, + sequence: { concurrent: true }, + setupFiles: [resolve(import.meta.dirname, "yoga-official/setup.ts")], + }, }, ], }, - test: { - globals: true, - include: [ - "*.test.mts", - "yoga-official/tests/*.test.ts", - "yoga-official/tests/generated/*.test.ts", - ], - retry: 0, - sequence: { concurrent: true }, - setupFiles: [resolve(import.meta.dirname, "yoga-official/setup.ts")], - }, }); diff --git a/tests/taffyjs-yoga/yoga-official.test.mts b/tests/taffyjs-yoga/yoga-official.test.mts index 255a338..db3c53f 100644 --- a/tests/taffyjs-yoga/yoga-official.test.mts +++ b/tests/taffyjs-yoga/yoga-official.test.mts @@ -3,10 +3,7 @@ import { readFile, readdir } from "node:fs/promises"; import { test } from "vite-plus/test"; -import { - expectedFailureByTitle, - expectedFailureGroups, -} from "./yoga-official/expected-failures.ts"; +import { expectedFailureByTitle } from "./yoga-official/expected-failures.ts"; const officialTestRoot = new URL("./yoga-official/tests/", import.meta.url); @@ -21,7 +18,7 @@ test("official Yoga snapshot and expected failures stay aligned", async () => { ), ) ).flat(); - const titleCounts = new Map<string, number>(); + const registrations = new Map<string, { active: number; skipped: number }>(); let caseCount = 0; let skippedCount = 0; const testPattern = /^test(?<skipped>\.skip)?\('(?<title>[^']+)'/gmu; @@ -32,29 +29,26 @@ test("official Yoga snapshot and expected failures stay aligned", async () => { const title = match.groups?.title; assert.ok(title, `missing test title in ${file.pathname}`); caseCount += 1; - if (match.groups?.skipped !== undefined) skippedCount += 1; - titleCounts.set(title, (titleCounts.get(title) ?? 0) + 1); + const registration = registrations.get(title) ?? { active: 0, skipped: 0 }; + if (match.groups?.skipped === undefined) { + registration.active += 1; + } else { + registration.skipped += 1; + skippedCount += 1; + } + registrations.set(title, registration); } } assert.equal(files.length, 35); assert.equal(caseCount, 570); assert.equal(skippedCount, 17); - assert.equal(expectedFailureByTitle.size, 85); - assert.equal( - expectedFailureGroups - .filter((group) => group.classification === "unsupported") - .flatMap((group) => group.titles).length, - 77, - ); - assert.equal( - expectedFailureGroups - .filter((group) => group.classification === "different") - .flatMap((group) => group.titles).length, - 8, - ); for (const title of expectedFailureByTitle.keys()) { - assert.equal(titleCounts.get(title), 1, `expected one official test named ${title}`); + assert.deepEqual( + registrations.get(title), + { active: 1, skipped: 0 }, + `expected exactly one active and no skipped official test named ${title}`, + ); } }); diff --git a/tests/taffyjs-yoga/yoga-official/expected-failures.ts b/tests/taffyjs-yoga/yoga-official/expected-failures.ts index 0d592a5..cbcd6b3 100644 --- a/tests/taffyjs-yoga/yoga-official/expected-failures.ts +++ b/tests/taffyjs-yoga/yoga-official/expected-failures.ts @@ -115,8 +115,12 @@ export const expectedFailureGroups = [ { classification: "different", capability: "main-axis auto-margin distribution", + titles: ["margin_auto_bottom_and_top_justify_center"], + }, + { + classification: "different", + capability: "oversized cross-axis auto-margin alignment", titles: [ - "margin_auto_bottom_and_top_justify_center", "margin_auto_left_right_child_bigger_than_parent", "margin_auto_left_child_bigger_than_parent", "margin_fix_left_auto_right_child_bigger_than_parent",