@xincli/opentui-core 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/README.md +63 -0
  2. package/dev/keypress-debug-renderer.ts +148 -0
  3. package/dev/keypress-debug.ts +43 -0
  4. package/dev/print-env-vars.ts +32 -0
  5. package/dev/test-tmux-graphics-334.sh +68 -0
  6. package/dev/test-tmux-theme-queries.sh +151 -0
  7. package/dev/thai-debug-test.ts +68 -0
  8. package/dev/theme-mode.ts +290 -0
  9. package/docs/development.md +144 -0
  10. package/package.json +102 -0
  11. package/prebuilt/aarch64-android/libopentui.so +0 -0
  12. package/scripts/build-android.ts +226 -0
  13. package/scripts/build-native-termux.sh +525 -0
  14. package/scripts/build.ts +530 -0
  15. package/scripts/dist-test.ts +312 -0
  16. package/scripts/package-prebuilt.ts +110 -0
  17. package/scripts/publish.ts +60 -0
  18. package/scripts/test-node-hook.mjs +16 -0
  19. package/scripts/test-node.ts +241 -0
  20. package/scripts/vendor-deps.sh +73 -0
  21. package/src/NativeSpanFeed.ts +375 -0
  22. package/src/Renderable.ts +1878 -0
  23. package/src/__snapshots__/buffer.test.ts.snap +28 -0
  24. package/src/animation/Timeline.test.ts +2709 -0
  25. package/src/animation/Timeline.ts +598 -0
  26. package/src/ansi.ts +22 -0
  27. package/src/audio.ts +479 -0
  28. package/src/benchmark/attenuation-benchmark.ts +81 -0
  29. package/src/benchmark/audio-playback-benchmark.ts +344 -0
  30. package/src/benchmark/box-draw-benchmark.ts +1042 -0
  31. package/src/benchmark/colormatrix-benchmark.ts +123 -0
  32. package/src/benchmark/gain-benchmark.ts +80 -0
  33. package/src/benchmark/latest-all-bench-run.json +707 -0
  34. package/src/benchmark/latest-async-bench-run.json +336 -0
  35. package/src/benchmark/latest-default-bench-run.json +657 -0
  36. package/src/benchmark/latest-large-bench-run.json +707 -0
  37. package/src/benchmark/latest-quick-bench-run.json +207 -0
  38. package/src/benchmark/layout-benchmark.ts +2547 -0
  39. package/src/benchmark/markdown-benchmark.ts +1796 -0
  40. package/src/benchmark/native-span-feed-async-benchmark.ts +355 -0
  41. package/src/benchmark/native-span-feed-benchmark.md +56 -0
  42. package/src/benchmark/native-span-feed-benchmark.ts +596 -0
  43. package/src/benchmark/native-span-feed-compare.ts +280 -0
  44. package/src/benchmark/render-traversal-benchmark.ts +928 -0
  45. package/src/benchmark/text-buffer-render-benchmark.ts +874 -0
  46. package/src/benchmark/text-table-benchmark.ts +948 -0
  47. package/src/buffer.test.ts +292 -0
  48. package/src/buffer.ts +564 -0
  49. package/src/console.test.ts +629 -0
  50. package/src/console.ts +1253 -0
  51. package/src/edit-buffer.test.ts +1852 -0
  52. package/src/edit-buffer.ts +417 -0
  53. package/src/editor-view.test.ts +1056 -0
  54. package/src/editor-view.ts +290 -0
  55. package/src/index.ts +25 -0
  56. package/src/lib/KeyHandler.integration.test.ts +292 -0
  57. package/src/lib/KeyHandler.stopPropagation.test.ts +289 -0
  58. package/src/lib/KeyHandler.test.ts +662 -0
  59. package/src/lib/KeyHandler.ts +222 -0
  60. package/src/lib/RGBA.test.ts +60 -0
  61. package/src/lib/RGBA.ts +343 -0
  62. package/src/lib/ascii.font.ts +330 -0
  63. package/src/lib/border.test.ts +83 -0
  64. package/src/lib/border.ts +170 -0
  65. package/src/lib/bunfs.test.ts +27 -0
  66. package/src/lib/bunfs.ts +18 -0
  67. package/src/lib/clipboard.test.ts +63 -0
  68. package/src/lib/clipboard.ts +41 -0
  69. package/src/lib/clock.ts +35 -0
  70. package/src/lib/data-paths.test.ts +133 -0
  71. package/src/lib/data-paths.ts +109 -0
  72. package/src/lib/debounce.ts +106 -0
  73. package/src/lib/detect-links.test.ts +98 -0
  74. package/src/lib/detect-links.ts +56 -0
  75. package/src/lib/env.test.ts +228 -0
  76. package/src/lib/env.ts +209 -0
  77. package/src/lib/extmarks-history.ts +51 -0
  78. package/src/lib/extmarks-multiwidth.test.ts +324 -0
  79. package/src/lib/extmarks.test.ts +3547 -0
  80. package/src/lib/extmarks.ts +861 -0
  81. package/src/lib/fonts/block.json +405 -0
  82. package/src/lib/fonts/grid.json +265 -0
  83. package/src/lib/fonts/huge.json +741 -0
  84. package/src/lib/fonts/pallet.json +314 -0
  85. package/src/lib/fonts/shade.json +591 -0
  86. package/src/lib/fonts/slick.json +321 -0
  87. package/src/lib/fonts/tiny.json +69 -0
  88. package/src/lib/hast-styled-text.ts +59 -0
  89. package/src/lib/index.ts +22 -0
  90. package/src/lib/keybinding.internal.test.ts +342 -0
  91. package/src/lib/keybinding.internal.ts +182 -0
  92. package/src/lib/objects-in-viewport.test.ts +789 -0
  93. package/src/lib/objects-in-viewport.ts +153 -0
  94. package/src/lib/output.capture.ts +58 -0
  95. package/src/lib/parse.keypress-kitty.protocol.test.ts +347 -0
  96. package/src/lib/parse.keypress-kitty.test.ts +712 -0
  97. package/src/lib/parse.keypress-kitty.ts +470 -0
  98. package/src/lib/parse.keypress.test.ts +2020 -0
  99. package/src/lib/parse.keypress.ts +480 -0
  100. package/src/lib/parse.mouse.test.ts +552 -0
  101. package/src/lib/parse.mouse.ts +232 -0
  102. package/src/lib/paste.ts +18 -0
  103. package/src/lib/queue.ts +65 -0
  104. package/src/lib/render-geometry.ts +36 -0
  105. package/src/lib/renderable.validations.test.ts +87 -0
  106. package/src/lib/renderable.validations.ts +83 -0
  107. package/src/lib/scroll-acceleration.ts +98 -0
  108. package/src/lib/selection.ts +261 -0
  109. package/src/lib/singleton.ts +34 -0
  110. package/src/lib/stdin-parser.test.ts +2439 -0
  111. package/src/lib/stdin-parser.ts +2007 -0
  112. package/src/lib/styled-text.ts +178 -0
  113. package/src/lib/terminal-capability-detection.test.ts +226 -0
  114. package/src/lib/terminal-capability-detection.ts +98 -0
  115. package/src/lib/terminal-palette.test.ts +954 -0
  116. package/src/lib/terminal-palette.ts +441 -0
  117. package/src/lib/tree-sitter/assets/README.md +119 -0
  118. package/src/lib/tree-sitter/assets/javascript/highlights.scm +205 -0
  119. package/src/lib/tree-sitter/assets/javascript/tree-sitter-javascript.wasm +0 -0
  120. package/src/lib/tree-sitter/assets/markdown/highlights.scm +150 -0
  121. package/src/lib/tree-sitter/assets/markdown/injections.scm +27 -0
  122. package/src/lib/tree-sitter/assets/markdown/tree-sitter-markdown.wasm +0 -0
  123. package/src/lib/tree-sitter/assets/markdown_inline/highlights.scm +115 -0
  124. package/src/lib/tree-sitter/assets/markdown_inline/tree-sitter-markdown_inline.wasm +0 -0
  125. package/src/lib/tree-sitter/assets/typescript/highlights.scm +604 -0
  126. package/src/lib/tree-sitter/assets/typescript/tree-sitter-typescript.wasm +0 -0
  127. package/src/lib/tree-sitter/assets/update.ts +360 -0
  128. package/src/lib/tree-sitter/assets/zig/highlights.scm +284 -0
  129. package/src/lib/tree-sitter/assets/zig/tree-sitter-zig.wasm +0 -0
  130. package/src/lib/tree-sitter/assets.d.ts +9 -0
  131. package/src/lib/tree-sitter/cache.test.ts +291 -0
  132. package/src/lib/tree-sitter/client.test.ts +1434 -0
  133. package/src/lib/tree-sitter/client.ts +847 -0
  134. package/src/lib/tree-sitter/default-parsers.ts +133 -0
  135. package/src/lib/tree-sitter/download-utils.ts +148 -0
  136. package/src/lib/tree-sitter/index.ts +75 -0
  137. package/src/lib/tree-sitter/parser.worker.ts +1098 -0
  138. package/src/lib/tree-sitter/parsers-config.ts +81 -0
  139. package/src/lib/tree-sitter/resolve-ft.test.ts +55 -0
  140. package/src/lib/tree-sitter/resolve-ft.ts +189 -0
  141. package/src/lib/tree-sitter/types.ts +132 -0
  142. package/src/lib/tree-sitter/update-assets.ts +10 -0
  143. package/src/lib/tree-sitter-styled-text.test.ts +1253 -0
  144. package/src/lib/tree-sitter-styled-text.ts +314 -0
  145. package/src/lib/validate-dir-name.ts +55 -0
  146. package/src/lib/yoga.options.test.ts +628 -0
  147. package/src/lib/yoga.options.ts +346 -0
  148. package/src/native-event-worker-repro.test.ts +48 -0
  149. package/src/native-event-worker-repro.worker.ts +9 -0
  150. package/src/native-handle.test.ts +221 -0
  151. package/src/platform/ffi.test.ts +516 -0
  152. package/src/platform/ffi.ts +653 -0
  153. package/src/platform/runtime.test.ts +52 -0
  154. package/src/platform/runtime.ts +121 -0
  155. package/src/platform/test.ts +45 -0
  156. package/src/platform/worker-handler-cleanup.fixture.ts +12 -0
  157. package/src/platform/worker-onmessage-startup.fixture.ts +10 -0
  158. package/src/platform/worker-startup.fixture.ts +9 -0
  159. package/src/platform/worker.node-test.ts +153 -0
  160. package/src/platform/worker.ts +425 -0
  161. package/src/plugins/core-slot.ts +579 -0
  162. package/src/plugins/registry.ts +402 -0
  163. package/src/plugins/types.ts +46 -0
  164. package/src/post/effects.ts +948 -0
  165. package/src/post/filters.ts +512 -0
  166. package/src/post/matrices.ts +288 -0
  167. package/src/renderables/ASCIIFont.ts +219 -0
  168. package/src/renderables/Box.test.ts +474 -0
  169. package/src/renderables/Box.ts +353 -0
  170. package/src/renderables/Code.test.ts +2388 -0
  171. package/src/renderables/Code.ts +555 -0
  172. package/src/renderables/Diff.regression.test.ts +381 -0
  173. package/src/renderables/Diff.test.ts +3212 -0
  174. package/src/renderables/Diff.ts +1278 -0
  175. package/src/renderables/EditBufferRenderable.test.ts +288 -0
  176. package/src/renderables/EditBufferRenderable.ts +1152 -0
  177. package/src/renderables/FrameBuffer.ts +47 -0
  178. package/src/renderables/Input.test.ts +1310 -0
  179. package/src/renderables/Input.ts +273 -0
  180. package/src/renderables/LineNumberRenderable.ts +725 -0
  181. package/src/renderables/Markdown.ts +2144 -0
  182. package/src/renderables/ScrollBar.ts +423 -0
  183. package/src/renderables/ScrollBox.ts +903 -0
  184. package/src/renderables/Select.test.ts +1134 -0
  185. package/src/renderables/Select.ts +535 -0
  186. package/src/renderables/Slider.test.ts +456 -0
  187. package/src/renderables/Slider.ts +342 -0
  188. package/src/renderables/TabSelect.test.ts +238 -0
  189. package/src/renderables/TabSelect.ts +447 -0
  190. package/src/renderables/Text.selection-buffer.test.ts +118 -0
  191. package/src/renderables/Text.test.ts +2662 -0
  192. package/src/renderables/Text.ts +147 -0
  193. package/src/renderables/TextBufferRenderable.ts +504 -0
  194. package/src/renderables/TextNode.test.ts +1137 -0
  195. package/src/renderables/TextNode.ts +379 -0
  196. package/src/renderables/TextTable.test.ts +1411 -0
  197. package/src/renderables/TextTable.ts +1434 -0
  198. package/src/renderables/Textarea.ts +425 -0
  199. package/src/renderables/TimeToFirstDraw.ts +89 -0
  200. package/src/renderables/__snapshots__/Code.test.ts.snap +13 -0
  201. package/src/renderables/__snapshots__/Diff.test.ts.snap +785 -0
  202. package/src/renderables/__snapshots__/Text.test.ts.snap +421 -0
  203. package/src/renderables/__snapshots__/TextTable.test.ts.snap +215 -0
  204. package/src/renderables/__tests__/Code.test.ts +55 -0
  205. package/src/renderables/__tests__/LineNumberRenderable.scrollbox-simple.test.ts +144 -0
  206. package/src/renderables/__tests__/LineNumberRenderable.scrollbox.test.ts +827 -0
  207. package/src/renderables/__tests__/LineNumberRenderable.test.ts +1906 -0
  208. package/src/renderables/__tests__/LineNumberRenderable.wrapping.test.ts +85 -0
  209. package/src/renderables/__tests__/Markdown.code-colors.test.ts +288 -0
  210. package/src/renderables/__tests__/Markdown.test.ts +4175 -0
  211. package/src/renderables/__tests__/MultiRenderable.selection.test.ts +87 -0
  212. package/src/renderables/__tests__/Textarea.buffer.test.ts +683 -0
  213. package/src/renderables/__tests__/Textarea.destroyed-events.test.ts +675 -0
  214. package/src/renderables/__tests__/Textarea.editing.test.ts +2120 -0
  215. package/src/renderables/__tests__/Textarea.error-handling.test.ts +35 -0
  216. package/src/renderables/__tests__/Textarea.events.test.ts +738 -0
  217. package/src/renderables/__tests__/Textarea.highlights.test.ts +590 -0
  218. package/src/renderables/__tests__/Textarea.keybinding.test.ts +3275 -0
  219. package/src/renderables/__tests__/Textarea.paste.test.ts +357 -0
  220. package/src/renderables/__tests__/Textarea.rendering.test.ts +1927 -0
  221. package/src/renderables/__tests__/Textarea.scroll.test.ts +733 -0
  222. package/src/renderables/__tests__/Textarea.selection.test.ts +1589 -0
  223. package/src/renderables/__tests__/Textarea.stress.test.ts +670 -0
  224. package/src/renderables/__tests__/Textarea.undo-redo.test.ts +383 -0
  225. package/src/renderables/__tests__/Textarea.visual-lines.test.ts +310 -0
  226. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.code.test.ts.snap +221 -0
  227. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox-simple.test.ts.snap +89 -0
  228. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.scrollbox.test.ts.snap +457 -0
  229. package/src/renderables/__tests__/__snapshots__/LineNumberRenderable.test.ts.snap +158 -0
  230. package/src/renderables/__tests__/__snapshots__/Textarea.rendering.test.ts.snap +387 -0
  231. package/src/renderables/__tests__/markdown-parser.test.ts +241 -0
  232. package/src/renderables/__tests__/renderable-test-utils.ts +60 -0
  233. package/src/renderables/composition/README.md +8 -0
  234. package/src/renderables/composition/VRenderable.ts +32 -0
  235. package/src/renderables/composition/constructs.ts +127 -0
  236. package/src/renderables/composition/vnode.ts +277 -0
  237. package/src/renderables/index.ts +23 -0
  238. package/src/renderables/markdown-parser.ts +79 -0
  239. package/src/renderer-theme-mode.ts +199 -0
  240. package/src/renderer.ts +4975 -0
  241. package/src/runtime-plugin-support-configure.ts +63 -0
  242. package/src/runtime-plugin-support.ts +13 -0
  243. package/src/runtime-plugin.ts +626 -0
  244. package/src/specs/terminal-startup.md +64 -0
  245. package/src/syntax-style.test.ts +841 -0
  246. package/src/syntax-style.ts +274 -0
  247. package/src/testing/README.md +219 -0
  248. package/src/testing/bun-test-node.ts +880 -0
  249. package/src/testing/capture-spans.test.ts +216 -0
  250. package/src/testing/integration.test.ts +276 -0
  251. package/src/testing/manual-clock.ts +117 -0
  252. package/src/testing/mock-keys.test.ts +1378 -0
  253. package/src/testing/mock-keys.ts +457 -0
  254. package/src/testing/mock-mouse.test.ts +218 -0
  255. package/src/testing/mock-mouse.ts +247 -0
  256. package/src/testing/mock-tree-sitter-client.ts +81 -0
  257. package/src/testing/spy.ts +13 -0
  258. package/src/testing/terminal-capabilities.ts +47 -0
  259. package/src/testing/test-recorder.test.ts +410 -0
  260. package/src/testing/test-recorder.ts +133 -0
  261. package/src/testing/test-renderer.ts +375 -0
  262. package/src/testing/test-renderer.wait.test.ts +278 -0
  263. package/src/testing/test-streams.ts +31 -0
  264. package/src/testing.ts +9 -0
  265. package/src/tests/__snapshots__/absolute-positioning.snapshot.test.ts.snap +481 -0
  266. package/src/tests/__snapshots__/renderable.snapshot.test.ts.snap +19 -0
  267. package/src/tests/__snapshots__/scrollbox.test.ts.snap +29 -0
  268. package/src/tests/absolute-positioning.snapshot.test.ts +638 -0
  269. package/src/tests/allocator-stats.test.ts +53 -0
  270. package/src/tests/audio.test.ts +303 -0
  271. package/src/tests/destroy-during-render.test.ts +200 -0
  272. package/src/tests/destroy-on-exit.fixture.ts +36 -0
  273. package/src/tests/destroy-on-exit.test.ts +62 -0
  274. package/src/tests/ffi-borrowed-pointer-callsites.test.ts +153 -0
  275. package/src/tests/hover-cursor.test.ts +98 -0
  276. package/src/tests/native-backed-measurement-lifecycle.test.ts +133 -0
  277. package/src/tests/native-backed-measurement-parity.test.ts +322 -0
  278. package/src/tests/native-span-feed-async.test.ts +173 -0
  279. package/src/tests/native-span-feed-close.test.ts +120 -0
  280. package/src/tests/native-span-feed-coverage.test.ts +227 -0
  281. package/src/tests/native-span-feed-edge-cases.test.ts +384 -0
  282. package/src/tests/native-span-feed-use-after-free.test.ts +45 -0
  283. package/src/tests/opacity.test.ts +123 -0
  284. package/src/tests/renderable.snapshot.test.ts +524 -0
  285. package/src/tests/renderable.test.ts +1851 -0
  286. package/src/tests/renderer.clock.test.ts +270 -0
  287. package/src/tests/renderer.console-startup.test.ts +2151 -0
  288. package/src/tests/renderer.control.test.ts +458 -0
  289. package/src/tests/renderer.core-slot-binding.test.ts +962 -0
  290. package/src/tests/renderer.cursor.test.ts +26 -0
  291. package/src/tests/renderer.custom-stdout.test.ts +1112 -0
  292. package/src/tests/renderer.destroy-during-render.test.ts +147 -0
  293. package/src/tests/renderer.focus-restore.test.ts +257 -0
  294. package/src/tests/renderer.focus.test.ts +329 -0
  295. package/src/tests/renderer.idle.test.ts +219 -0
  296. package/src/tests/renderer.input.test.ts +2615 -0
  297. package/src/tests/renderer.kitty-flags.test.ts +195 -0
  298. package/src/tests/renderer.lifecycle.test.ts +34 -0
  299. package/src/tests/renderer.mouse.test.ts +1315 -0
  300. package/src/tests/renderer.notifications.test.ts +27 -0
  301. package/src/tests/renderer.palette.test.ts +1199 -0
  302. package/src/tests/renderer.remote.test.ts +247 -0
  303. package/src/tests/renderer.render-stats.test.ts +146 -0
  304. package/src/tests/renderer.scrollback-surface.test.ts +474 -0
  305. package/src/tests/renderer.selection.test.ts +138 -0
  306. package/src/tests/renderer.slot-registry.test.ts +684 -0
  307. package/src/tests/renderer.tracker.test.ts +202 -0
  308. package/src/tests/renderer.useMouse.test.ts +83 -0
  309. package/src/tests/runtime-plugin-node-modules-cycle.fixture.ts +76 -0
  310. package/src/tests/runtime-plugin-node-modules-import-like-string.fixture.ts +48 -0
  311. package/src/tests/runtime-plugin-node-modules-mjs.fixture.ts +43 -0
  312. package/src/tests/runtime-plugin-node-modules-no-bare-rewrite.fixture.ts +67 -0
  313. package/src/tests/runtime-plugin-node-modules-package-type-cache.fixture.ts +72 -0
  314. package/src/tests/runtime-plugin-node-modules-runtime-specifier.fixture.ts +44 -0
  315. package/src/tests/runtime-plugin-node-modules-scoped-package-bare-rewrite.fixture.ts +85 -0
  316. package/src/tests/runtime-plugin-path-alias.fixture.ts +43 -0
  317. package/src/tests/runtime-plugin-resolve-roots.fixture.ts +65 -0
  318. package/src/tests/runtime-plugin-support-configure.fixture.ts +31 -0
  319. package/src/tests/runtime-plugin-support-late-addition.fixture.ts +17 -0
  320. package/src/tests/runtime-plugin-support.fixture.ts +11 -0
  321. package/src/tests/runtime-plugin-support.test.ts +54 -0
  322. package/src/tests/runtime-plugin-windows-file-url.fixture.ts +30 -0
  323. package/src/tests/runtime-plugin.fixture.ts +40 -0
  324. package/src/tests/runtime-plugin.test.ts +369 -0
  325. package/src/tests/scrollbox-culling-bug.test.ts +114 -0
  326. package/src/tests/scrollbox-hitgrid-resize.test.ts +136 -0
  327. package/src/tests/scrollbox-hitgrid.test.ts +909 -0
  328. package/src/tests/scrollbox.test.ts +1895 -0
  329. package/src/tests/wrap-resize-perf.test.ts +276 -0
  330. package/src/tests/yoga-api-coverage.test.ts +409 -0
  331. package/src/tests/yoga-callback-stress.test.ts +122 -0
  332. package/src/tests/yoga-ffi.test.ts +117 -0
  333. package/src/tests/yoga-setters.test.ts +921 -0
  334. package/src/tests/yoga-upstream/YGAlignBaselineTest.test.ts +124 -0
  335. package/src/tests/yoga-upstream/YGComputedBorderTest.test.ts +27 -0
  336. package/src/tests/yoga-upstream/YGComputedMarginTest.test.ts +27 -0
  337. package/src/tests/yoga-upstream/YGComputedPaddingTest.test.ts +27 -0
  338. package/src/tests/yoga-upstream/YGDirtiedTest.test.ts +157 -0
  339. package/src/tests/yoga-upstream/YGErrataTest.test.ts +40 -0
  340. package/src/tests/yoga-upstream/YGFlexBasisAuto.test.ts +23 -0
  341. package/src/tests/yoga-upstream/YGHasNewLayout.test.ts +81 -0
  342. package/src/tests/yoga-upstream/YGMeasureCacheTest.test.ts +31 -0
  343. package/src/tests/yoga-upstream/YGMeasureTest.test.ts +70 -0
  344. package/src/tests/yoga-upstream/generated/YGAbsolutePositionTest.test.ts +1864 -0
  345. package/src/tests/yoga-upstream/generated/YGAlignContentTest.test.ts +5829 -0
  346. package/src/tests/yoga-upstream/generated/YGAlignItemsTest.test.ts +2444 -0
  347. package/src/tests/yoga-upstream/generated/YGAlignSelfTest.test.ts +293 -0
  348. package/src/tests/yoga-upstream/generated/YGAndroidNewsFeed.test.ts +315 -0
  349. package/src/tests/yoga-upstream/generated/YGAspectRatioTest.test.ts +231 -0
  350. package/src/tests/yoga-upstream/generated/YGAutoTest.test.ts +347 -0
  351. package/src/tests/yoga-upstream/generated/YGBorderTest.test.ts +256 -0
  352. package/src/tests/yoga-upstream/generated/YGBoxSizingTest.test.ts +2747 -0
  353. package/src/tests/yoga-upstream/generated/YGDimensionTest.test.ts +129 -0
  354. package/src/tests/yoga-upstream/generated/YGDisplayContentsTest.test.ts +109 -0
  355. package/src/tests/yoga-upstream/generated/YGDisplayTest.test.ts +1097 -0
  356. package/src/tests/yoga-upstream/generated/YGFlexDirectionTest.test.ts +4562 -0
  357. package/src/tests/yoga-upstream/generated/YGFlexTest.test.ts +677 -0
  358. package/src/tests/yoga-upstream/generated/YGFlexWrapTest.test.ts +2071 -0
  359. package/src/tests/yoga-upstream/generated/YGGapTest.test.ts +3303 -0
  360. package/src/tests/yoga-upstream/generated/YGIntrinsicSizeTest.test.ts +582 -0
  361. package/src/tests/yoga-upstream/generated/YGJustifyContentTest.test.ts +2150 -0
  362. package/src/tests/yoga-upstream/generated/YGMarginTest.test.ts +1963 -0
  363. package/src/tests/yoga-upstream/generated/YGMinMaxDimensionTest.test.ts +1446 -0
  364. package/src/tests/yoga-upstream/generated/YGPaddingTest.test.ts +354 -0
  365. package/src/tests/yoga-upstream/generated/YGPercentageTest.test.ts +1760 -0
  366. package/src/tests/yoga-upstream/generated/YGRoundingTest.test.ts +1161 -0
  367. package/src/tests/yoga-upstream/generated/YGSizeOverflowTest.test.ts +207 -0
  368. package/src/tests/yoga-upstream/generated/YGStaticPositionTest.test.ts +6338 -0
  369. package/src/tests/yoga-upstream/tools/MeasureCounter.ts +54 -0
  370. package/src/tests/yoga-upstream/tools/utils.ts +81 -0
  371. package/src/text-buffer-view.test.ts +722 -0
  372. package/src/text-buffer-view.ts +193 -0
  373. package/src/text-buffer.test.ts +512 -0
  374. package/src/text-buffer.ts +250 -0
  375. package/src/types.ts +199 -0
  376. package/src/utils.ts +88 -0
  377. package/src/yoga.ts +1146 -0
  378. package/src/zig/ansi.zig +502 -0
  379. package/src/zig/audio.zig +1206 -0
  380. package/src/zig/bench/README.md +50 -0
  381. package/src/zig/bench/buffer-color-blending_bench.zig +350 -0
  382. package/src/zig/bench/buffer-draw-box_bench.zig +786 -0
  383. package/src/zig/bench/buffer-draw-text-buffer_bench.zig +894 -0
  384. package/src/zig/bench/edit-buffer_bench.zig +476 -0
  385. package/src/zig/bench/editor-view_bench.zig +169 -0
  386. package/src/zig/bench/native-span-feed_bench.zig +107 -0
  387. package/src/zig/bench/rope-markers_bench.zig +713 -0
  388. package/src/zig/bench/rope_bench.zig +514 -0
  389. package/src/zig/bench/styled-text_bench.zig +476 -0
  390. package/src/zig/bench/text-buffer-coords_bench.zig +362 -0
  391. package/src/zig/bench/text-buffer-view_bench.zig +459 -0
  392. package/src/zig/bench/text-chunk-graphemes_bench.zig +272 -0
  393. package/src/zig/bench/utf8_bench.zig +799 -0
  394. package/src/zig/bench-utils.zig +431 -0
  395. package/src/zig/bench.zig +223 -0
  396. package/src/zig/buffer-methods.zig +215 -0
  397. package/src/zig/buffer.zig +2515 -0
  398. package/src/zig/build.zig +700 -0
  399. package/src/zig/build.zig.zon +19 -0
  400. package/src/zig/edit-buffer.zig +900 -0
  401. package/src/zig/editor-view.zig +812 -0
  402. package/src/zig/event-bus.zig +28 -0
  403. package/src/zig/event-emitter.zig +65 -0
  404. package/src/zig/file-logger.zig +92 -0
  405. package/src/zig/grapheme.zig +838 -0
  406. package/src/zig/handles.zig +267 -0
  407. package/src/zig/lib.zig +2813 -0
  408. package/src/zig/link.zig +349 -0
  409. package/src/zig/logger.zig +43 -0
  410. package/src/zig/mem-registry.zig +126 -0
  411. package/src/zig/miniaudio_shim.c +21 -0
  412. package/src/zig/native-renderable.zig +112 -0
  413. package/src/zig/native-span-feed-bench-lib.zig +7 -0
  414. package/src/zig/native-span-feed.zig +747 -0
  415. package/src/zig/renderer-output.zig +677 -0
  416. package/src/zig/renderer.zig +2106 -0
  417. package/src/zig/rope.zig +1220 -0
  418. package/src/zig/split-scrollback.zig +88 -0
  419. package/src/zig/syntax-style.zig +174 -0
  420. package/src/zig/terminal.zig +1652 -0
  421. package/src/zig/test.zig +82 -0
  422. package/src/zig/tests/README.md +18 -0
  423. package/src/zig/tests/ansi_test.zig +18 -0
  424. package/src/zig/tests/audio_test.zig +439 -0
  425. package/src/zig/tests/buffer-methods_test.zig +1111 -0
  426. package/src/zig/tests/buffer_test.zig +2926 -0
  427. package/src/zig/tests/edit-buffer-history_test.zig +299 -0
  428. package/src/zig/tests/edit-buffer_test.zig +1688 -0
  429. package/src/zig/tests/editor-view_test.zig +3454 -0
  430. package/src/zig/tests/event-emitter_test.zig +249 -0
  431. package/src/zig/tests/grapheme_test.zig +1329 -0
  432. package/src/zig/tests/handles_test.zig +123 -0
  433. package/src/zig/tests/link_test.zig +220 -0
  434. package/src/zig/tests/mem-registry_test.zig +473 -0
  435. package/src/zig/tests/memory_leak_regression_test.zig +234 -0
  436. package/src/zig/tests/native-renderable_test.zig +16 -0
  437. package/src/zig/tests/native-span-feed_test.zig +1266 -0
  438. package/src/zig/tests/renderer_test.zig +2604 -0
  439. package/src/zig/tests/rope-nested_test.zig +712 -0
  440. package/src/zig/tests/rope_fuzz_test.zig +238 -0
  441. package/src/zig/tests/rope_test.zig +2362 -0
  442. package/src/zig/tests/segment-merge.test.zig +148 -0
  443. package/src/zig/tests/split-scrollback_test.zig +70 -0
  444. package/src/zig/tests/syntax-style_test.zig +558 -0
  445. package/src/zig/tests/terminal_test.zig +1489 -0
  446. package/src/zig/tests/test-renderer.zig +126 -0
  447. package/src/zig/tests/text-buffer-drawing_test.zig +3291 -0
  448. package/src/zig/tests/text-buffer-highlights_test.zig +706 -0
  449. package/src/zig/tests/text-buffer-iterators_test.zig +776 -0
  450. package/src/zig/tests/text-buffer-segment_test.zig +320 -0
  451. package/src/zig/tests/text-buffer-selection_test.zig +1056 -0
  452. package/src/zig/tests/text-buffer-selection_viewport_test.zig +358 -0
  453. package/src/zig/tests/text-buffer-view_test.zig +3672 -0
  454. package/src/zig/tests/text-buffer_test.zig +2191 -0
  455. package/src/zig/tests/unicode-width-map.zon +3909 -0
  456. package/src/zig/tests/utf8_no_zwj_test.zig +260 -0
  457. package/src/zig/tests/utf8_test.zig +4060 -0
  458. package/src/zig/tests/utf8_wcwidth_cursor_test.zig +267 -0
  459. package/src/zig/tests/utf8_wcwidth_test.zig +357 -0
  460. package/src/zig/tests/word-wrap-editing_test.zig +498 -0
  461. package/src/zig/tests/wrap-cache-perf_test.zig +113 -0
  462. package/src/zig/tests/yoga_test.zig +65 -0
  463. package/src/zig/text-buffer-iterators.zig +496 -0
  464. package/src/zig/text-buffer-segment.zig +403 -0
  465. package/src/zig/text-buffer-view.zig +1428 -0
  466. package/src/zig/text-buffer.zig +1272 -0
  467. package/src/zig/utf8.zig +1954 -0
  468. package/src/zig/utils.zig +12 -0
  469. package/src/zig/uucode-stub.zig +76 -0
  470. package/src/zig/vendor/miniaudio/miniaudio.h +93468 -0
  471. package/src/zig/yoga.zig +658 -0
  472. package/src/zig-structs.ts +381 -0
  473. package/src/zig.ts +5260 -0
  474. package/tsconfig.build.json +17 -0
  475. package/tsconfig.json +27 -0
  476. package/tsconfig.node-test.json +138 -0
@@ -0,0 +1,3303 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<3fad56933a314f0a81b6ed504040ffae>>
8
+ * generated by gentest/gentest-driver.ts from gentest/fixtures/YGGapTest.html
9
+ */
10
+
11
+ import { instrinsicSizeMeasureFunc } from "../tools/utils.ts"
12
+ import Yoga from "../../../yoga.js"
13
+ import {
14
+ Align,
15
+ BoxSizing,
16
+ Direction,
17
+ Display,
18
+ Edge,
19
+ Errata,
20
+ ExperimentalFeature,
21
+ FlexDirection,
22
+ Gutter,
23
+ Justify,
24
+ MeasureMode,
25
+ Overflow,
26
+ PositionType,
27
+ Unit,
28
+ Wrap,
29
+ } from "../../../yoga.js"
30
+
31
+ test("column_gap_flexible", () => {
32
+ const config = Yoga.Config.create()
33
+ let root
34
+
35
+ try {
36
+ root = Yoga.Node.create(config)
37
+ root.setFlexDirection(FlexDirection.Row)
38
+ root.setPositionType(PositionType.Absolute)
39
+ root.setWidth(80)
40
+ root.setHeight(100)
41
+ root.setGap(Gutter.Column, 10)
42
+ root.setGap(Gutter.Row, 20)
43
+
44
+ const root_child0 = Yoga.Node.create(config)
45
+ root_child0.setFlexGrow(1)
46
+ root_child0.setFlexShrink(1)
47
+ root_child0.setFlexBasis("0%")
48
+ root.insertChild(root_child0, 0)
49
+
50
+ const root_child1 = Yoga.Node.create(config)
51
+ root_child1.setFlexGrow(1)
52
+ root_child1.setFlexShrink(1)
53
+ root_child1.setFlexBasis("0%")
54
+ root.insertChild(root_child1, 1)
55
+
56
+ const root_child2 = Yoga.Node.create(config)
57
+ root_child2.setFlexGrow(1)
58
+ root_child2.setFlexShrink(1)
59
+ root_child2.setFlexBasis("0%")
60
+ root.insertChild(root_child2, 2)
61
+ root.calculateLayout(undefined, undefined, Direction.LTR)
62
+
63
+ expect(root.getComputedLeft()).toBe(0)
64
+ expect(root.getComputedTop()).toBe(0)
65
+ expect(root.getComputedWidth()).toBe(80)
66
+ expect(root.getComputedHeight()).toBe(100)
67
+
68
+ expect(root_child0.getComputedLeft()).toBe(0)
69
+ expect(root_child0.getComputedTop()).toBe(0)
70
+ expect(root_child0.getComputedWidth()).toBe(20)
71
+ expect(root_child0.getComputedHeight()).toBe(100)
72
+
73
+ expect(root_child1.getComputedLeft()).toBe(30)
74
+ expect(root_child1.getComputedTop()).toBe(0)
75
+ expect(root_child1.getComputedWidth()).toBe(20)
76
+ expect(root_child1.getComputedHeight()).toBe(100)
77
+
78
+ expect(root_child2.getComputedLeft()).toBe(60)
79
+ expect(root_child2.getComputedTop()).toBe(0)
80
+ expect(root_child2.getComputedWidth()).toBe(20)
81
+ expect(root_child2.getComputedHeight()).toBe(100)
82
+
83
+ root.calculateLayout(undefined, undefined, Direction.RTL)
84
+
85
+ expect(root.getComputedLeft()).toBe(0)
86
+ expect(root.getComputedTop()).toBe(0)
87
+ expect(root.getComputedWidth()).toBe(80)
88
+ expect(root.getComputedHeight()).toBe(100)
89
+
90
+ expect(root_child0.getComputedLeft()).toBe(60)
91
+ expect(root_child0.getComputedTop()).toBe(0)
92
+ expect(root_child0.getComputedWidth()).toBe(20)
93
+ expect(root_child0.getComputedHeight()).toBe(100)
94
+
95
+ expect(root_child1.getComputedLeft()).toBe(30)
96
+ expect(root_child1.getComputedTop()).toBe(0)
97
+ expect(root_child1.getComputedWidth()).toBe(20)
98
+ expect(root_child1.getComputedHeight()).toBe(100)
99
+
100
+ expect(root_child2.getComputedLeft()).toBe(0)
101
+ expect(root_child2.getComputedTop()).toBe(0)
102
+ expect(root_child2.getComputedWidth()).toBe(20)
103
+ expect(root_child2.getComputedHeight()).toBe(100)
104
+ } finally {
105
+ if (typeof root !== "undefined") {
106
+ root.freeRecursive()
107
+ }
108
+
109
+ config.free()
110
+ }
111
+ })
112
+ test("column_gap_inflexible", () => {
113
+ const config = Yoga.Config.create()
114
+ let root
115
+
116
+ try {
117
+ root = Yoga.Node.create(config)
118
+ root.setFlexDirection(FlexDirection.Row)
119
+ root.setPositionType(PositionType.Absolute)
120
+ root.setWidth(80)
121
+ root.setHeight(100)
122
+ root.setGap(Gutter.Column, 10)
123
+
124
+ const root_child0 = Yoga.Node.create(config)
125
+ root_child0.setWidth(20)
126
+ root.insertChild(root_child0, 0)
127
+
128
+ const root_child1 = Yoga.Node.create(config)
129
+ root_child1.setWidth(20)
130
+ root.insertChild(root_child1, 1)
131
+
132
+ const root_child2 = Yoga.Node.create(config)
133
+ root_child2.setWidth(20)
134
+ root.insertChild(root_child2, 2)
135
+ root.calculateLayout(undefined, undefined, Direction.LTR)
136
+
137
+ expect(root.getComputedLeft()).toBe(0)
138
+ expect(root.getComputedTop()).toBe(0)
139
+ expect(root.getComputedWidth()).toBe(80)
140
+ expect(root.getComputedHeight()).toBe(100)
141
+
142
+ expect(root_child0.getComputedLeft()).toBe(0)
143
+ expect(root_child0.getComputedTop()).toBe(0)
144
+ expect(root_child0.getComputedWidth()).toBe(20)
145
+ expect(root_child0.getComputedHeight()).toBe(100)
146
+
147
+ expect(root_child1.getComputedLeft()).toBe(30)
148
+ expect(root_child1.getComputedTop()).toBe(0)
149
+ expect(root_child1.getComputedWidth()).toBe(20)
150
+ expect(root_child1.getComputedHeight()).toBe(100)
151
+
152
+ expect(root_child2.getComputedLeft()).toBe(60)
153
+ expect(root_child2.getComputedTop()).toBe(0)
154
+ expect(root_child2.getComputedWidth()).toBe(20)
155
+ expect(root_child2.getComputedHeight()).toBe(100)
156
+
157
+ root.calculateLayout(undefined, undefined, Direction.RTL)
158
+
159
+ expect(root.getComputedLeft()).toBe(0)
160
+ expect(root.getComputedTop()).toBe(0)
161
+ expect(root.getComputedWidth()).toBe(80)
162
+ expect(root.getComputedHeight()).toBe(100)
163
+
164
+ expect(root_child0.getComputedLeft()).toBe(60)
165
+ expect(root_child0.getComputedTop()).toBe(0)
166
+ expect(root_child0.getComputedWidth()).toBe(20)
167
+ expect(root_child0.getComputedHeight()).toBe(100)
168
+
169
+ expect(root_child1.getComputedLeft()).toBe(30)
170
+ expect(root_child1.getComputedTop()).toBe(0)
171
+ expect(root_child1.getComputedWidth()).toBe(20)
172
+ expect(root_child1.getComputedHeight()).toBe(100)
173
+
174
+ expect(root_child2.getComputedLeft()).toBe(0)
175
+ expect(root_child2.getComputedTop()).toBe(0)
176
+ expect(root_child2.getComputedWidth()).toBe(20)
177
+ expect(root_child2.getComputedHeight()).toBe(100)
178
+ } finally {
179
+ if (typeof root !== "undefined") {
180
+ root.freeRecursive()
181
+ }
182
+
183
+ config.free()
184
+ }
185
+ })
186
+ test("column_gap_mixed_flexible", () => {
187
+ const config = Yoga.Config.create()
188
+ let root
189
+
190
+ try {
191
+ root = Yoga.Node.create(config)
192
+ root.setFlexDirection(FlexDirection.Row)
193
+ root.setPositionType(PositionType.Absolute)
194
+ root.setWidth(80)
195
+ root.setHeight(100)
196
+ root.setGap(Gutter.Column, 10)
197
+
198
+ const root_child0 = Yoga.Node.create(config)
199
+ root_child0.setWidth(20)
200
+ root.insertChild(root_child0, 0)
201
+
202
+ const root_child1 = Yoga.Node.create(config)
203
+ root_child1.setFlexGrow(1)
204
+ root_child1.setFlexShrink(1)
205
+ root_child1.setFlexBasis("0%")
206
+ root.insertChild(root_child1, 1)
207
+
208
+ const root_child2 = Yoga.Node.create(config)
209
+ root_child2.setWidth(20)
210
+ root.insertChild(root_child2, 2)
211
+ root.calculateLayout(undefined, undefined, Direction.LTR)
212
+
213
+ expect(root.getComputedLeft()).toBe(0)
214
+ expect(root.getComputedTop()).toBe(0)
215
+ expect(root.getComputedWidth()).toBe(80)
216
+ expect(root.getComputedHeight()).toBe(100)
217
+
218
+ expect(root_child0.getComputedLeft()).toBe(0)
219
+ expect(root_child0.getComputedTop()).toBe(0)
220
+ expect(root_child0.getComputedWidth()).toBe(20)
221
+ expect(root_child0.getComputedHeight()).toBe(100)
222
+
223
+ expect(root_child1.getComputedLeft()).toBe(30)
224
+ expect(root_child1.getComputedTop()).toBe(0)
225
+ expect(root_child1.getComputedWidth()).toBe(20)
226
+ expect(root_child1.getComputedHeight()).toBe(100)
227
+
228
+ expect(root_child2.getComputedLeft()).toBe(60)
229
+ expect(root_child2.getComputedTop()).toBe(0)
230
+ expect(root_child2.getComputedWidth()).toBe(20)
231
+ expect(root_child2.getComputedHeight()).toBe(100)
232
+
233
+ root.calculateLayout(undefined, undefined, Direction.RTL)
234
+
235
+ expect(root.getComputedLeft()).toBe(0)
236
+ expect(root.getComputedTop()).toBe(0)
237
+ expect(root.getComputedWidth()).toBe(80)
238
+ expect(root.getComputedHeight()).toBe(100)
239
+
240
+ expect(root_child0.getComputedLeft()).toBe(60)
241
+ expect(root_child0.getComputedTop()).toBe(0)
242
+ expect(root_child0.getComputedWidth()).toBe(20)
243
+ expect(root_child0.getComputedHeight()).toBe(100)
244
+
245
+ expect(root_child1.getComputedLeft()).toBe(30)
246
+ expect(root_child1.getComputedTop()).toBe(0)
247
+ expect(root_child1.getComputedWidth()).toBe(20)
248
+ expect(root_child1.getComputedHeight()).toBe(100)
249
+
250
+ expect(root_child2.getComputedLeft()).toBe(0)
251
+ expect(root_child2.getComputedTop()).toBe(0)
252
+ expect(root_child2.getComputedWidth()).toBe(20)
253
+ expect(root_child2.getComputedHeight()).toBe(100)
254
+ } finally {
255
+ if (typeof root !== "undefined") {
256
+ root.freeRecursive()
257
+ }
258
+
259
+ config.free()
260
+ }
261
+ })
262
+ test("column_gap_child_margins", () => {
263
+ const config = Yoga.Config.create()
264
+ let root
265
+
266
+ try {
267
+ root = Yoga.Node.create(config)
268
+ root.setFlexDirection(FlexDirection.Row)
269
+ root.setPositionType(PositionType.Absolute)
270
+ root.setWidth(80)
271
+ root.setHeight(100)
272
+ root.setGap(Gutter.Column, 10)
273
+
274
+ const root_child0 = Yoga.Node.create(config)
275
+ root_child0.setFlexGrow(1)
276
+ root_child0.setFlexShrink(1)
277
+ root_child0.setFlexBasis("0%")
278
+ root_child0.setMargin(Edge.Left, 2)
279
+ root_child0.setMargin(Edge.Right, 2)
280
+ root.insertChild(root_child0, 0)
281
+
282
+ const root_child1 = Yoga.Node.create(config)
283
+ root_child1.setFlexGrow(1)
284
+ root_child1.setFlexShrink(1)
285
+ root_child1.setFlexBasis("0%")
286
+ root_child1.setMargin(Edge.Left, 10)
287
+ root_child1.setMargin(Edge.Right, 10)
288
+ root.insertChild(root_child1, 1)
289
+
290
+ const root_child2 = Yoga.Node.create(config)
291
+ root_child2.setFlexGrow(1)
292
+ root_child2.setFlexShrink(1)
293
+ root_child2.setFlexBasis("0%")
294
+ root_child2.setMargin(Edge.Left, 15)
295
+ root_child2.setMargin(Edge.Right, 15)
296
+ root.insertChild(root_child2, 2)
297
+ root.calculateLayout(undefined, undefined, Direction.LTR)
298
+
299
+ expect(root.getComputedLeft()).toBe(0)
300
+ expect(root.getComputedTop()).toBe(0)
301
+ expect(root.getComputedWidth()).toBe(80)
302
+ expect(root.getComputedHeight()).toBe(100)
303
+
304
+ expect(root_child0.getComputedLeft()).toBe(2)
305
+ expect(root_child0.getComputedTop()).toBe(0)
306
+ expect(root_child0.getComputedWidth()).toBe(2)
307
+ expect(root_child0.getComputedHeight()).toBe(100)
308
+
309
+ expect(root_child1.getComputedLeft()).toBe(26)
310
+ expect(root_child1.getComputedTop()).toBe(0)
311
+ expect(root_child1.getComputedWidth()).toBe(2)
312
+ expect(root_child1.getComputedHeight()).toBe(100)
313
+
314
+ expect(root_child2.getComputedLeft()).toBe(63)
315
+ expect(root_child2.getComputedTop()).toBe(0)
316
+ expect(root_child2.getComputedWidth()).toBe(2)
317
+ expect(root_child2.getComputedHeight()).toBe(100)
318
+
319
+ root.calculateLayout(undefined, undefined, Direction.RTL)
320
+
321
+ expect(root.getComputedLeft()).toBe(0)
322
+ expect(root.getComputedTop()).toBe(0)
323
+ expect(root.getComputedWidth()).toBe(80)
324
+ expect(root.getComputedHeight()).toBe(100)
325
+
326
+ expect(root_child0.getComputedLeft()).toBe(76)
327
+ expect(root_child0.getComputedTop()).toBe(0)
328
+ expect(root_child0.getComputedWidth()).toBe(2)
329
+ expect(root_child0.getComputedHeight()).toBe(100)
330
+
331
+ expect(root_child1.getComputedLeft()).toBe(52)
332
+ expect(root_child1.getComputedTop()).toBe(0)
333
+ expect(root_child1.getComputedWidth()).toBe(2)
334
+ expect(root_child1.getComputedHeight()).toBe(100)
335
+
336
+ expect(root_child2.getComputedLeft()).toBe(15)
337
+ expect(root_child2.getComputedTop()).toBe(0)
338
+ expect(root_child2.getComputedWidth()).toBe(2)
339
+ expect(root_child2.getComputedHeight()).toBe(100)
340
+ } finally {
341
+ if (typeof root !== "undefined") {
342
+ root.freeRecursive()
343
+ }
344
+
345
+ config.free()
346
+ }
347
+ })
348
+ test("column_row_gap_wrapping", () => {
349
+ const config = Yoga.Config.create()
350
+ let root
351
+
352
+ try {
353
+ root = Yoga.Node.create(config)
354
+ root.setFlexDirection(FlexDirection.Row)
355
+ root.setPositionType(PositionType.Absolute)
356
+ root.setFlexWrap(Wrap.Wrap)
357
+ root.setWidth(80)
358
+ root.setGap(Gutter.Column, 10)
359
+ root.setGap(Gutter.Row, 20)
360
+
361
+ const root_child0 = Yoga.Node.create(config)
362
+ root_child0.setWidth(20)
363
+ root_child0.setHeight(20)
364
+ root.insertChild(root_child0, 0)
365
+
366
+ const root_child1 = Yoga.Node.create(config)
367
+ root_child1.setWidth(20)
368
+ root_child1.setHeight(20)
369
+ root.insertChild(root_child1, 1)
370
+
371
+ const root_child2 = Yoga.Node.create(config)
372
+ root_child2.setWidth(20)
373
+ root_child2.setHeight(20)
374
+ root.insertChild(root_child2, 2)
375
+
376
+ const root_child3 = Yoga.Node.create(config)
377
+ root_child3.setWidth(20)
378
+ root_child3.setHeight(20)
379
+ root.insertChild(root_child3, 3)
380
+
381
+ const root_child4 = Yoga.Node.create(config)
382
+ root_child4.setWidth(20)
383
+ root_child4.setHeight(20)
384
+ root.insertChild(root_child4, 4)
385
+
386
+ const root_child5 = Yoga.Node.create(config)
387
+ root_child5.setWidth(20)
388
+ root_child5.setHeight(20)
389
+ root.insertChild(root_child5, 5)
390
+
391
+ const root_child6 = Yoga.Node.create(config)
392
+ root_child6.setWidth(20)
393
+ root_child6.setHeight(20)
394
+ root.insertChild(root_child6, 6)
395
+
396
+ const root_child7 = Yoga.Node.create(config)
397
+ root_child7.setWidth(20)
398
+ root_child7.setHeight(20)
399
+ root.insertChild(root_child7, 7)
400
+
401
+ const root_child8 = Yoga.Node.create(config)
402
+ root_child8.setWidth(20)
403
+ root_child8.setHeight(20)
404
+ root.insertChild(root_child8, 8)
405
+ root.calculateLayout(undefined, undefined, Direction.LTR)
406
+
407
+ expect(root.getComputedLeft()).toBe(0)
408
+ expect(root.getComputedTop()).toBe(0)
409
+ expect(root.getComputedWidth()).toBe(80)
410
+ expect(root.getComputedHeight()).toBe(100)
411
+
412
+ expect(root_child0.getComputedLeft()).toBe(0)
413
+ expect(root_child0.getComputedTop()).toBe(0)
414
+ expect(root_child0.getComputedWidth()).toBe(20)
415
+ expect(root_child0.getComputedHeight()).toBe(20)
416
+
417
+ expect(root_child1.getComputedLeft()).toBe(30)
418
+ expect(root_child1.getComputedTop()).toBe(0)
419
+ expect(root_child1.getComputedWidth()).toBe(20)
420
+ expect(root_child1.getComputedHeight()).toBe(20)
421
+
422
+ expect(root_child2.getComputedLeft()).toBe(60)
423
+ expect(root_child2.getComputedTop()).toBe(0)
424
+ expect(root_child2.getComputedWidth()).toBe(20)
425
+ expect(root_child2.getComputedHeight()).toBe(20)
426
+
427
+ expect(root_child3.getComputedLeft()).toBe(0)
428
+ expect(root_child3.getComputedTop()).toBe(40)
429
+ expect(root_child3.getComputedWidth()).toBe(20)
430
+ expect(root_child3.getComputedHeight()).toBe(20)
431
+
432
+ expect(root_child4.getComputedLeft()).toBe(30)
433
+ expect(root_child4.getComputedTop()).toBe(40)
434
+ expect(root_child4.getComputedWidth()).toBe(20)
435
+ expect(root_child4.getComputedHeight()).toBe(20)
436
+
437
+ expect(root_child5.getComputedLeft()).toBe(60)
438
+ expect(root_child5.getComputedTop()).toBe(40)
439
+ expect(root_child5.getComputedWidth()).toBe(20)
440
+ expect(root_child5.getComputedHeight()).toBe(20)
441
+
442
+ expect(root_child6.getComputedLeft()).toBe(0)
443
+ expect(root_child6.getComputedTop()).toBe(80)
444
+ expect(root_child6.getComputedWidth()).toBe(20)
445
+ expect(root_child6.getComputedHeight()).toBe(20)
446
+
447
+ expect(root_child7.getComputedLeft()).toBe(30)
448
+ expect(root_child7.getComputedTop()).toBe(80)
449
+ expect(root_child7.getComputedWidth()).toBe(20)
450
+ expect(root_child7.getComputedHeight()).toBe(20)
451
+
452
+ expect(root_child8.getComputedLeft()).toBe(60)
453
+ expect(root_child8.getComputedTop()).toBe(80)
454
+ expect(root_child8.getComputedWidth()).toBe(20)
455
+ expect(root_child8.getComputedHeight()).toBe(20)
456
+
457
+ root.calculateLayout(undefined, undefined, Direction.RTL)
458
+
459
+ expect(root.getComputedLeft()).toBe(0)
460
+ expect(root.getComputedTop()).toBe(0)
461
+ expect(root.getComputedWidth()).toBe(80)
462
+ expect(root.getComputedHeight()).toBe(100)
463
+
464
+ expect(root_child0.getComputedLeft()).toBe(60)
465
+ expect(root_child0.getComputedTop()).toBe(0)
466
+ expect(root_child0.getComputedWidth()).toBe(20)
467
+ expect(root_child0.getComputedHeight()).toBe(20)
468
+
469
+ expect(root_child1.getComputedLeft()).toBe(30)
470
+ expect(root_child1.getComputedTop()).toBe(0)
471
+ expect(root_child1.getComputedWidth()).toBe(20)
472
+ expect(root_child1.getComputedHeight()).toBe(20)
473
+
474
+ expect(root_child2.getComputedLeft()).toBe(0)
475
+ expect(root_child2.getComputedTop()).toBe(0)
476
+ expect(root_child2.getComputedWidth()).toBe(20)
477
+ expect(root_child2.getComputedHeight()).toBe(20)
478
+
479
+ expect(root_child3.getComputedLeft()).toBe(60)
480
+ expect(root_child3.getComputedTop()).toBe(40)
481
+ expect(root_child3.getComputedWidth()).toBe(20)
482
+ expect(root_child3.getComputedHeight()).toBe(20)
483
+
484
+ expect(root_child4.getComputedLeft()).toBe(30)
485
+ expect(root_child4.getComputedTop()).toBe(40)
486
+ expect(root_child4.getComputedWidth()).toBe(20)
487
+ expect(root_child4.getComputedHeight()).toBe(20)
488
+
489
+ expect(root_child5.getComputedLeft()).toBe(0)
490
+ expect(root_child5.getComputedTop()).toBe(40)
491
+ expect(root_child5.getComputedWidth()).toBe(20)
492
+ expect(root_child5.getComputedHeight()).toBe(20)
493
+
494
+ expect(root_child6.getComputedLeft()).toBe(60)
495
+ expect(root_child6.getComputedTop()).toBe(80)
496
+ expect(root_child6.getComputedWidth()).toBe(20)
497
+ expect(root_child6.getComputedHeight()).toBe(20)
498
+
499
+ expect(root_child7.getComputedLeft()).toBe(30)
500
+ expect(root_child7.getComputedTop()).toBe(80)
501
+ expect(root_child7.getComputedWidth()).toBe(20)
502
+ expect(root_child7.getComputedHeight()).toBe(20)
503
+
504
+ expect(root_child8.getComputedLeft()).toBe(0)
505
+ expect(root_child8.getComputedTop()).toBe(80)
506
+ expect(root_child8.getComputedWidth()).toBe(20)
507
+ expect(root_child8.getComputedHeight()).toBe(20)
508
+ } finally {
509
+ if (typeof root !== "undefined") {
510
+ root.freeRecursive()
511
+ }
512
+
513
+ config.free()
514
+ }
515
+ })
516
+ test("column_gap_start_index", () => {
517
+ const config = Yoga.Config.create()
518
+ let root
519
+
520
+ try {
521
+ root = Yoga.Node.create(config)
522
+ root.setFlexDirection(FlexDirection.Row)
523
+ root.setPositionType(PositionType.Absolute)
524
+ root.setFlexWrap(Wrap.Wrap)
525
+ root.setWidth(80)
526
+ root.setGap(Gutter.Column, 10)
527
+ root.setGap(Gutter.Row, 20)
528
+
529
+ const root_child0 = Yoga.Node.create(config)
530
+ root_child0.setPositionType(PositionType.Absolute)
531
+ root_child0.setWidth(20)
532
+ root_child0.setHeight(20)
533
+ root.insertChild(root_child0, 0)
534
+
535
+ const root_child1 = Yoga.Node.create(config)
536
+ root_child1.setWidth(20)
537
+ root_child1.setHeight(20)
538
+ root.insertChild(root_child1, 1)
539
+
540
+ const root_child2 = Yoga.Node.create(config)
541
+ root_child2.setWidth(20)
542
+ root_child2.setHeight(20)
543
+ root.insertChild(root_child2, 2)
544
+
545
+ const root_child3 = Yoga.Node.create(config)
546
+ root_child3.setWidth(20)
547
+ root_child3.setHeight(20)
548
+ root.insertChild(root_child3, 3)
549
+ root.calculateLayout(undefined, undefined, Direction.LTR)
550
+
551
+ expect(root.getComputedLeft()).toBe(0)
552
+ expect(root.getComputedTop()).toBe(0)
553
+ expect(root.getComputedWidth()).toBe(80)
554
+ expect(root.getComputedHeight()).toBe(20)
555
+
556
+ expect(root_child0.getComputedLeft()).toBe(0)
557
+ expect(root_child0.getComputedTop()).toBe(0)
558
+ expect(root_child0.getComputedWidth()).toBe(20)
559
+ expect(root_child0.getComputedHeight()).toBe(20)
560
+
561
+ expect(root_child1.getComputedLeft()).toBe(0)
562
+ expect(root_child1.getComputedTop()).toBe(0)
563
+ expect(root_child1.getComputedWidth()).toBe(20)
564
+ expect(root_child1.getComputedHeight()).toBe(20)
565
+
566
+ expect(root_child2.getComputedLeft()).toBe(30)
567
+ expect(root_child2.getComputedTop()).toBe(0)
568
+ expect(root_child2.getComputedWidth()).toBe(20)
569
+ expect(root_child2.getComputedHeight()).toBe(20)
570
+
571
+ expect(root_child3.getComputedLeft()).toBe(60)
572
+ expect(root_child3.getComputedTop()).toBe(0)
573
+ expect(root_child3.getComputedWidth()).toBe(20)
574
+ expect(root_child3.getComputedHeight()).toBe(20)
575
+
576
+ root.calculateLayout(undefined, undefined, Direction.RTL)
577
+
578
+ expect(root.getComputedLeft()).toBe(0)
579
+ expect(root.getComputedTop()).toBe(0)
580
+ expect(root.getComputedWidth()).toBe(80)
581
+ expect(root.getComputedHeight()).toBe(20)
582
+
583
+ expect(root_child0.getComputedLeft()).toBe(60)
584
+ expect(root_child0.getComputedTop()).toBe(0)
585
+ expect(root_child0.getComputedWidth()).toBe(20)
586
+ expect(root_child0.getComputedHeight()).toBe(20)
587
+
588
+ expect(root_child1.getComputedLeft()).toBe(60)
589
+ expect(root_child1.getComputedTop()).toBe(0)
590
+ expect(root_child1.getComputedWidth()).toBe(20)
591
+ expect(root_child1.getComputedHeight()).toBe(20)
592
+
593
+ expect(root_child2.getComputedLeft()).toBe(30)
594
+ expect(root_child2.getComputedTop()).toBe(0)
595
+ expect(root_child2.getComputedWidth()).toBe(20)
596
+ expect(root_child2.getComputedHeight()).toBe(20)
597
+
598
+ expect(root_child3.getComputedLeft()).toBe(0)
599
+ expect(root_child3.getComputedTop()).toBe(0)
600
+ expect(root_child3.getComputedWidth()).toBe(20)
601
+ expect(root_child3.getComputedHeight()).toBe(20)
602
+ } finally {
603
+ if (typeof root !== "undefined") {
604
+ root.freeRecursive()
605
+ }
606
+
607
+ config.free()
608
+ }
609
+ })
610
+ test("column_gap_justify_flex_start", () => {
611
+ const config = Yoga.Config.create()
612
+ let root
613
+
614
+ try {
615
+ root = Yoga.Node.create(config)
616
+ root.setFlexDirection(FlexDirection.Row)
617
+ root.setPositionType(PositionType.Absolute)
618
+ root.setWidth(100)
619
+ root.setHeight(100)
620
+ root.setGap(Gutter.Column, 10)
621
+
622
+ const root_child0 = Yoga.Node.create(config)
623
+ root_child0.setWidth(20)
624
+ root.insertChild(root_child0, 0)
625
+
626
+ const root_child1 = Yoga.Node.create(config)
627
+ root_child1.setWidth(20)
628
+ root.insertChild(root_child1, 1)
629
+
630
+ const root_child2 = Yoga.Node.create(config)
631
+ root_child2.setWidth(20)
632
+ root.insertChild(root_child2, 2)
633
+ root.calculateLayout(undefined, undefined, Direction.LTR)
634
+
635
+ expect(root.getComputedLeft()).toBe(0)
636
+ expect(root.getComputedTop()).toBe(0)
637
+ expect(root.getComputedWidth()).toBe(100)
638
+ expect(root.getComputedHeight()).toBe(100)
639
+
640
+ expect(root_child0.getComputedLeft()).toBe(0)
641
+ expect(root_child0.getComputedTop()).toBe(0)
642
+ expect(root_child0.getComputedWidth()).toBe(20)
643
+ expect(root_child0.getComputedHeight()).toBe(100)
644
+
645
+ expect(root_child1.getComputedLeft()).toBe(30)
646
+ expect(root_child1.getComputedTop()).toBe(0)
647
+ expect(root_child1.getComputedWidth()).toBe(20)
648
+ expect(root_child1.getComputedHeight()).toBe(100)
649
+
650
+ expect(root_child2.getComputedLeft()).toBe(60)
651
+ expect(root_child2.getComputedTop()).toBe(0)
652
+ expect(root_child2.getComputedWidth()).toBe(20)
653
+ expect(root_child2.getComputedHeight()).toBe(100)
654
+
655
+ root.calculateLayout(undefined, undefined, Direction.RTL)
656
+
657
+ expect(root.getComputedLeft()).toBe(0)
658
+ expect(root.getComputedTop()).toBe(0)
659
+ expect(root.getComputedWidth()).toBe(100)
660
+ expect(root.getComputedHeight()).toBe(100)
661
+
662
+ expect(root_child0.getComputedLeft()).toBe(80)
663
+ expect(root_child0.getComputedTop()).toBe(0)
664
+ expect(root_child0.getComputedWidth()).toBe(20)
665
+ expect(root_child0.getComputedHeight()).toBe(100)
666
+
667
+ expect(root_child1.getComputedLeft()).toBe(50)
668
+ expect(root_child1.getComputedTop()).toBe(0)
669
+ expect(root_child1.getComputedWidth()).toBe(20)
670
+ expect(root_child1.getComputedHeight()).toBe(100)
671
+
672
+ expect(root_child2.getComputedLeft()).toBe(20)
673
+ expect(root_child2.getComputedTop()).toBe(0)
674
+ expect(root_child2.getComputedWidth()).toBe(20)
675
+ expect(root_child2.getComputedHeight()).toBe(100)
676
+ } finally {
677
+ if (typeof root !== "undefined") {
678
+ root.freeRecursive()
679
+ }
680
+
681
+ config.free()
682
+ }
683
+ })
684
+ test("column_gap_justify_center", () => {
685
+ const config = Yoga.Config.create()
686
+ let root
687
+
688
+ try {
689
+ root = Yoga.Node.create(config)
690
+ root.setFlexDirection(FlexDirection.Row)
691
+ root.setJustifyContent(Justify.Center)
692
+ root.setPositionType(PositionType.Absolute)
693
+ root.setWidth(100)
694
+ root.setHeight(100)
695
+ root.setGap(Gutter.Column, 10)
696
+
697
+ const root_child0 = Yoga.Node.create(config)
698
+ root_child0.setWidth(20)
699
+ root.insertChild(root_child0, 0)
700
+
701
+ const root_child1 = Yoga.Node.create(config)
702
+ root_child1.setWidth(20)
703
+ root.insertChild(root_child1, 1)
704
+
705
+ const root_child2 = Yoga.Node.create(config)
706
+ root_child2.setWidth(20)
707
+ root.insertChild(root_child2, 2)
708
+ root.calculateLayout(undefined, undefined, Direction.LTR)
709
+
710
+ expect(root.getComputedLeft()).toBe(0)
711
+ expect(root.getComputedTop()).toBe(0)
712
+ expect(root.getComputedWidth()).toBe(100)
713
+ expect(root.getComputedHeight()).toBe(100)
714
+
715
+ expect(root_child0.getComputedLeft()).toBe(10)
716
+ expect(root_child0.getComputedTop()).toBe(0)
717
+ expect(root_child0.getComputedWidth()).toBe(20)
718
+ expect(root_child0.getComputedHeight()).toBe(100)
719
+
720
+ expect(root_child1.getComputedLeft()).toBe(40)
721
+ expect(root_child1.getComputedTop()).toBe(0)
722
+ expect(root_child1.getComputedWidth()).toBe(20)
723
+ expect(root_child1.getComputedHeight()).toBe(100)
724
+
725
+ expect(root_child2.getComputedLeft()).toBe(70)
726
+ expect(root_child2.getComputedTop()).toBe(0)
727
+ expect(root_child2.getComputedWidth()).toBe(20)
728
+ expect(root_child2.getComputedHeight()).toBe(100)
729
+
730
+ root.calculateLayout(undefined, undefined, Direction.RTL)
731
+
732
+ expect(root.getComputedLeft()).toBe(0)
733
+ expect(root.getComputedTop()).toBe(0)
734
+ expect(root.getComputedWidth()).toBe(100)
735
+ expect(root.getComputedHeight()).toBe(100)
736
+
737
+ expect(root_child0.getComputedLeft()).toBe(70)
738
+ expect(root_child0.getComputedTop()).toBe(0)
739
+ expect(root_child0.getComputedWidth()).toBe(20)
740
+ expect(root_child0.getComputedHeight()).toBe(100)
741
+
742
+ expect(root_child1.getComputedLeft()).toBe(40)
743
+ expect(root_child1.getComputedTop()).toBe(0)
744
+ expect(root_child1.getComputedWidth()).toBe(20)
745
+ expect(root_child1.getComputedHeight()).toBe(100)
746
+
747
+ expect(root_child2.getComputedLeft()).toBe(10)
748
+ expect(root_child2.getComputedTop()).toBe(0)
749
+ expect(root_child2.getComputedWidth()).toBe(20)
750
+ expect(root_child2.getComputedHeight()).toBe(100)
751
+ } finally {
752
+ if (typeof root !== "undefined") {
753
+ root.freeRecursive()
754
+ }
755
+
756
+ config.free()
757
+ }
758
+ })
759
+ test("column_gap_justify_flex_end", () => {
760
+ const config = Yoga.Config.create()
761
+ let root
762
+
763
+ try {
764
+ root = Yoga.Node.create(config)
765
+ root.setFlexDirection(FlexDirection.Row)
766
+ root.setJustifyContent(Justify.FlexEnd)
767
+ root.setPositionType(PositionType.Absolute)
768
+ root.setWidth(100)
769
+ root.setHeight(100)
770
+ root.setGap(Gutter.Column, 10)
771
+
772
+ const root_child0 = Yoga.Node.create(config)
773
+ root_child0.setWidth(20)
774
+ root.insertChild(root_child0, 0)
775
+
776
+ const root_child1 = Yoga.Node.create(config)
777
+ root_child1.setWidth(20)
778
+ root.insertChild(root_child1, 1)
779
+
780
+ const root_child2 = Yoga.Node.create(config)
781
+ root_child2.setWidth(20)
782
+ root.insertChild(root_child2, 2)
783
+ root.calculateLayout(undefined, undefined, Direction.LTR)
784
+
785
+ expect(root.getComputedLeft()).toBe(0)
786
+ expect(root.getComputedTop()).toBe(0)
787
+ expect(root.getComputedWidth()).toBe(100)
788
+ expect(root.getComputedHeight()).toBe(100)
789
+
790
+ expect(root_child0.getComputedLeft()).toBe(20)
791
+ expect(root_child0.getComputedTop()).toBe(0)
792
+ expect(root_child0.getComputedWidth()).toBe(20)
793
+ expect(root_child0.getComputedHeight()).toBe(100)
794
+
795
+ expect(root_child1.getComputedLeft()).toBe(50)
796
+ expect(root_child1.getComputedTop()).toBe(0)
797
+ expect(root_child1.getComputedWidth()).toBe(20)
798
+ expect(root_child1.getComputedHeight()).toBe(100)
799
+
800
+ expect(root_child2.getComputedLeft()).toBe(80)
801
+ expect(root_child2.getComputedTop()).toBe(0)
802
+ expect(root_child2.getComputedWidth()).toBe(20)
803
+ expect(root_child2.getComputedHeight()).toBe(100)
804
+
805
+ root.calculateLayout(undefined, undefined, Direction.RTL)
806
+
807
+ expect(root.getComputedLeft()).toBe(0)
808
+ expect(root.getComputedTop()).toBe(0)
809
+ expect(root.getComputedWidth()).toBe(100)
810
+ expect(root.getComputedHeight()).toBe(100)
811
+
812
+ expect(root_child0.getComputedLeft()).toBe(60)
813
+ expect(root_child0.getComputedTop()).toBe(0)
814
+ expect(root_child0.getComputedWidth()).toBe(20)
815
+ expect(root_child0.getComputedHeight()).toBe(100)
816
+
817
+ expect(root_child1.getComputedLeft()).toBe(30)
818
+ expect(root_child1.getComputedTop()).toBe(0)
819
+ expect(root_child1.getComputedWidth()).toBe(20)
820
+ expect(root_child1.getComputedHeight()).toBe(100)
821
+
822
+ expect(root_child2.getComputedLeft()).toBe(0)
823
+ expect(root_child2.getComputedTop()).toBe(0)
824
+ expect(root_child2.getComputedWidth()).toBe(20)
825
+ expect(root_child2.getComputedHeight()).toBe(100)
826
+ } finally {
827
+ if (typeof root !== "undefined") {
828
+ root.freeRecursive()
829
+ }
830
+
831
+ config.free()
832
+ }
833
+ })
834
+ test("column_gap_justify_space_between", () => {
835
+ const config = Yoga.Config.create()
836
+ let root
837
+
838
+ try {
839
+ root = Yoga.Node.create(config)
840
+ root.setFlexDirection(FlexDirection.Row)
841
+ root.setJustifyContent(Justify.SpaceBetween)
842
+ root.setPositionType(PositionType.Absolute)
843
+ root.setWidth(100)
844
+ root.setHeight(100)
845
+ root.setGap(Gutter.Column, 10)
846
+
847
+ const root_child0 = Yoga.Node.create(config)
848
+ root_child0.setWidth(20)
849
+ root.insertChild(root_child0, 0)
850
+
851
+ const root_child1 = Yoga.Node.create(config)
852
+ root_child1.setWidth(20)
853
+ root.insertChild(root_child1, 1)
854
+
855
+ const root_child2 = Yoga.Node.create(config)
856
+ root_child2.setWidth(20)
857
+ root.insertChild(root_child2, 2)
858
+ root.calculateLayout(undefined, undefined, Direction.LTR)
859
+
860
+ expect(root.getComputedLeft()).toBe(0)
861
+ expect(root.getComputedTop()).toBe(0)
862
+ expect(root.getComputedWidth()).toBe(100)
863
+ expect(root.getComputedHeight()).toBe(100)
864
+
865
+ expect(root_child0.getComputedLeft()).toBe(0)
866
+ expect(root_child0.getComputedTop()).toBe(0)
867
+ expect(root_child0.getComputedWidth()).toBe(20)
868
+ expect(root_child0.getComputedHeight()).toBe(100)
869
+
870
+ expect(root_child1.getComputedLeft()).toBe(40)
871
+ expect(root_child1.getComputedTop()).toBe(0)
872
+ expect(root_child1.getComputedWidth()).toBe(20)
873
+ expect(root_child1.getComputedHeight()).toBe(100)
874
+
875
+ expect(root_child2.getComputedLeft()).toBe(80)
876
+ expect(root_child2.getComputedTop()).toBe(0)
877
+ expect(root_child2.getComputedWidth()).toBe(20)
878
+ expect(root_child2.getComputedHeight()).toBe(100)
879
+
880
+ root.calculateLayout(undefined, undefined, Direction.RTL)
881
+
882
+ expect(root.getComputedLeft()).toBe(0)
883
+ expect(root.getComputedTop()).toBe(0)
884
+ expect(root.getComputedWidth()).toBe(100)
885
+ expect(root.getComputedHeight()).toBe(100)
886
+
887
+ expect(root_child0.getComputedLeft()).toBe(80)
888
+ expect(root_child0.getComputedTop()).toBe(0)
889
+ expect(root_child0.getComputedWidth()).toBe(20)
890
+ expect(root_child0.getComputedHeight()).toBe(100)
891
+
892
+ expect(root_child1.getComputedLeft()).toBe(40)
893
+ expect(root_child1.getComputedTop()).toBe(0)
894
+ expect(root_child1.getComputedWidth()).toBe(20)
895
+ expect(root_child1.getComputedHeight()).toBe(100)
896
+
897
+ expect(root_child2.getComputedLeft()).toBe(0)
898
+ expect(root_child2.getComputedTop()).toBe(0)
899
+ expect(root_child2.getComputedWidth()).toBe(20)
900
+ expect(root_child2.getComputedHeight()).toBe(100)
901
+ } finally {
902
+ if (typeof root !== "undefined") {
903
+ root.freeRecursive()
904
+ }
905
+
906
+ config.free()
907
+ }
908
+ })
909
+ test("column_gap_justify_space_around", () => {
910
+ const config = Yoga.Config.create()
911
+ let root
912
+
913
+ try {
914
+ root = Yoga.Node.create(config)
915
+ root.setFlexDirection(FlexDirection.Row)
916
+ root.setJustifyContent(Justify.SpaceAround)
917
+ root.setPositionType(PositionType.Absolute)
918
+ root.setWidth(100)
919
+ root.setHeight(100)
920
+ root.setGap(Gutter.Column, 10)
921
+
922
+ const root_child0 = Yoga.Node.create(config)
923
+ root_child0.setWidth(20)
924
+ root.insertChild(root_child0, 0)
925
+
926
+ const root_child1 = Yoga.Node.create(config)
927
+ root_child1.setWidth(20)
928
+ root.insertChild(root_child1, 1)
929
+
930
+ const root_child2 = Yoga.Node.create(config)
931
+ root_child2.setWidth(20)
932
+ root.insertChild(root_child2, 2)
933
+ root.calculateLayout(undefined, undefined, Direction.LTR)
934
+
935
+ expect(root.getComputedLeft()).toBe(0)
936
+ expect(root.getComputedTop()).toBe(0)
937
+ expect(root.getComputedWidth()).toBe(100)
938
+ expect(root.getComputedHeight()).toBe(100)
939
+
940
+ expect(root_child0.getComputedLeft()).toBe(3)
941
+ expect(root_child0.getComputedTop()).toBe(0)
942
+ expect(root_child0.getComputedWidth()).toBe(20)
943
+ expect(root_child0.getComputedHeight()).toBe(100)
944
+
945
+ expect(root_child1.getComputedLeft()).toBe(40)
946
+ expect(root_child1.getComputedTop()).toBe(0)
947
+ expect(root_child1.getComputedWidth()).toBe(20)
948
+ expect(root_child1.getComputedHeight()).toBe(100)
949
+
950
+ expect(root_child2.getComputedLeft()).toBe(77)
951
+ expect(root_child2.getComputedTop()).toBe(0)
952
+ expect(root_child2.getComputedWidth()).toBe(20)
953
+ expect(root_child2.getComputedHeight()).toBe(100)
954
+
955
+ root.calculateLayout(undefined, undefined, Direction.RTL)
956
+
957
+ expect(root.getComputedLeft()).toBe(0)
958
+ expect(root.getComputedTop()).toBe(0)
959
+ expect(root.getComputedWidth()).toBe(100)
960
+ expect(root.getComputedHeight()).toBe(100)
961
+
962
+ expect(root_child0.getComputedLeft()).toBe(77)
963
+ expect(root_child0.getComputedTop()).toBe(0)
964
+ expect(root_child0.getComputedWidth()).toBe(20)
965
+ expect(root_child0.getComputedHeight()).toBe(100)
966
+
967
+ expect(root_child1.getComputedLeft()).toBe(40)
968
+ expect(root_child1.getComputedTop()).toBe(0)
969
+ expect(root_child1.getComputedWidth()).toBe(20)
970
+ expect(root_child1.getComputedHeight()).toBe(100)
971
+
972
+ expect(root_child2.getComputedLeft()).toBe(3)
973
+ expect(root_child2.getComputedTop()).toBe(0)
974
+ expect(root_child2.getComputedWidth()).toBe(20)
975
+ expect(root_child2.getComputedHeight()).toBe(100)
976
+ } finally {
977
+ if (typeof root !== "undefined") {
978
+ root.freeRecursive()
979
+ }
980
+
981
+ config.free()
982
+ }
983
+ })
984
+ test("column_gap_justify_space_evenly", () => {
985
+ const config = Yoga.Config.create()
986
+ let root
987
+
988
+ try {
989
+ root = Yoga.Node.create(config)
990
+ root.setFlexDirection(FlexDirection.Row)
991
+ root.setJustifyContent(Justify.SpaceEvenly)
992
+ root.setPositionType(PositionType.Absolute)
993
+ root.setWidth(100)
994
+ root.setHeight(100)
995
+ root.setGap(Gutter.Column, 10)
996
+
997
+ const root_child0 = Yoga.Node.create(config)
998
+ root_child0.setWidth(20)
999
+ root.insertChild(root_child0, 0)
1000
+
1001
+ const root_child1 = Yoga.Node.create(config)
1002
+ root_child1.setWidth(20)
1003
+ root.insertChild(root_child1, 1)
1004
+
1005
+ const root_child2 = Yoga.Node.create(config)
1006
+ root_child2.setWidth(20)
1007
+ root.insertChild(root_child2, 2)
1008
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1009
+
1010
+ expect(root.getComputedLeft()).toBe(0)
1011
+ expect(root.getComputedTop()).toBe(0)
1012
+ expect(root.getComputedWidth()).toBe(100)
1013
+ expect(root.getComputedHeight()).toBe(100)
1014
+
1015
+ expect(root_child0.getComputedLeft()).toBe(5)
1016
+ expect(root_child0.getComputedTop()).toBe(0)
1017
+ expect(root_child0.getComputedWidth()).toBe(20)
1018
+ expect(root_child0.getComputedHeight()).toBe(100)
1019
+
1020
+ expect(root_child1.getComputedLeft()).toBe(40)
1021
+ expect(root_child1.getComputedTop()).toBe(0)
1022
+ expect(root_child1.getComputedWidth()).toBe(20)
1023
+ expect(root_child1.getComputedHeight()).toBe(100)
1024
+
1025
+ expect(root_child2.getComputedLeft()).toBe(75)
1026
+ expect(root_child2.getComputedTop()).toBe(0)
1027
+ expect(root_child2.getComputedWidth()).toBe(20)
1028
+ expect(root_child2.getComputedHeight()).toBe(100)
1029
+
1030
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1031
+
1032
+ expect(root.getComputedLeft()).toBe(0)
1033
+ expect(root.getComputedTop()).toBe(0)
1034
+ expect(root.getComputedWidth()).toBe(100)
1035
+ expect(root.getComputedHeight()).toBe(100)
1036
+
1037
+ expect(root_child0.getComputedLeft()).toBe(75)
1038
+ expect(root_child0.getComputedTop()).toBe(0)
1039
+ expect(root_child0.getComputedWidth()).toBe(20)
1040
+ expect(root_child0.getComputedHeight()).toBe(100)
1041
+
1042
+ expect(root_child1.getComputedLeft()).toBe(40)
1043
+ expect(root_child1.getComputedTop()).toBe(0)
1044
+ expect(root_child1.getComputedWidth()).toBe(20)
1045
+ expect(root_child1.getComputedHeight()).toBe(100)
1046
+
1047
+ expect(root_child2.getComputedLeft()).toBe(5)
1048
+ expect(root_child2.getComputedTop()).toBe(0)
1049
+ expect(root_child2.getComputedWidth()).toBe(20)
1050
+ expect(root_child2.getComputedHeight()).toBe(100)
1051
+ } finally {
1052
+ if (typeof root !== "undefined") {
1053
+ root.freeRecursive()
1054
+ }
1055
+
1056
+ config.free()
1057
+ }
1058
+ })
1059
+ test("column_gap_wrap_align_flex_start", () => {
1060
+ const config = Yoga.Config.create()
1061
+ let root
1062
+
1063
+ try {
1064
+ root = Yoga.Node.create(config)
1065
+ root.setFlexDirection(FlexDirection.Row)
1066
+ root.setPositionType(PositionType.Absolute)
1067
+ root.setFlexWrap(Wrap.Wrap)
1068
+ root.setWidth(100)
1069
+ root.setHeight(100)
1070
+ root.setGap(Gutter.Column, 10)
1071
+ root.setGap(Gutter.Row, 20)
1072
+
1073
+ const root_child0 = Yoga.Node.create(config)
1074
+ root_child0.setWidth(20)
1075
+ root_child0.setHeight(20)
1076
+ root.insertChild(root_child0, 0)
1077
+
1078
+ const root_child1 = Yoga.Node.create(config)
1079
+ root_child1.setWidth(20)
1080
+ root_child1.setHeight(20)
1081
+ root.insertChild(root_child1, 1)
1082
+
1083
+ const root_child2 = Yoga.Node.create(config)
1084
+ root_child2.setWidth(20)
1085
+ root_child2.setHeight(20)
1086
+ root.insertChild(root_child2, 2)
1087
+
1088
+ const root_child3 = Yoga.Node.create(config)
1089
+ root_child3.setWidth(20)
1090
+ root_child3.setHeight(20)
1091
+ root.insertChild(root_child3, 3)
1092
+
1093
+ const root_child4 = Yoga.Node.create(config)
1094
+ root_child4.setWidth(20)
1095
+ root_child4.setHeight(20)
1096
+ root.insertChild(root_child4, 4)
1097
+
1098
+ const root_child5 = Yoga.Node.create(config)
1099
+ root_child5.setWidth(20)
1100
+ root_child5.setHeight(20)
1101
+ root.insertChild(root_child5, 5)
1102
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1103
+
1104
+ expect(root.getComputedLeft()).toBe(0)
1105
+ expect(root.getComputedTop()).toBe(0)
1106
+ expect(root.getComputedWidth()).toBe(100)
1107
+ expect(root.getComputedHeight()).toBe(100)
1108
+
1109
+ expect(root_child0.getComputedLeft()).toBe(0)
1110
+ expect(root_child0.getComputedTop()).toBe(0)
1111
+ expect(root_child0.getComputedWidth()).toBe(20)
1112
+ expect(root_child0.getComputedHeight()).toBe(20)
1113
+
1114
+ expect(root_child1.getComputedLeft()).toBe(30)
1115
+ expect(root_child1.getComputedTop()).toBe(0)
1116
+ expect(root_child1.getComputedWidth()).toBe(20)
1117
+ expect(root_child1.getComputedHeight()).toBe(20)
1118
+
1119
+ expect(root_child2.getComputedLeft()).toBe(60)
1120
+ expect(root_child2.getComputedTop()).toBe(0)
1121
+ expect(root_child2.getComputedWidth()).toBe(20)
1122
+ expect(root_child2.getComputedHeight()).toBe(20)
1123
+
1124
+ expect(root_child3.getComputedLeft()).toBe(0)
1125
+ expect(root_child3.getComputedTop()).toBe(40)
1126
+ expect(root_child3.getComputedWidth()).toBe(20)
1127
+ expect(root_child3.getComputedHeight()).toBe(20)
1128
+
1129
+ expect(root_child4.getComputedLeft()).toBe(30)
1130
+ expect(root_child4.getComputedTop()).toBe(40)
1131
+ expect(root_child4.getComputedWidth()).toBe(20)
1132
+ expect(root_child4.getComputedHeight()).toBe(20)
1133
+
1134
+ expect(root_child5.getComputedLeft()).toBe(60)
1135
+ expect(root_child5.getComputedTop()).toBe(40)
1136
+ expect(root_child5.getComputedWidth()).toBe(20)
1137
+ expect(root_child5.getComputedHeight()).toBe(20)
1138
+
1139
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1140
+
1141
+ expect(root.getComputedLeft()).toBe(0)
1142
+ expect(root.getComputedTop()).toBe(0)
1143
+ expect(root.getComputedWidth()).toBe(100)
1144
+ expect(root.getComputedHeight()).toBe(100)
1145
+
1146
+ expect(root_child0.getComputedLeft()).toBe(80)
1147
+ expect(root_child0.getComputedTop()).toBe(0)
1148
+ expect(root_child0.getComputedWidth()).toBe(20)
1149
+ expect(root_child0.getComputedHeight()).toBe(20)
1150
+
1151
+ expect(root_child1.getComputedLeft()).toBe(50)
1152
+ expect(root_child1.getComputedTop()).toBe(0)
1153
+ expect(root_child1.getComputedWidth()).toBe(20)
1154
+ expect(root_child1.getComputedHeight()).toBe(20)
1155
+
1156
+ expect(root_child2.getComputedLeft()).toBe(20)
1157
+ expect(root_child2.getComputedTop()).toBe(0)
1158
+ expect(root_child2.getComputedWidth()).toBe(20)
1159
+ expect(root_child2.getComputedHeight()).toBe(20)
1160
+
1161
+ expect(root_child3.getComputedLeft()).toBe(80)
1162
+ expect(root_child3.getComputedTop()).toBe(40)
1163
+ expect(root_child3.getComputedWidth()).toBe(20)
1164
+ expect(root_child3.getComputedHeight()).toBe(20)
1165
+
1166
+ expect(root_child4.getComputedLeft()).toBe(50)
1167
+ expect(root_child4.getComputedTop()).toBe(40)
1168
+ expect(root_child4.getComputedWidth()).toBe(20)
1169
+ expect(root_child4.getComputedHeight()).toBe(20)
1170
+
1171
+ expect(root_child5.getComputedLeft()).toBe(20)
1172
+ expect(root_child5.getComputedTop()).toBe(40)
1173
+ expect(root_child5.getComputedWidth()).toBe(20)
1174
+ expect(root_child5.getComputedHeight()).toBe(20)
1175
+ } finally {
1176
+ if (typeof root !== "undefined") {
1177
+ root.freeRecursive()
1178
+ }
1179
+
1180
+ config.free()
1181
+ }
1182
+ })
1183
+ test("column_gap_wrap_align_center", () => {
1184
+ const config = Yoga.Config.create()
1185
+ let root
1186
+
1187
+ try {
1188
+ root = Yoga.Node.create(config)
1189
+ root.setFlexDirection(FlexDirection.Row)
1190
+ root.setAlignContent(Align.Center)
1191
+ root.setPositionType(PositionType.Absolute)
1192
+ root.setFlexWrap(Wrap.Wrap)
1193
+ root.setWidth(100)
1194
+ root.setHeight(100)
1195
+ root.setGap(Gutter.Column, 10)
1196
+ root.setGap(Gutter.Row, 20)
1197
+
1198
+ const root_child0 = Yoga.Node.create(config)
1199
+ root_child0.setWidth(20)
1200
+ root_child0.setHeight(20)
1201
+ root.insertChild(root_child0, 0)
1202
+
1203
+ const root_child1 = Yoga.Node.create(config)
1204
+ root_child1.setWidth(20)
1205
+ root_child1.setHeight(20)
1206
+ root.insertChild(root_child1, 1)
1207
+
1208
+ const root_child2 = Yoga.Node.create(config)
1209
+ root_child2.setWidth(20)
1210
+ root_child2.setHeight(20)
1211
+ root.insertChild(root_child2, 2)
1212
+
1213
+ const root_child3 = Yoga.Node.create(config)
1214
+ root_child3.setWidth(20)
1215
+ root_child3.setHeight(20)
1216
+ root.insertChild(root_child3, 3)
1217
+
1218
+ const root_child4 = Yoga.Node.create(config)
1219
+ root_child4.setWidth(20)
1220
+ root_child4.setHeight(20)
1221
+ root.insertChild(root_child4, 4)
1222
+
1223
+ const root_child5 = Yoga.Node.create(config)
1224
+ root_child5.setWidth(20)
1225
+ root_child5.setHeight(20)
1226
+ root.insertChild(root_child5, 5)
1227
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1228
+
1229
+ expect(root.getComputedLeft()).toBe(0)
1230
+ expect(root.getComputedTop()).toBe(0)
1231
+ expect(root.getComputedWidth()).toBe(100)
1232
+ expect(root.getComputedHeight()).toBe(100)
1233
+
1234
+ expect(root_child0.getComputedLeft()).toBe(0)
1235
+ expect(root_child0.getComputedTop()).toBe(20)
1236
+ expect(root_child0.getComputedWidth()).toBe(20)
1237
+ expect(root_child0.getComputedHeight()).toBe(20)
1238
+
1239
+ expect(root_child1.getComputedLeft()).toBe(30)
1240
+ expect(root_child1.getComputedTop()).toBe(20)
1241
+ expect(root_child1.getComputedWidth()).toBe(20)
1242
+ expect(root_child1.getComputedHeight()).toBe(20)
1243
+
1244
+ expect(root_child2.getComputedLeft()).toBe(60)
1245
+ expect(root_child2.getComputedTop()).toBe(20)
1246
+ expect(root_child2.getComputedWidth()).toBe(20)
1247
+ expect(root_child2.getComputedHeight()).toBe(20)
1248
+
1249
+ expect(root_child3.getComputedLeft()).toBe(0)
1250
+ expect(root_child3.getComputedTop()).toBe(60)
1251
+ expect(root_child3.getComputedWidth()).toBe(20)
1252
+ expect(root_child3.getComputedHeight()).toBe(20)
1253
+
1254
+ expect(root_child4.getComputedLeft()).toBe(30)
1255
+ expect(root_child4.getComputedTop()).toBe(60)
1256
+ expect(root_child4.getComputedWidth()).toBe(20)
1257
+ expect(root_child4.getComputedHeight()).toBe(20)
1258
+
1259
+ expect(root_child5.getComputedLeft()).toBe(60)
1260
+ expect(root_child5.getComputedTop()).toBe(60)
1261
+ expect(root_child5.getComputedWidth()).toBe(20)
1262
+ expect(root_child5.getComputedHeight()).toBe(20)
1263
+
1264
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1265
+
1266
+ expect(root.getComputedLeft()).toBe(0)
1267
+ expect(root.getComputedTop()).toBe(0)
1268
+ expect(root.getComputedWidth()).toBe(100)
1269
+ expect(root.getComputedHeight()).toBe(100)
1270
+
1271
+ expect(root_child0.getComputedLeft()).toBe(80)
1272
+ expect(root_child0.getComputedTop()).toBe(20)
1273
+ expect(root_child0.getComputedWidth()).toBe(20)
1274
+ expect(root_child0.getComputedHeight()).toBe(20)
1275
+
1276
+ expect(root_child1.getComputedLeft()).toBe(50)
1277
+ expect(root_child1.getComputedTop()).toBe(20)
1278
+ expect(root_child1.getComputedWidth()).toBe(20)
1279
+ expect(root_child1.getComputedHeight()).toBe(20)
1280
+
1281
+ expect(root_child2.getComputedLeft()).toBe(20)
1282
+ expect(root_child2.getComputedTop()).toBe(20)
1283
+ expect(root_child2.getComputedWidth()).toBe(20)
1284
+ expect(root_child2.getComputedHeight()).toBe(20)
1285
+
1286
+ expect(root_child3.getComputedLeft()).toBe(80)
1287
+ expect(root_child3.getComputedTop()).toBe(60)
1288
+ expect(root_child3.getComputedWidth()).toBe(20)
1289
+ expect(root_child3.getComputedHeight()).toBe(20)
1290
+
1291
+ expect(root_child4.getComputedLeft()).toBe(50)
1292
+ expect(root_child4.getComputedTop()).toBe(60)
1293
+ expect(root_child4.getComputedWidth()).toBe(20)
1294
+ expect(root_child4.getComputedHeight()).toBe(20)
1295
+
1296
+ expect(root_child5.getComputedLeft()).toBe(20)
1297
+ expect(root_child5.getComputedTop()).toBe(60)
1298
+ expect(root_child5.getComputedWidth()).toBe(20)
1299
+ expect(root_child5.getComputedHeight()).toBe(20)
1300
+ } finally {
1301
+ if (typeof root !== "undefined") {
1302
+ root.freeRecursive()
1303
+ }
1304
+
1305
+ config.free()
1306
+ }
1307
+ })
1308
+ test("column_gap_wrap_align_flex_end", () => {
1309
+ const config = Yoga.Config.create()
1310
+ let root
1311
+
1312
+ try {
1313
+ root = Yoga.Node.create(config)
1314
+ root.setFlexDirection(FlexDirection.Row)
1315
+ root.setAlignContent(Align.FlexEnd)
1316
+ root.setPositionType(PositionType.Absolute)
1317
+ root.setFlexWrap(Wrap.Wrap)
1318
+ root.setWidth(100)
1319
+ root.setHeight(100)
1320
+ root.setGap(Gutter.Column, 10)
1321
+ root.setGap(Gutter.Row, 20)
1322
+
1323
+ const root_child0 = Yoga.Node.create(config)
1324
+ root_child0.setWidth(20)
1325
+ root_child0.setHeight(20)
1326
+ root.insertChild(root_child0, 0)
1327
+
1328
+ const root_child1 = Yoga.Node.create(config)
1329
+ root_child1.setWidth(20)
1330
+ root_child1.setHeight(20)
1331
+ root.insertChild(root_child1, 1)
1332
+
1333
+ const root_child2 = Yoga.Node.create(config)
1334
+ root_child2.setWidth(20)
1335
+ root_child2.setHeight(20)
1336
+ root.insertChild(root_child2, 2)
1337
+
1338
+ const root_child3 = Yoga.Node.create(config)
1339
+ root_child3.setWidth(20)
1340
+ root_child3.setHeight(20)
1341
+ root.insertChild(root_child3, 3)
1342
+
1343
+ const root_child4 = Yoga.Node.create(config)
1344
+ root_child4.setWidth(20)
1345
+ root_child4.setHeight(20)
1346
+ root.insertChild(root_child4, 4)
1347
+
1348
+ const root_child5 = Yoga.Node.create(config)
1349
+ root_child5.setWidth(20)
1350
+ root_child5.setHeight(20)
1351
+ root.insertChild(root_child5, 5)
1352
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1353
+
1354
+ expect(root.getComputedLeft()).toBe(0)
1355
+ expect(root.getComputedTop()).toBe(0)
1356
+ expect(root.getComputedWidth()).toBe(100)
1357
+ expect(root.getComputedHeight()).toBe(100)
1358
+
1359
+ expect(root_child0.getComputedLeft()).toBe(0)
1360
+ expect(root_child0.getComputedTop()).toBe(40)
1361
+ expect(root_child0.getComputedWidth()).toBe(20)
1362
+ expect(root_child0.getComputedHeight()).toBe(20)
1363
+
1364
+ expect(root_child1.getComputedLeft()).toBe(30)
1365
+ expect(root_child1.getComputedTop()).toBe(40)
1366
+ expect(root_child1.getComputedWidth()).toBe(20)
1367
+ expect(root_child1.getComputedHeight()).toBe(20)
1368
+
1369
+ expect(root_child2.getComputedLeft()).toBe(60)
1370
+ expect(root_child2.getComputedTop()).toBe(40)
1371
+ expect(root_child2.getComputedWidth()).toBe(20)
1372
+ expect(root_child2.getComputedHeight()).toBe(20)
1373
+
1374
+ expect(root_child3.getComputedLeft()).toBe(0)
1375
+ expect(root_child3.getComputedTop()).toBe(80)
1376
+ expect(root_child3.getComputedWidth()).toBe(20)
1377
+ expect(root_child3.getComputedHeight()).toBe(20)
1378
+
1379
+ expect(root_child4.getComputedLeft()).toBe(30)
1380
+ expect(root_child4.getComputedTop()).toBe(80)
1381
+ expect(root_child4.getComputedWidth()).toBe(20)
1382
+ expect(root_child4.getComputedHeight()).toBe(20)
1383
+
1384
+ expect(root_child5.getComputedLeft()).toBe(60)
1385
+ expect(root_child5.getComputedTop()).toBe(80)
1386
+ expect(root_child5.getComputedWidth()).toBe(20)
1387
+ expect(root_child5.getComputedHeight()).toBe(20)
1388
+
1389
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1390
+
1391
+ expect(root.getComputedLeft()).toBe(0)
1392
+ expect(root.getComputedTop()).toBe(0)
1393
+ expect(root.getComputedWidth()).toBe(100)
1394
+ expect(root.getComputedHeight()).toBe(100)
1395
+
1396
+ expect(root_child0.getComputedLeft()).toBe(80)
1397
+ expect(root_child0.getComputedTop()).toBe(40)
1398
+ expect(root_child0.getComputedWidth()).toBe(20)
1399
+ expect(root_child0.getComputedHeight()).toBe(20)
1400
+
1401
+ expect(root_child1.getComputedLeft()).toBe(50)
1402
+ expect(root_child1.getComputedTop()).toBe(40)
1403
+ expect(root_child1.getComputedWidth()).toBe(20)
1404
+ expect(root_child1.getComputedHeight()).toBe(20)
1405
+
1406
+ expect(root_child2.getComputedLeft()).toBe(20)
1407
+ expect(root_child2.getComputedTop()).toBe(40)
1408
+ expect(root_child2.getComputedWidth()).toBe(20)
1409
+ expect(root_child2.getComputedHeight()).toBe(20)
1410
+
1411
+ expect(root_child3.getComputedLeft()).toBe(80)
1412
+ expect(root_child3.getComputedTop()).toBe(80)
1413
+ expect(root_child3.getComputedWidth()).toBe(20)
1414
+ expect(root_child3.getComputedHeight()).toBe(20)
1415
+
1416
+ expect(root_child4.getComputedLeft()).toBe(50)
1417
+ expect(root_child4.getComputedTop()).toBe(80)
1418
+ expect(root_child4.getComputedWidth()).toBe(20)
1419
+ expect(root_child4.getComputedHeight()).toBe(20)
1420
+
1421
+ expect(root_child5.getComputedLeft()).toBe(20)
1422
+ expect(root_child5.getComputedTop()).toBe(80)
1423
+ expect(root_child5.getComputedWidth()).toBe(20)
1424
+ expect(root_child5.getComputedHeight()).toBe(20)
1425
+ } finally {
1426
+ if (typeof root !== "undefined") {
1427
+ root.freeRecursive()
1428
+ }
1429
+
1430
+ config.free()
1431
+ }
1432
+ })
1433
+ test("column_gap_wrap_align_space_between", () => {
1434
+ const config = Yoga.Config.create()
1435
+ let root
1436
+
1437
+ try {
1438
+ root = Yoga.Node.create(config)
1439
+ root.setFlexDirection(FlexDirection.Row)
1440
+ root.setAlignContent(Align.SpaceBetween)
1441
+ root.setPositionType(PositionType.Absolute)
1442
+ root.setFlexWrap(Wrap.Wrap)
1443
+ root.setWidth(100)
1444
+ root.setHeight(100)
1445
+ root.setGap(Gutter.Column, 10)
1446
+ root.setGap(Gutter.Row, 20)
1447
+
1448
+ const root_child0 = Yoga.Node.create(config)
1449
+ root_child0.setWidth(20)
1450
+ root_child0.setHeight(20)
1451
+ root.insertChild(root_child0, 0)
1452
+
1453
+ const root_child1 = Yoga.Node.create(config)
1454
+ root_child1.setWidth(20)
1455
+ root_child1.setHeight(20)
1456
+ root.insertChild(root_child1, 1)
1457
+
1458
+ const root_child2 = Yoga.Node.create(config)
1459
+ root_child2.setWidth(20)
1460
+ root_child2.setHeight(20)
1461
+ root.insertChild(root_child2, 2)
1462
+
1463
+ const root_child3 = Yoga.Node.create(config)
1464
+ root_child3.setWidth(20)
1465
+ root_child3.setHeight(20)
1466
+ root.insertChild(root_child3, 3)
1467
+
1468
+ const root_child4 = Yoga.Node.create(config)
1469
+ root_child4.setWidth(20)
1470
+ root_child4.setHeight(20)
1471
+ root.insertChild(root_child4, 4)
1472
+
1473
+ const root_child5 = Yoga.Node.create(config)
1474
+ root_child5.setWidth(20)
1475
+ root_child5.setHeight(20)
1476
+ root.insertChild(root_child5, 5)
1477
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1478
+
1479
+ expect(root.getComputedLeft()).toBe(0)
1480
+ expect(root.getComputedTop()).toBe(0)
1481
+ expect(root.getComputedWidth()).toBe(100)
1482
+ expect(root.getComputedHeight()).toBe(100)
1483
+
1484
+ expect(root_child0.getComputedLeft()).toBe(0)
1485
+ expect(root_child0.getComputedTop()).toBe(0)
1486
+ expect(root_child0.getComputedWidth()).toBe(20)
1487
+ expect(root_child0.getComputedHeight()).toBe(20)
1488
+
1489
+ expect(root_child1.getComputedLeft()).toBe(30)
1490
+ expect(root_child1.getComputedTop()).toBe(0)
1491
+ expect(root_child1.getComputedWidth()).toBe(20)
1492
+ expect(root_child1.getComputedHeight()).toBe(20)
1493
+
1494
+ expect(root_child2.getComputedLeft()).toBe(60)
1495
+ expect(root_child2.getComputedTop()).toBe(0)
1496
+ expect(root_child2.getComputedWidth()).toBe(20)
1497
+ expect(root_child2.getComputedHeight()).toBe(20)
1498
+
1499
+ expect(root_child3.getComputedLeft()).toBe(0)
1500
+ expect(root_child3.getComputedTop()).toBe(80)
1501
+ expect(root_child3.getComputedWidth()).toBe(20)
1502
+ expect(root_child3.getComputedHeight()).toBe(20)
1503
+
1504
+ expect(root_child4.getComputedLeft()).toBe(30)
1505
+ expect(root_child4.getComputedTop()).toBe(80)
1506
+ expect(root_child4.getComputedWidth()).toBe(20)
1507
+ expect(root_child4.getComputedHeight()).toBe(20)
1508
+
1509
+ expect(root_child5.getComputedLeft()).toBe(60)
1510
+ expect(root_child5.getComputedTop()).toBe(80)
1511
+ expect(root_child5.getComputedWidth()).toBe(20)
1512
+ expect(root_child5.getComputedHeight()).toBe(20)
1513
+
1514
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1515
+
1516
+ expect(root.getComputedLeft()).toBe(0)
1517
+ expect(root.getComputedTop()).toBe(0)
1518
+ expect(root.getComputedWidth()).toBe(100)
1519
+ expect(root.getComputedHeight()).toBe(100)
1520
+
1521
+ expect(root_child0.getComputedLeft()).toBe(80)
1522
+ expect(root_child0.getComputedTop()).toBe(0)
1523
+ expect(root_child0.getComputedWidth()).toBe(20)
1524
+ expect(root_child0.getComputedHeight()).toBe(20)
1525
+
1526
+ expect(root_child1.getComputedLeft()).toBe(50)
1527
+ expect(root_child1.getComputedTop()).toBe(0)
1528
+ expect(root_child1.getComputedWidth()).toBe(20)
1529
+ expect(root_child1.getComputedHeight()).toBe(20)
1530
+
1531
+ expect(root_child2.getComputedLeft()).toBe(20)
1532
+ expect(root_child2.getComputedTop()).toBe(0)
1533
+ expect(root_child2.getComputedWidth()).toBe(20)
1534
+ expect(root_child2.getComputedHeight()).toBe(20)
1535
+
1536
+ expect(root_child3.getComputedLeft()).toBe(80)
1537
+ expect(root_child3.getComputedTop()).toBe(80)
1538
+ expect(root_child3.getComputedWidth()).toBe(20)
1539
+ expect(root_child3.getComputedHeight()).toBe(20)
1540
+
1541
+ expect(root_child4.getComputedLeft()).toBe(50)
1542
+ expect(root_child4.getComputedTop()).toBe(80)
1543
+ expect(root_child4.getComputedWidth()).toBe(20)
1544
+ expect(root_child4.getComputedHeight()).toBe(20)
1545
+
1546
+ expect(root_child5.getComputedLeft()).toBe(20)
1547
+ expect(root_child5.getComputedTop()).toBe(80)
1548
+ expect(root_child5.getComputedWidth()).toBe(20)
1549
+ expect(root_child5.getComputedHeight()).toBe(20)
1550
+ } finally {
1551
+ if (typeof root !== "undefined") {
1552
+ root.freeRecursive()
1553
+ }
1554
+
1555
+ config.free()
1556
+ }
1557
+ })
1558
+ test("column_gap_wrap_align_space_around", () => {
1559
+ const config = Yoga.Config.create()
1560
+ let root
1561
+
1562
+ try {
1563
+ root = Yoga.Node.create(config)
1564
+ root.setFlexDirection(FlexDirection.Row)
1565
+ root.setAlignContent(Align.SpaceAround)
1566
+ root.setPositionType(PositionType.Absolute)
1567
+ root.setFlexWrap(Wrap.Wrap)
1568
+ root.setWidth(100)
1569
+ root.setHeight(100)
1570
+ root.setGap(Gutter.Column, 10)
1571
+ root.setGap(Gutter.Row, 20)
1572
+
1573
+ const root_child0 = Yoga.Node.create(config)
1574
+ root_child0.setWidth(20)
1575
+ root_child0.setHeight(20)
1576
+ root.insertChild(root_child0, 0)
1577
+
1578
+ const root_child1 = Yoga.Node.create(config)
1579
+ root_child1.setWidth(20)
1580
+ root_child1.setHeight(20)
1581
+ root.insertChild(root_child1, 1)
1582
+
1583
+ const root_child2 = Yoga.Node.create(config)
1584
+ root_child2.setWidth(20)
1585
+ root_child2.setHeight(20)
1586
+ root.insertChild(root_child2, 2)
1587
+
1588
+ const root_child3 = Yoga.Node.create(config)
1589
+ root_child3.setWidth(20)
1590
+ root_child3.setHeight(20)
1591
+ root.insertChild(root_child3, 3)
1592
+
1593
+ const root_child4 = Yoga.Node.create(config)
1594
+ root_child4.setWidth(20)
1595
+ root_child4.setHeight(20)
1596
+ root.insertChild(root_child4, 4)
1597
+
1598
+ const root_child5 = Yoga.Node.create(config)
1599
+ root_child5.setWidth(20)
1600
+ root_child5.setHeight(20)
1601
+ root.insertChild(root_child5, 5)
1602
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1603
+
1604
+ expect(root.getComputedLeft()).toBe(0)
1605
+ expect(root.getComputedTop()).toBe(0)
1606
+ expect(root.getComputedWidth()).toBe(100)
1607
+ expect(root.getComputedHeight()).toBe(100)
1608
+
1609
+ expect(root_child0.getComputedLeft()).toBe(0)
1610
+ expect(root_child0.getComputedTop()).toBe(10)
1611
+ expect(root_child0.getComputedWidth()).toBe(20)
1612
+ expect(root_child0.getComputedHeight()).toBe(20)
1613
+
1614
+ expect(root_child1.getComputedLeft()).toBe(30)
1615
+ expect(root_child1.getComputedTop()).toBe(10)
1616
+ expect(root_child1.getComputedWidth()).toBe(20)
1617
+ expect(root_child1.getComputedHeight()).toBe(20)
1618
+
1619
+ expect(root_child2.getComputedLeft()).toBe(60)
1620
+ expect(root_child2.getComputedTop()).toBe(10)
1621
+ expect(root_child2.getComputedWidth()).toBe(20)
1622
+ expect(root_child2.getComputedHeight()).toBe(20)
1623
+
1624
+ expect(root_child3.getComputedLeft()).toBe(0)
1625
+ expect(root_child3.getComputedTop()).toBe(70)
1626
+ expect(root_child3.getComputedWidth()).toBe(20)
1627
+ expect(root_child3.getComputedHeight()).toBe(20)
1628
+
1629
+ expect(root_child4.getComputedLeft()).toBe(30)
1630
+ expect(root_child4.getComputedTop()).toBe(70)
1631
+ expect(root_child4.getComputedWidth()).toBe(20)
1632
+ expect(root_child4.getComputedHeight()).toBe(20)
1633
+
1634
+ expect(root_child5.getComputedLeft()).toBe(60)
1635
+ expect(root_child5.getComputedTop()).toBe(70)
1636
+ expect(root_child5.getComputedWidth()).toBe(20)
1637
+ expect(root_child5.getComputedHeight()).toBe(20)
1638
+
1639
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1640
+
1641
+ expect(root.getComputedLeft()).toBe(0)
1642
+ expect(root.getComputedTop()).toBe(0)
1643
+ expect(root.getComputedWidth()).toBe(100)
1644
+ expect(root.getComputedHeight()).toBe(100)
1645
+
1646
+ expect(root_child0.getComputedLeft()).toBe(80)
1647
+ expect(root_child0.getComputedTop()).toBe(10)
1648
+ expect(root_child0.getComputedWidth()).toBe(20)
1649
+ expect(root_child0.getComputedHeight()).toBe(20)
1650
+
1651
+ expect(root_child1.getComputedLeft()).toBe(50)
1652
+ expect(root_child1.getComputedTop()).toBe(10)
1653
+ expect(root_child1.getComputedWidth()).toBe(20)
1654
+ expect(root_child1.getComputedHeight()).toBe(20)
1655
+
1656
+ expect(root_child2.getComputedLeft()).toBe(20)
1657
+ expect(root_child2.getComputedTop()).toBe(10)
1658
+ expect(root_child2.getComputedWidth()).toBe(20)
1659
+ expect(root_child2.getComputedHeight()).toBe(20)
1660
+
1661
+ expect(root_child3.getComputedLeft()).toBe(80)
1662
+ expect(root_child3.getComputedTop()).toBe(70)
1663
+ expect(root_child3.getComputedWidth()).toBe(20)
1664
+ expect(root_child3.getComputedHeight()).toBe(20)
1665
+
1666
+ expect(root_child4.getComputedLeft()).toBe(50)
1667
+ expect(root_child4.getComputedTop()).toBe(70)
1668
+ expect(root_child4.getComputedWidth()).toBe(20)
1669
+ expect(root_child4.getComputedHeight()).toBe(20)
1670
+
1671
+ expect(root_child5.getComputedLeft()).toBe(20)
1672
+ expect(root_child5.getComputedTop()).toBe(70)
1673
+ expect(root_child5.getComputedWidth()).toBe(20)
1674
+ expect(root_child5.getComputedHeight()).toBe(20)
1675
+ } finally {
1676
+ if (typeof root !== "undefined") {
1677
+ root.freeRecursive()
1678
+ }
1679
+
1680
+ config.free()
1681
+ }
1682
+ })
1683
+ test("column_gap_wrap_align_stretch", () => {
1684
+ const config = Yoga.Config.create()
1685
+ let root
1686
+
1687
+ try {
1688
+ root = Yoga.Node.create(config)
1689
+ root.setFlexDirection(FlexDirection.Row)
1690
+ root.setAlignContent(Align.Stretch)
1691
+ root.setPositionType(PositionType.Absolute)
1692
+ root.setFlexWrap(Wrap.Wrap)
1693
+ root.setWidth(300)
1694
+ root.setHeight(300)
1695
+ root.setGap(Gutter.Column, 5)
1696
+
1697
+ const root_child0 = Yoga.Node.create(config)
1698
+ root_child0.setFlexGrow(1)
1699
+ root_child0.setMinWidth(60)
1700
+ root.insertChild(root_child0, 0)
1701
+
1702
+ const root_child1 = Yoga.Node.create(config)
1703
+ root_child1.setFlexGrow(1)
1704
+ root_child1.setMinWidth(60)
1705
+ root.insertChild(root_child1, 1)
1706
+
1707
+ const root_child2 = Yoga.Node.create(config)
1708
+ root_child2.setFlexGrow(1)
1709
+ root_child2.setMinWidth(60)
1710
+ root.insertChild(root_child2, 2)
1711
+
1712
+ const root_child3 = Yoga.Node.create(config)
1713
+ root_child3.setFlexGrow(1)
1714
+ root_child3.setMinWidth(60)
1715
+ root.insertChild(root_child3, 3)
1716
+
1717
+ const root_child4 = Yoga.Node.create(config)
1718
+ root_child4.setFlexGrow(1)
1719
+ root_child4.setMinWidth(60)
1720
+ root.insertChild(root_child4, 4)
1721
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1722
+
1723
+ expect(root.getComputedLeft()).toBe(0)
1724
+ expect(root.getComputedTop()).toBe(0)
1725
+ expect(root.getComputedWidth()).toBe(300)
1726
+ expect(root.getComputedHeight()).toBe(300)
1727
+
1728
+ expect(root_child0.getComputedLeft()).toBe(0)
1729
+ expect(root_child0.getComputedTop()).toBe(0)
1730
+ expect(root_child0.getComputedWidth()).toBe(71)
1731
+ expect(root_child0.getComputedHeight()).toBe(150)
1732
+
1733
+ expect(root_child1.getComputedLeft()).toBe(76)
1734
+ expect(root_child1.getComputedTop()).toBe(0)
1735
+ expect(root_child1.getComputedWidth()).toBe(72)
1736
+ expect(root_child1.getComputedHeight()).toBe(150)
1737
+
1738
+ expect(root_child2.getComputedLeft()).toBe(153)
1739
+ expect(root_child2.getComputedTop()).toBe(0)
1740
+ expect(root_child2.getComputedWidth()).toBe(71)
1741
+ expect(root_child2.getComputedHeight()).toBe(150)
1742
+
1743
+ expect(root_child3.getComputedLeft()).toBe(229)
1744
+ expect(root_child3.getComputedTop()).toBe(0)
1745
+ expect(root_child3.getComputedWidth()).toBe(71)
1746
+ expect(root_child3.getComputedHeight()).toBe(150)
1747
+
1748
+ expect(root_child4.getComputedLeft()).toBe(0)
1749
+ expect(root_child4.getComputedTop()).toBe(150)
1750
+ expect(root_child4.getComputedWidth()).toBe(300)
1751
+ expect(root_child4.getComputedHeight()).toBe(150)
1752
+
1753
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1754
+
1755
+ expect(root.getComputedLeft()).toBe(0)
1756
+ expect(root.getComputedTop()).toBe(0)
1757
+ expect(root.getComputedWidth()).toBe(300)
1758
+ expect(root.getComputedHeight()).toBe(300)
1759
+
1760
+ expect(root_child0.getComputedLeft()).toBe(229)
1761
+ expect(root_child0.getComputedTop()).toBe(0)
1762
+ expect(root_child0.getComputedWidth()).toBe(71)
1763
+ expect(root_child0.getComputedHeight()).toBe(150)
1764
+
1765
+ expect(root_child1.getComputedLeft()).toBe(153)
1766
+ expect(root_child1.getComputedTop()).toBe(0)
1767
+ expect(root_child1.getComputedWidth()).toBe(71)
1768
+ expect(root_child1.getComputedHeight()).toBe(150)
1769
+
1770
+ expect(root_child2.getComputedLeft()).toBe(76)
1771
+ expect(root_child2.getComputedTop()).toBe(0)
1772
+ expect(root_child2.getComputedWidth()).toBe(72)
1773
+ expect(root_child2.getComputedHeight()).toBe(150)
1774
+
1775
+ expect(root_child3.getComputedLeft()).toBe(0)
1776
+ expect(root_child3.getComputedTop()).toBe(0)
1777
+ expect(root_child3.getComputedWidth()).toBe(71)
1778
+ expect(root_child3.getComputedHeight()).toBe(150)
1779
+
1780
+ expect(root_child4.getComputedLeft()).toBe(0)
1781
+ expect(root_child4.getComputedTop()).toBe(150)
1782
+ expect(root_child4.getComputedWidth()).toBe(300)
1783
+ expect(root_child4.getComputedHeight()).toBe(150)
1784
+ } finally {
1785
+ if (typeof root !== "undefined") {
1786
+ root.freeRecursive()
1787
+ }
1788
+
1789
+ config.free()
1790
+ }
1791
+ })
1792
+ test("column_gap_determines_parent_width", () => {
1793
+ const config = Yoga.Config.create()
1794
+ let root
1795
+
1796
+ try {
1797
+ root = Yoga.Node.create(config)
1798
+ root.setFlexDirection(FlexDirection.Row)
1799
+ root.setPositionType(PositionType.Absolute)
1800
+ root.setHeight(100)
1801
+ root.setGap(Gutter.Column, 10)
1802
+
1803
+ const root_child0 = Yoga.Node.create(config)
1804
+ root_child0.setWidth(10)
1805
+ root.insertChild(root_child0, 0)
1806
+
1807
+ const root_child1 = Yoga.Node.create(config)
1808
+ root_child1.setWidth(20)
1809
+ root.insertChild(root_child1, 1)
1810
+
1811
+ const root_child2 = Yoga.Node.create(config)
1812
+ root_child2.setWidth(30)
1813
+ root.insertChild(root_child2, 2)
1814
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1815
+
1816
+ expect(root.getComputedLeft()).toBe(0)
1817
+ expect(root.getComputedTop()).toBe(0)
1818
+ expect(root.getComputedWidth()).toBe(80)
1819
+ expect(root.getComputedHeight()).toBe(100)
1820
+
1821
+ expect(root_child0.getComputedLeft()).toBe(0)
1822
+ expect(root_child0.getComputedTop()).toBe(0)
1823
+ expect(root_child0.getComputedWidth()).toBe(10)
1824
+ expect(root_child0.getComputedHeight()).toBe(100)
1825
+
1826
+ expect(root_child1.getComputedLeft()).toBe(20)
1827
+ expect(root_child1.getComputedTop()).toBe(0)
1828
+ expect(root_child1.getComputedWidth()).toBe(20)
1829
+ expect(root_child1.getComputedHeight()).toBe(100)
1830
+
1831
+ expect(root_child2.getComputedLeft()).toBe(50)
1832
+ expect(root_child2.getComputedTop()).toBe(0)
1833
+ expect(root_child2.getComputedWidth()).toBe(30)
1834
+ expect(root_child2.getComputedHeight()).toBe(100)
1835
+
1836
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1837
+
1838
+ expect(root.getComputedLeft()).toBe(0)
1839
+ expect(root.getComputedTop()).toBe(0)
1840
+ expect(root.getComputedWidth()).toBe(80)
1841
+ expect(root.getComputedHeight()).toBe(100)
1842
+
1843
+ expect(root_child0.getComputedLeft()).toBe(70)
1844
+ expect(root_child0.getComputedTop()).toBe(0)
1845
+ expect(root_child0.getComputedWidth()).toBe(10)
1846
+ expect(root_child0.getComputedHeight()).toBe(100)
1847
+
1848
+ expect(root_child1.getComputedLeft()).toBe(40)
1849
+ expect(root_child1.getComputedTop()).toBe(0)
1850
+ expect(root_child1.getComputedWidth()).toBe(20)
1851
+ expect(root_child1.getComputedHeight()).toBe(100)
1852
+
1853
+ expect(root_child2.getComputedLeft()).toBe(0)
1854
+ expect(root_child2.getComputedTop()).toBe(0)
1855
+ expect(root_child2.getComputedWidth()).toBe(30)
1856
+ expect(root_child2.getComputedHeight()).toBe(100)
1857
+ } finally {
1858
+ if (typeof root !== "undefined") {
1859
+ root.freeRecursive()
1860
+ }
1861
+
1862
+ config.free()
1863
+ }
1864
+ })
1865
+ test("row_gap_align_items_stretch", () => {
1866
+ const config = Yoga.Config.create()
1867
+ let root
1868
+
1869
+ try {
1870
+ root = Yoga.Node.create(config)
1871
+ root.setFlexDirection(FlexDirection.Row)
1872
+ root.setAlignContent(Align.Stretch)
1873
+ root.setPositionType(PositionType.Absolute)
1874
+ root.setFlexWrap(Wrap.Wrap)
1875
+ root.setWidth(100)
1876
+ root.setHeight(200)
1877
+ root.setGap(Gutter.Column, 10)
1878
+ root.setGap(Gutter.Row, 20)
1879
+
1880
+ const root_child0 = Yoga.Node.create(config)
1881
+ root_child0.setWidth(20)
1882
+ root.insertChild(root_child0, 0)
1883
+
1884
+ const root_child1 = Yoga.Node.create(config)
1885
+ root_child1.setWidth(20)
1886
+ root.insertChild(root_child1, 1)
1887
+
1888
+ const root_child2 = Yoga.Node.create(config)
1889
+ root_child2.setWidth(20)
1890
+ root.insertChild(root_child2, 2)
1891
+
1892
+ const root_child3 = Yoga.Node.create(config)
1893
+ root_child3.setWidth(20)
1894
+ root.insertChild(root_child3, 3)
1895
+
1896
+ const root_child4 = Yoga.Node.create(config)
1897
+ root_child4.setWidth(20)
1898
+ root.insertChild(root_child4, 4)
1899
+
1900
+ const root_child5 = Yoga.Node.create(config)
1901
+ root_child5.setWidth(20)
1902
+ root.insertChild(root_child5, 5)
1903
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1904
+
1905
+ expect(root.getComputedLeft()).toBe(0)
1906
+ expect(root.getComputedTop()).toBe(0)
1907
+ expect(root.getComputedWidth()).toBe(100)
1908
+ expect(root.getComputedHeight()).toBe(200)
1909
+
1910
+ expect(root_child0.getComputedLeft()).toBe(0)
1911
+ expect(root_child0.getComputedTop()).toBe(0)
1912
+ expect(root_child0.getComputedWidth()).toBe(20)
1913
+ expect(root_child0.getComputedHeight()).toBe(90)
1914
+
1915
+ expect(root_child1.getComputedLeft()).toBe(30)
1916
+ expect(root_child1.getComputedTop()).toBe(0)
1917
+ expect(root_child1.getComputedWidth()).toBe(20)
1918
+ expect(root_child1.getComputedHeight()).toBe(90)
1919
+
1920
+ expect(root_child2.getComputedLeft()).toBe(60)
1921
+ expect(root_child2.getComputedTop()).toBe(0)
1922
+ expect(root_child2.getComputedWidth()).toBe(20)
1923
+ expect(root_child2.getComputedHeight()).toBe(90)
1924
+
1925
+ expect(root_child3.getComputedLeft()).toBe(0)
1926
+ expect(root_child3.getComputedTop()).toBe(110)
1927
+ expect(root_child3.getComputedWidth()).toBe(20)
1928
+ expect(root_child3.getComputedHeight()).toBe(90)
1929
+
1930
+ expect(root_child4.getComputedLeft()).toBe(30)
1931
+ expect(root_child4.getComputedTop()).toBe(110)
1932
+ expect(root_child4.getComputedWidth()).toBe(20)
1933
+ expect(root_child4.getComputedHeight()).toBe(90)
1934
+
1935
+ expect(root_child5.getComputedLeft()).toBe(60)
1936
+ expect(root_child5.getComputedTop()).toBe(110)
1937
+ expect(root_child5.getComputedWidth()).toBe(20)
1938
+ expect(root_child5.getComputedHeight()).toBe(90)
1939
+
1940
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1941
+
1942
+ expect(root.getComputedLeft()).toBe(0)
1943
+ expect(root.getComputedTop()).toBe(0)
1944
+ expect(root.getComputedWidth()).toBe(100)
1945
+ expect(root.getComputedHeight()).toBe(200)
1946
+
1947
+ expect(root_child0.getComputedLeft()).toBe(80)
1948
+ expect(root_child0.getComputedTop()).toBe(0)
1949
+ expect(root_child0.getComputedWidth()).toBe(20)
1950
+ expect(root_child0.getComputedHeight()).toBe(90)
1951
+
1952
+ expect(root_child1.getComputedLeft()).toBe(50)
1953
+ expect(root_child1.getComputedTop()).toBe(0)
1954
+ expect(root_child1.getComputedWidth()).toBe(20)
1955
+ expect(root_child1.getComputedHeight()).toBe(90)
1956
+
1957
+ expect(root_child2.getComputedLeft()).toBe(20)
1958
+ expect(root_child2.getComputedTop()).toBe(0)
1959
+ expect(root_child2.getComputedWidth()).toBe(20)
1960
+ expect(root_child2.getComputedHeight()).toBe(90)
1961
+
1962
+ expect(root_child3.getComputedLeft()).toBe(80)
1963
+ expect(root_child3.getComputedTop()).toBe(110)
1964
+ expect(root_child3.getComputedWidth()).toBe(20)
1965
+ expect(root_child3.getComputedHeight()).toBe(90)
1966
+
1967
+ expect(root_child4.getComputedLeft()).toBe(50)
1968
+ expect(root_child4.getComputedTop()).toBe(110)
1969
+ expect(root_child4.getComputedWidth()).toBe(20)
1970
+ expect(root_child4.getComputedHeight()).toBe(90)
1971
+
1972
+ expect(root_child5.getComputedLeft()).toBe(20)
1973
+ expect(root_child5.getComputedTop()).toBe(110)
1974
+ expect(root_child5.getComputedWidth()).toBe(20)
1975
+ expect(root_child5.getComputedHeight()).toBe(90)
1976
+ } finally {
1977
+ if (typeof root !== "undefined") {
1978
+ root.freeRecursive()
1979
+ }
1980
+
1981
+ config.free()
1982
+ }
1983
+ })
1984
+ test("row_gap_align_items_end", () => {
1985
+ const config = Yoga.Config.create()
1986
+ let root
1987
+
1988
+ try {
1989
+ root = Yoga.Node.create(config)
1990
+ root.setFlexDirection(FlexDirection.Row)
1991
+ root.setAlignItems(Align.FlexEnd)
1992
+ root.setPositionType(PositionType.Absolute)
1993
+ root.setFlexWrap(Wrap.Wrap)
1994
+ root.setWidth(100)
1995
+ root.setHeight(200)
1996
+ root.setGap(Gutter.Column, 10)
1997
+ root.setGap(Gutter.Row, 20)
1998
+
1999
+ const root_child0 = Yoga.Node.create(config)
2000
+ root_child0.setWidth(20)
2001
+ root.insertChild(root_child0, 0)
2002
+
2003
+ const root_child1 = Yoga.Node.create(config)
2004
+ root_child1.setWidth(20)
2005
+ root.insertChild(root_child1, 1)
2006
+
2007
+ const root_child2 = Yoga.Node.create(config)
2008
+ root_child2.setWidth(20)
2009
+ root.insertChild(root_child2, 2)
2010
+
2011
+ const root_child3 = Yoga.Node.create(config)
2012
+ root_child3.setWidth(20)
2013
+ root.insertChild(root_child3, 3)
2014
+
2015
+ const root_child4 = Yoga.Node.create(config)
2016
+ root_child4.setWidth(20)
2017
+ root.insertChild(root_child4, 4)
2018
+
2019
+ const root_child5 = Yoga.Node.create(config)
2020
+ root_child5.setWidth(20)
2021
+ root.insertChild(root_child5, 5)
2022
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2023
+
2024
+ expect(root.getComputedLeft()).toBe(0)
2025
+ expect(root.getComputedTop()).toBe(0)
2026
+ expect(root.getComputedWidth()).toBe(100)
2027
+ expect(root.getComputedHeight()).toBe(200)
2028
+
2029
+ expect(root_child0.getComputedLeft()).toBe(0)
2030
+ expect(root_child0.getComputedTop()).toBe(0)
2031
+ expect(root_child0.getComputedWidth()).toBe(20)
2032
+ expect(root_child0.getComputedHeight()).toBe(0)
2033
+
2034
+ expect(root_child1.getComputedLeft()).toBe(30)
2035
+ expect(root_child1.getComputedTop()).toBe(0)
2036
+ expect(root_child1.getComputedWidth()).toBe(20)
2037
+ expect(root_child1.getComputedHeight()).toBe(0)
2038
+
2039
+ expect(root_child2.getComputedLeft()).toBe(60)
2040
+ expect(root_child2.getComputedTop()).toBe(0)
2041
+ expect(root_child2.getComputedWidth()).toBe(20)
2042
+ expect(root_child2.getComputedHeight()).toBe(0)
2043
+
2044
+ expect(root_child3.getComputedLeft()).toBe(0)
2045
+ expect(root_child3.getComputedTop()).toBe(20)
2046
+ expect(root_child3.getComputedWidth()).toBe(20)
2047
+ expect(root_child3.getComputedHeight()).toBe(0)
2048
+
2049
+ expect(root_child4.getComputedLeft()).toBe(30)
2050
+ expect(root_child4.getComputedTop()).toBe(20)
2051
+ expect(root_child4.getComputedWidth()).toBe(20)
2052
+ expect(root_child4.getComputedHeight()).toBe(0)
2053
+
2054
+ expect(root_child5.getComputedLeft()).toBe(60)
2055
+ expect(root_child5.getComputedTop()).toBe(20)
2056
+ expect(root_child5.getComputedWidth()).toBe(20)
2057
+ expect(root_child5.getComputedHeight()).toBe(0)
2058
+
2059
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2060
+
2061
+ expect(root.getComputedLeft()).toBe(0)
2062
+ expect(root.getComputedTop()).toBe(0)
2063
+ expect(root.getComputedWidth()).toBe(100)
2064
+ expect(root.getComputedHeight()).toBe(200)
2065
+
2066
+ expect(root_child0.getComputedLeft()).toBe(80)
2067
+ expect(root_child0.getComputedTop()).toBe(0)
2068
+ expect(root_child0.getComputedWidth()).toBe(20)
2069
+ expect(root_child0.getComputedHeight()).toBe(0)
2070
+
2071
+ expect(root_child1.getComputedLeft()).toBe(50)
2072
+ expect(root_child1.getComputedTop()).toBe(0)
2073
+ expect(root_child1.getComputedWidth()).toBe(20)
2074
+ expect(root_child1.getComputedHeight()).toBe(0)
2075
+
2076
+ expect(root_child2.getComputedLeft()).toBe(20)
2077
+ expect(root_child2.getComputedTop()).toBe(0)
2078
+ expect(root_child2.getComputedWidth()).toBe(20)
2079
+ expect(root_child2.getComputedHeight()).toBe(0)
2080
+
2081
+ expect(root_child3.getComputedLeft()).toBe(80)
2082
+ expect(root_child3.getComputedTop()).toBe(20)
2083
+ expect(root_child3.getComputedWidth()).toBe(20)
2084
+ expect(root_child3.getComputedHeight()).toBe(0)
2085
+
2086
+ expect(root_child4.getComputedLeft()).toBe(50)
2087
+ expect(root_child4.getComputedTop()).toBe(20)
2088
+ expect(root_child4.getComputedWidth()).toBe(20)
2089
+ expect(root_child4.getComputedHeight()).toBe(0)
2090
+
2091
+ expect(root_child5.getComputedLeft()).toBe(20)
2092
+ expect(root_child5.getComputedTop()).toBe(20)
2093
+ expect(root_child5.getComputedWidth()).toBe(20)
2094
+ expect(root_child5.getComputedHeight()).toBe(0)
2095
+ } finally {
2096
+ if (typeof root !== "undefined") {
2097
+ root.freeRecursive()
2098
+ }
2099
+
2100
+ config.free()
2101
+ }
2102
+ })
2103
+ test("row_gap_column_child_margins", () => {
2104
+ const config = Yoga.Config.create()
2105
+ let root
2106
+
2107
+ try {
2108
+ root = Yoga.Node.create(config)
2109
+ root.setPositionType(PositionType.Absolute)
2110
+ root.setWidth(100)
2111
+ root.setHeight(200)
2112
+ root.setGap(Gutter.Row, 10)
2113
+
2114
+ const root_child0 = Yoga.Node.create(config)
2115
+ root_child0.setFlexGrow(1)
2116
+ root_child0.setFlexShrink(1)
2117
+ root_child0.setFlexBasis("0%")
2118
+ root_child0.setMargin(Edge.Top, 2)
2119
+ root_child0.setMargin(Edge.Bottom, 2)
2120
+ root.insertChild(root_child0, 0)
2121
+
2122
+ const root_child1 = Yoga.Node.create(config)
2123
+ root_child1.setFlexGrow(1)
2124
+ root_child1.setFlexShrink(1)
2125
+ root_child1.setFlexBasis("0%")
2126
+ root_child1.setMargin(Edge.Top, 10)
2127
+ root_child1.setMargin(Edge.Bottom, 10)
2128
+ root.insertChild(root_child1, 1)
2129
+
2130
+ const root_child2 = Yoga.Node.create(config)
2131
+ root_child2.setFlexGrow(1)
2132
+ root_child2.setFlexShrink(1)
2133
+ root_child2.setFlexBasis("0%")
2134
+ root_child2.setMargin(Edge.Top, 15)
2135
+ root_child2.setMargin(Edge.Bottom, 15)
2136
+ root.insertChild(root_child2, 2)
2137
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2138
+
2139
+ expect(root.getComputedLeft()).toBe(0)
2140
+ expect(root.getComputedTop()).toBe(0)
2141
+ expect(root.getComputedWidth()).toBe(100)
2142
+ expect(root.getComputedHeight()).toBe(200)
2143
+
2144
+ expect(root_child0.getComputedLeft()).toBe(0)
2145
+ expect(root_child0.getComputedTop()).toBe(2)
2146
+ expect(root_child0.getComputedWidth()).toBe(100)
2147
+ expect(root_child0.getComputedHeight()).toBe(42)
2148
+
2149
+ expect(root_child1.getComputedLeft()).toBe(0)
2150
+ expect(root_child1.getComputedTop()).toBe(66)
2151
+ expect(root_child1.getComputedWidth()).toBe(100)
2152
+ expect(root_child1.getComputedHeight()).toBe(42)
2153
+
2154
+ expect(root_child2.getComputedLeft()).toBe(0)
2155
+ expect(root_child2.getComputedTop()).toBe(143)
2156
+ expect(root_child2.getComputedWidth()).toBe(100)
2157
+ expect(root_child2.getComputedHeight()).toBe(42)
2158
+
2159
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2160
+
2161
+ expect(root.getComputedLeft()).toBe(0)
2162
+ expect(root.getComputedTop()).toBe(0)
2163
+ expect(root.getComputedWidth()).toBe(100)
2164
+ expect(root.getComputedHeight()).toBe(200)
2165
+
2166
+ expect(root_child0.getComputedLeft()).toBe(0)
2167
+ expect(root_child0.getComputedTop()).toBe(2)
2168
+ expect(root_child0.getComputedWidth()).toBe(100)
2169
+ expect(root_child0.getComputedHeight()).toBe(42)
2170
+
2171
+ expect(root_child1.getComputedLeft()).toBe(0)
2172
+ expect(root_child1.getComputedTop()).toBe(66)
2173
+ expect(root_child1.getComputedWidth()).toBe(100)
2174
+ expect(root_child1.getComputedHeight()).toBe(42)
2175
+
2176
+ expect(root_child2.getComputedLeft()).toBe(0)
2177
+ expect(root_child2.getComputedTop()).toBe(143)
2178
+ expect(root_child2.getComputedWidth()).toBe(100)
2179
+ expect(root_child2.getComputedHeight()).toBe(42)
2180
+ } finally {
2181
+ if (typeof root !== "undefined") {
2182
+ root.freeRecursive()
2183
+ }
2184
+
2185
+ config.free()
2186
+ }
2187
+ })
2188
+ test("row_gap_row_wrap_child_margins", () => {
2189
+ const config = Yoga.Config.create()
2190
+ let root
2191
+
2192
+ try {
2193
+ root = Yoga.Node.create(config)
2194
+ root.setFlexDirection(FlexDirection.Row)
2195
+ root.setPositionType(PositionType.Absolute)
2196
+ root.setFlexWrap(Wrap.Wrap)
2197
+ root.setWidth(100)
2198
+ root.setHeight(200)
2199
+ root.setGap(Gutter.Row, 10)
2200
+
2201
+ const root_child0 = Yoga.Node.create(config)
2202
+ root_child0.setMargin(Edge.Top, 2)
2203
+ root_child0.setMargin(Edge.Bottom, 2)
2204
+ root_child0.setWidth(60)
2205
+ root.insertChild(root_child0, 0)
2206
+
2207
+ const root_child1 = Yoga.Node.create(config)
2208
+ root_child1.setMargin(Edge.Top, 10)
2209
+ root_child1.setMargin(Edge.Bottom, 10)
2210
+ root_child1.setWidth(60)
2211
+ root.insertChild(root_child1, 1)
2212
+
2213
+ const root_child2 = Yoga.Node.create(config)
2214
+ root_child2.setMargin(Edge.Top, 15)
2215
+ root_child2.setMargin(Edge.Bottom, 15)
2216
+ root_child2.setWidth(60)
2217
+ root.insertChild(root_child2, 2)
2218
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2219
+
2220
+ expect(root.getComputedLeft()).toBe(0)
2221
+ expect(root.getComputedTop()).toBe(0)
2222
+ expect(root.getComputedWidth()).toBe(100)
2223
+ expect(root.getComputedHeight()).toBe(200)
2224
+
2225
+ expect(root_child0.getComputedLeft()).toBe(0)
2226
+ expect(root_child0.getComputedTop()).toBe(2)
2227
+ expect(root_child0.getComputedWidth()).toBe(60)
2228
+ expect(root_child0.getComputedHeight()).toBe(0)
2229
+
2230
+ expect(root_child1.getComputedLeft()).toBe(0)
2231
+ expect(root_child1.getComputedTop()).toBe(24)
2232
+ expect(root_child1.getComputedWidth()).toBe(60)
2233
+ expect(root_child1.getComputedHeight()).toBe(0)
2234
+
2235
+ expect(root_child2.getComputedLeft()).toBe(0)
2236
+ expect(root_child2.getComputedTop()).toBe(59)
2237
+ expect(root_child2.getComputedWidth()).toBe(60)
2238
+ expect(root_child2.getComputedHeight()).toBe(0)
2239
+
2240
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2241
+
2242
+ expect(root.getComputedLeft()).toBe(0)
2243
+ expect(root.getComputedTop()).toBe(0)
2244
+ expect(root.getComputedWidth()).toBe(100)
2245
+ expect(root.getComputedHeight()).toBe(200)
2246
+
2247
+ expect(root_child0.getComputedLeft()).toBe(40)
2248
+ expect(root_child0.getComputedTop()).toBe(2)
2249
+ expect(root_child0.getComputedWidth()).toBe(60)
2250
+ expect(root_child0.getComputedHeight()).toBe(0)
2251
+
2252
+ expect(root_child1.getComputedLeft()).toBe(40)
2253
+ expect(root_child1.getComputedTop()).toBe(24)
2254
+ expect(root_child1.getComputedWidth()).toBe(60)
2255
+ expect(root_child1.getComputedHeight()).toBe(0)
2256
+
2257
+ expect(root_child2.getComputedLeft()).toBe(40)
2258
+ expect(root_child2.getComputedTop()).toBe(59)
2259
+ expect(root_child2.getComputedWidth()).toBe(60)
2260
+ expect(root_child2.getComputedHeight()).toBe(0)
2261
+ } finally {
2262
+ if (typeof root !== "undefined") {
2263
+ root.freeRecursive()
2264
+ }
2265
+
2266
+ config.free()
2267
+ }
2268
+ })
2269
+ test("row_gap_determines_parent_height", () => {
2270
+ const config = Yoga.Config.create()
2271
+ let root
2272
+
2273
+ try {
2274
+ root = Yoga.Node.create(config)
2275
+ root.setPositionType(PositionType.Absolute)
2276
+ root.setWidth(100)
2277
+ root.setGap(Gutter.Row, 10)
2278
+
2279
+ const root_child0 = Yoga.Node.create(config)
2280
+ root_child0.setHeight(10)
2281
+ root.insertChild(root_child0, 0)
2282
+
2283
+ const root_child1 = Yoga.Node.create(config)
2284
+ root_child1.setHeight(20)
2285
+ root.insertChild(root_child1, 1)
2286
+
2287
+ const root_child2 = Yoga.Node.create(config)
2288
+ root_child2.setHeight(30)
2289
+ root.insertChild(root_child2, 2)
2290
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2291
+
2292
+ expect(root.getComputedLeft()).toBe(0)
2293
+ expect(root.getComputedTop()).toBe(0)
2294
+ expect(root.getComputedWidth()).toBe(100)
2295
+ expect(root.getComputedHeight()).toBe(80)
2296
+
2297
+ expect(root_child0.getComputedLeft()).toBe(0)
2298
+ expect(root_child0.getComputedTop()).toBe(0)
2299
+ expect(root_child0.getComputedWidth()).toBe(100)
2300
+ expect(root_child0.getComputedHeight()).toBe(10)
2301
+
2302
+ expect(root_child1.getComputedLeft()).toBe(0)
2303
+ expect(root_child1.getComputedTop()).toBe(20)
2304
+ expect(root_child1.getComputedWidth()).toBe(100)
2305
+ expect(root_child1.getComputedHeight()).toBe(20)
2306
+
2307
+ expect(root_child2.getComputedLeft()).toBe(0)
2308
+ expect(root_child2.getComputedTop()).toBe(50)
2309
+ expect(root_child2.getComputedWidth()).toBe(100)
2310
+ expect(root_child2.getComputedHeight()).toBe(30)
2311
+
2312
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2313
+
2314
+ expect(root.getComputedLeft()).toBe(0)
2315
+ expect(root.getComputedTop()).toBe(0)
2316
+ expect(root.getComputedWidth()).toBe(100)
2317
+ expect(root.getComputedHeight()).toBe(80)
2318
+
2319
+ expect(root_child0.getComputedLeft()).toBe(0)
2320
+ expect(root_child0.getComputedTop()).toBe(0)
2321
+ expect(root_child0.getComputedWidth()).toBe(100)
2322
+ expect(root_child0.getComputedHeight()).toBe(10)
2323
+
2324
+ expect(root_child1.getComputedLeft()).toBe(0)
2325
+ expect(root_child1.getComputedTop()).toBe(20)
2326
+ expect(root_child1.getComputedWidth()).toBe(100)
2327
+ expect(root_child1.getComputedHeight()).toBe(20)
2328
+
2329
+ expect(root_child2.getComputedLeft()).toBe(0)
2330
+ expect(root_child2.getComputedTop()).toBe(50)
2331
+ expect(root_child2.getComputedWidth()).toBe(100)
2332
+ expect(root_child2.getComputedHeight()).toBe(30)
2333
+ } finally {
2334
+ if (typeof root !== "undefined") {
2335
+ root.freeRecursive()
2336
+ }
2337
+
2338
+ config.free()
2339
+ }
2340
+ })
2341
+ test("row_gap_percent_wrapping", () => {
2342
+ const config = Yoga.Config.create()
2343
+ let root
2344
+
2345
+ try {
2346
+ root = Yoga.Node.create(config)
2347
+ root.setFlexDirection(FlexDirection.Row)
2348
+ root.setPositionType(PositionType.Absolute)
2349
+ root.setFlexWrap(Wrap.Wrap)
2350
+ root.setPadding(Edge.Left, 10)
2351
+ root.setPadding(Edge.Top, 10)
2352
+ root.setPadding(Edge.Right, 10)
2353
+ root.setPadding(Edge.Bottom, 10)
2354
+ root.setWidth(300)
2355
+ root.setHeight(700)
2356
+ root.setGap(Gutter.Column, "10%")
2357
+ root.setGap(Gutter.Row, "10%")
2358
+
2359
+ const root_child0 = Yoga.Node.create(config)
2360
+ root_child0.setWidth(100)
2361
+ root_child0.setHeight(100)
2362
+ root.insertChild(root_child0, 0)
2363
+
2364
+ const root_child1 = Yoga.Node.create(config)
2365
+ root_child1.setWidth(100)
2366
+ root_child1.setHeight(100)
2367
+ root.insertChild(root_child1, 1)
2368
+
2369
+ const root_child2 = Yoga.Node.create(config)
2370
+ root_child2.setWidth(100)
2371
+ root_child2.setHeight(100)
2372
+ root.insertChild(root_child2, 2)
2373
+
2374
+ const root_child3 = Yoga.Node.create(config)
2375
+ root_child3.setWidth(100)
2376
+ root_child3.setHeight(100)
2377
+ root.insertChild(root_child3, 3)
2378
+
2379
+ const root_child4 = Yoga.Node.create(config)
2380
+ root_child4.setWidth(100)
2381
+ root_child4.setHeight(100)
2382
+ root.insertChild(root_child4, 4)
2383
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2384
+
2385
+ expect(root.getComputedLeft()).toBe(0)
2386
+ expect(root.getComputedTop()).toBe(0)
2387
+ expect(root.getComputedWidth()).toBe(300)
2388
+ expect(root.getComputedHeight()).toBe(700)
2389
+
2390
+ expect(root_child0.getComputedLeft()).toBe(10)
2391
+ expect(root_child0.getComputedTop()).toBe(10)
2392
+ expect(root_child0.getComputedWidth()).toBe(100)
2393
+ expect(root_child0.getComputedHeight()).toBe(100)
2394
+
2395
+ expect(root_child1.getComputedLeft()).toBe(138)
2396
+ expect(root_child1.getComputedTop()).toBe(10)
2397
+ expect(root_child1.getComputedWidth()).toBe(100)
2398
+ expect(root_child1.getComputedHeight()).toBe(100)
2399
+
2400
+ expect(root_child2.getComputedLeft()).toBe(10)
2401
+ expect(root_child2.getComputedTop()).toBe(178)
2402
+ expect(root_child2.getComputedWidth()).toBe(100)
2403
+ expect(root_child2.getComputedHeight()).toBe(100)
2404
+
2405
+ expect(root_child3.getComputedLeft()).toBe(138)
2406
+ expect(root_child3.getComputedTop()).toBe(178)
2407
+ expect(root_child3.getComputedWidth()).toBe(100)
2408
+ expect(root_child3.getComputedHeight()).toBe(100)
2409
+
2410
+ expect(root_child4.getComputedLeft()).toBe(10)
2411
+ expect(root_child4.getComputedTop()).toBe(346)
2412
+ expect(root_child4.getComputedWidth()).toBe(100)
2413
+ expect(root_child4.getComputedHeight()).toBe(100)
2414
+
2415
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2416
+
2417
+ expect(root.getComputedLeft()).toBe(0)
2418
+ expect(root.getComputedTop()).toBe(0)
2419
+ expect(root.getComputedWidth()).toBe(300)
2420
+ expect(root.getComputedHeight()).toBe(700)
2421
+
2422
+ expect(root_child0.getComputedLeft()).toBe(190)
2423
+ expect(root_child0.getComputedTop()).toBe(10)
2424
+ expect(root_child0.getComputedWidth()).toBe(100)
2425
+ expect(root_child0.getComputedHeight()).toBe(100)
2426
+
2427
+ expect(root_child1.getComputedLeft()).toBe(62)
2428
+ expect(root_child1.getComputedTop()).toBe(10)
2429
+ expect(root_child1.getComputedWidth()).toBe(100)
2430
+ expect(root_child1.getComputedHeight()).toBe(100)
2431
+
2432
+ expect(root_child2.getComputedLeft()).toBe(190)
2433
+ expect(root_child2.getComputedTop()).toBe(178)
2434
+ expect(root_child2.getComputedWidth()).toBe(100)
2435
+ expect(root_child2.getComputedHeight()).toBe(100)
2436
+
2437
+ expect(root_child3.getComputedLeft()).toBe(62)
2438
+ expect(root_child3.getComputedTop()).toBe(178)
2439
+ expect(root_child3.getComputedWidth()).toBe(100)
2440
+ expect(root_child3.getComputedHeight()).toBe(100)
2441
+
2442
+ expect(root_child4.getComputedLeft()).toBe(190)
2443
+ expect(root_child4.getComputedTop()).toBe(346)
2444
+ expect(root_child4.getComputedWidth()).toBe(100)
2445
+ expect(root_child4.getComputedHeight()).toBe(100)
2446
+ } finally {
2447
+ if (typeof root !== "undefined") {
2448
+ root.freeRecursive()
2449
+ }
2450
+
2451
+ config.free()
2452
+ }
2453
+ })
2454
+ test("row_gap_percent_determines_parent_height", () => {
2455
+ const config = Yoga.Config.create()
2456
+ let root
2457
+
2458
+ try {
2459
+ root = Yoga.Node.create(config)
2460
+ root.setFlexDirection(FlexDirection.Row)
2461
+ root.setPositionType(PositionType.Absolute)
2462
+ root.setFlexWrap(Wrap.Wrap)
2463
+ root.setWidth(300)
2464
+ root.setGap(Gutter.Column, "10%")
2465
+ root.setGap(Gutter.Row, "10%")
2466
+
2467
+ const root_child0 = Yoga.Node.create(config)
2468
+ root_child0.setWidth(100)
2469
+ root_child0.setHeight(100)
2470
+ root.insertChild(root_child0, 0)
2471
+
2472
+ const root_child1 = Yoga.Node.create(config)
2473
+ root_child1.setWidth(100)
2474
+ root_child1.setHeight(100)
2475
+ root.insertChild(root_child1, 1)
2476
+
2477
+ const root_child2 = Yoga.Node.create(config)
2478
+ root_child2.setWidth(100)
2479
+ root_child2.setHeight(100)
2480
+ root.insertChild(root_child2, 2)
2481
+
2482
+ const root_child3 = Yoga.Node.create(config)
2483
+ root_child3.setWidth(100)
2484
+ root_child3.setHeight(100)
2485
+ root.insertChild(root_child3, 3)
2486
+
2487
+ const root_child4 = Yoga.Node.create(config)
2488
+ root_child4.setWidth(100)
2489
+ root_child4.setHeight(100)
2490
+ root.insertChild(root_child4, 4)
2491
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2492
+
2493
+ expect(root.getComputedLeft()).toBe(0)
2494
+ expect(root.getComputedTop()).toBe(0)
2495
+ expect(root.getComputedWidth()).toBe(300)
2496
+ expect(root.getComputedHeight()).toBe(300)
2497
+
2498
+ expect(root_child0.getComputedLeft()).toBe(0)
2499
+ expect(root_child0.getComputedTop()).toBe(0)
2500
+ expect(root_child0.getComputedWidth()).toBe(100)
2501
+ expect(root_child0.getComputedHeight()).toBe(100)
2502
+
2503
+ expect(root_child1.getComputedLeft()).toBe(130)
2504
+ expect(root_child1.getComputedTop()).toBe(0)
2505
+ expect(root_child1.getComputedWidth()).toBe(100)
2506
+ expect(root_child1.getComputedHeight()).toBe(100)
2507
+
2508
+ expect(root_child2.getComputedLeft()).toBe(0)
2509
+ expect(root_child2.getComputedTop()).toBe(100)
2510
+ expect(root_child2.getComputedWidth()).toBe(100)
2511
+ expect(root_child2.getComputedHeight()).toBe(100)
2512
+
2513
+ expect(root_child3.getComputedLeft()).toBe(130)
2514
+ expect(root_child3.getComputedTop()).toBe(100)
2515
+ expect(root_child3.getComputedWidth()).toBe(100)
2516
+ expect(root_child3.getComputedHeight()).toBe(100)
2517
+
2518
+ expect(root_child4.getComputedLeft()).toBe(0)
2519
+ expect(root_child4.getComputedTop()).toBe(200)
2520
+ expect(root_child4.getComputedWidth()).toBe(100)
2521
+ expect(root_child4.getComputedHeight()).toBe(100)
2522
+
2523
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2524
+
2525
+ expect(root.getComputedLeft()).toBe(0)
2526
+ expect(root.getComputedTop()).toBe(0)
2527
+ expect(root.getComputedWidth()).toBe(300)
2528
+ expect(root.getComputedHeight()).toBe(300)
2529
+
2530
+ expect(root_child0.getComputedLeft()).toBe(200)
2531
+ expect(root_child0.getComputedTop()).toBe(0)
2532
+ expect(root_child0.getComputedWidth()).toBe(100)
2533
+ expect(root_child0.getComputedHeight()).toBe(100)
2534
+
2535
+ expect(root_child1.getComputedLeft()).toBe(70)
2536
+ expect(root_child1.getComputedTop()).toBe(0)
2537
+ expect(root_child1.getComputedWidth()).toBe(100)
2538
+ expect(root_child1.getComputedHeight()).toBe(100)
2539
+
2540
+ expect(root_child2.getComputedLeft()).toBe(200)
2541
+ expect(root_child2.getComputedTop()).toBe(100)
2542
+ expect(root_child2.getComputedWidth()).toBe(100)
2543
+ expect(root_child2.getComputedHeight()).toBe(100)
2544
+
2545
+ expect(root_child3.getComputedLeft()).toBe(70)
2546
+ expect(root_child3.getComputedTop()).toBe(100)
2547
+ expect(root_child3.getComputedWidth()).toBe(100)
2548
+ expect(root_child3.getComputedHeight()).toBe(100)
2549
+
2550
+ expect(root_child4.getComputedLeft()).toBe(200)
2551
+ expect(root_child4.getComputedTop()).toBe(200)
2552
+ expect(root_child4.getComputedWidth()).toBe(100)
2553
+ expect(root_child4.getComputedHeight()).toBe(100)
2554
+ } finally {
2555
+ if (typeof root !== "undefined") {
2556
+ root.freeRecursive()
2557
+ }
2558
+
2559
+ config.free()
2560
+ }
2561
+ })
2562
+ test("row_gap_percent_wrapping_with_both_content_padding_and_item_padding", () => {
2563
+ const config = Yoga.Config.create()
2564
+ let root
2565
+
2566
+ try {
2567
+ root = Yoga.Node.create(config)
2568
+ root.setFlexDirection(FlexDirection.Row)
2569
+ root.setPositionType(PositionType.Absolute)
2570
+ root.setFlexWrap(Wrap.Wrap)
2571
+ root.setPadding(Edge.Left, 10)
2572
+ root.setPadding(Edge.Top, 10)
2573
+ root.setPadding(Edge.Right, 10)
2574
+ root.setPadding(Edge.Bottom, 10)
2575
+ root.setWidth(300)
2576
+ root.setHeight(700)
2577
+ root.setGap(Gutter.Column, "10%")
2578
+ root.setGap(Gutter.Row, "10%")
2579
+
2580
+ const root_child0 = Yoga.Node.create(config)
2581
+ root_child0.setPadding(Edge.Left, 10)
2582
+ root_child0.setPadding(Edge.Top, 10)
2583
+ root_child0.setPadding(Edge.Right, 10)
2584
+ root_child0.setPadding(Edge.Bottom, 10)
2585
+ root_child0.setWidth(100)
2586
+ root_child0.setHeight(100)
2587
+ root.insertChild(root_child0, 0)
2588
+
2589
+ const root_child1 = Yoga.Node.create(config)
2590
+ root_child1.setPadding(Edge.Left, 10)
2591
+ root_child1.setPadding(Edge.Top, 10)
2592
+ root_child1.setPadding(Edge.Right, 10)
2593
+ root_child1.setPadding(Edge.Bottom, 10)
2594
+ root_child1.setWidth(100)
2595
+ root_child1.setHeight(100)
2596
+ root.insertChild(root_child1, 1)
2597
+
2598
+ const root_child2 = Yoga.Node.create(config)
2599
+ root_child2.setPadding(Edge.Left, 10)
2600
+ root_child2.setPadding(Edge.Top, 10)
2601
+ root_child2.setPadding(Edge.Right, 10)
2602
+ root_child2.setPadding(Edge.Bottom, 10)
2603
+ root_child2.setWidth(100)
2604
+ root_child2.setHeight(100)
2605
+ root.insertChild(root_child2, 2)
2606
+
2607
+ const root_child3 = Yoga.Node.create(config)
2608
+ root_child3.setPadding(Edge.Left, 10)
2609
+ root_child3.setPadding(Edge.Top, 10)
2610
+ root_child3.setPadding(Edge.Right, 10)
2611
+ root_child3.setPadding(Edge.Bottom, 10)
2612
+ root_child3.setWidth(100)
2613
+ root_child3.setHeight(100)
2614
+ root.insertChild(root_child3, 3)
2615
+
2616
+ const root_child4 = Yoga.Node.create(config)
2617
+ root_child4.setPadding(Edge.Left, 10)
2618
+ root_child4.setPadding(Edge.Top, 10)
2619
+ root_child4.setPadding(Edge.Right, 10)
2620
+ root_child4.setPadding(Edge.Bottom, 10)
2621
+ root_child4.setWidth(100)
2622
+ root_child4.setHeight(100)
2623
+ root.insertChild(root_child4, 4)
2624
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2625
+
2626
+ expect(root.getComputedLeft()).toBe(0)
2627
+ expect(root.getComputedTop()).toBe(0)
2628
+ expect(root.getComputedWidth()).toBe(300)
2629
+ expect(root.getComputedHeight()).toBe(700)
2630
+
2631
+ expect(root_child0.getComputedLeft()).toBe(10)
2632
+ expect(root_child0.getComputedTop()).toBe(10)
2633
+ expect(root_child0.getComputedWidth()).toBe(100)
2634
+ expect(root_child0.getComputedHeight()).toBe(100)
2635
+
2636
+ expect(root_child1.getComputedLeft()).toBe(138)
2637
+ expect(root_child1.getComputedTop()).toBe(10)
2638
+ expect(root_child1.getComputedWidth()).toBe(100)
2639
+ expect(root_child1.getComputedHeight()).toBe(100)
2640
+
2641
+ expect(root_child2.getComputedLeft()).toBe(10)
2642
+ expect(root_child2.getComputedTop()).toBe(178)
2643
+ expect(root_child2.getComputedWidth()).toBe(100)
2644
+ expect(root_child2.getComputedHeight()).toBe(100)
2645
+
2646
+ expect(root_child3.getComputedLeft()).toBe(138)
2647
+ expect(root_child3.getComputedTop()).toBe(178)
2648
+ expect(root_child3.getComputedWidth()).toBe(100)
2649
+ expect(root_child3.getComputedHeight()).toBe(100)
2650
+
2651
+ expect(root_child4.getComputedLeft()).toBe(10)
2652
+ expect(root_child4.getComputedTop()).toBe(346)
2653
+ expect(root_child4.getComputedWidth()).toBe(100)
2654
+ expect(root_child4.getComputedHeight()).toBe(100)
2655
+
2656
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2657
+
2658
+ expect(root.getComputedLeft()).toBe(0)
2659
+ expect(root.getComputedTop()).toBe(0)
2660
+ expect(root.getComputedWidth()).toBe(300)
2661
+ expect(root.getComputedHeight()).toBe(700)
2662
+
2663
+ expect(root_child0.getComputedLeft()).toBe(190)
2664
+ expect(root_child0.getComputedTop()).toBe(10)
2665
+ expect(root_child0.getComputedWidth()).toBe(100)
2666
+ expect(root_child0.getComputedHeight()).toBe(100)
2667
+
2668
+ expect(root_child1.getComputedLeft()).toBe(62)
2669
+ expect(root_child1.getComputedTop()).toBe(10)
2670
+ expect(root_child1.getComputedWidth()).toBe(100)
2671
+ expect(root_child1.getComputedHeight()).toBe(100)
2672
+
2673
+ expect(root_child2.getComputedLeft()).toBe(190)
2674
+ expect(root_child2.getComputedTop()).toBe(178)
2675
+ expect(root_child2.getComputedWidth()).toBe(100)
2676
+ expect(root_child2.getComputedHeight()).toBe(100)
2677
+
2678
+ expect(root_child3.getComputedLeft()).toBe(62)
2679
+ expect(root_child3.getComputedTop()).toBe(178)
2680
+ expect(root_child3.getComputedWidth()).toBe(100)
2681
+ expect(root_child3.getComputedHeight()).toBe(100)
2682
+
2683
+ expect(root_child4.getComputedLeft()).toBe(190)
2684
+ expect(root_child4.getComputedTop()).toBe(346)
2685
+ expect(root_child4.getComputedWidth()).toBe(100)
2686
+ expect(root_child4.getComputedHeight()).toBe(100)
2687
+ } finally {
2688
+ if (typeof root !== "undefined") {
2689
+ root.freeRecursive()
2690
+ }
2691
+
2692
+ config.free()
2693
+ }
2694
+ })
2695
+ test("row_gap_percent_wrapping_with_both_content_padding", () => {
2696
+ const config = Yoga.Config.create()
2697
+ let root
2698
+
2699
+ try {
2700
+ root = Yoga.Node.create(config)
2701
+ root.setFlexDirection(FlexDirection.Row)
2702
+ root.setPositionType(PositionType.Absolute)
2703
+ root.setFlexWrap(Wrap.Wrap)
2704
+ root.setPadding(Edge.Left, 10)
2705
+ root.setPadding(Edge.Top, 10)
2706
+ root.setPadding(Edge.Right, 10)
2707
+ root.setPadding(Edge.Bottom, 10)
2708
+ root.setWidth(300)
2709
+ root.setHeight(700)
2710
+ root.setGap(Gutter.Column, "10%")
2711
+ root.setGap(Gutter.Row, "10%")
2712
+
2713
+ const root_child0 = Yoga.Node.create(config)
2714
+ root_child0.setWidth(100)
2715
+ root_child0.setHeight(100)
2716
+ root.insertChild(root_child0, 0)
2717
+
2718
+ const root_child1 = Yoga.Node.create(config)
2719
+ root_child1.setWidth(100)
2720
+ root_child1.setHeight(100)
2721
+ root.insertChild(root_child1, 1)
2722
+
2723
+ const root_child2 = Yoga.Node.create(config)
2724
+ root_child2.setWidth(100)
2725
+ root_child2.setHeight(100)
2726
+ root.insertChild(root_child2, 2)
2727
+
2728
+ const root_child3 = Yoga.Node.create(config)
2729
+ root_child3.setWidth(100)
2730
+ root_child3.setHeight(100)
2731
+ root.insertChild(root_child3, 3)
2732
+
2733
+ const root_child4 = Yoga.Node.create(config)
2734
+ root_child4.setWidth(100)
2735
+ root_child4.setHeight(100)
2736
+ root.insertChild(root_child4, 4)
2737
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2738
+
2739
+ expect(root.getComputedLeft()).toBe(0)
2740
+ expect(root.getComputedTop()).toBe(0)
2741
+ expect(root.getComputedWidth()).toBe(300)
2742
+ expect(root.getComputedHeight()).toBe(700)
2743
+
2744
+ expect(root_child0.getComputedLeft()).toBe(10)
2745
+ expect(root_child0.getComputedTop()).toBe(10)
2746
+ expect(root_child0.getComputedWidth()).toBe(100)
2747
+ expect(root_child0.getComputedHeight()).toBe(100)
2748
+
2749
+ expect(root_child1.getComputedLeft()).toBe(138)
2750
+ expect(root_child1.getComputedTop()).toBe(10)
2751
+ expect(root_child1.getComputedWidth()).toBe(100)
2752
+ expect(root_child1.getComputedHeight()).toBe(100)
2753
+
2754
+ expect(root_child2.getComputedLeft()).toBe(10)
2755
+ expect(root_child2.getComputedTop()).toBe(178)
2756
+ expect(root_child2.getComputedWidth()).toBe(100)
2757
+ expect(root_child2.getComputedHeight()).toBe(100)
2758
+
2759
+ expect(root_child3.getComputedLeft()).toBe(138)
2760
+ expect(root_child3.getComputedTop()).toBe(178)
2761
+ expect(root_child3.getComputedWidth()).toBe(100)
2762
+ expect(root_child3.getComputedHeight()).toBe(100)
2763
+
2764
+ expect(root_child4.getComputedLeft()).toBe(10)
2765
+ expect(root_child4.getComputedTop()).toBe(346)
2766
+ expect(root_child4.getComputedWidth()).toBe(100)
2767
+ expect(root_child4.getComputedHeight()).toBe(100)
2768
+
2769
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2770
+
2771
+ expect(root.getComputedLeft()).toBe(0)
2772
+ expect(root.getComputedTop()).toBe(0)
2773
+ expect(root.getComputedWidth()).toBe(300)
2774
+ expect(root.getComputedHeight()).toBe(700)
2775
+
2776
+ expect(root_child0.getComputedLeft()).toBe(190)
2777
+ expect(root_child0.getComputedTop()).toBe(10)
2778
+ expect(root_child0.getComputedWidth()).toBe(100)
2779
+ expect(root_child0.getComputedHeight()).toBe(100)
2780
+
2781
+ expect(root_child1.getComputedLeft()).toBe(62)
2782
+ expect(root_child1.getComputedTop()).toBe(10)
2783
+ expect(root_child1.getComputedWidth()).toBe(100)
2784
+ expect(root_child1.getComputedHeight()).toBe(100)
2785
+
2786
+ expect(root_child2.getComputedLeft()).toBe(190)
2787
+ expect(root_child2.getComputedTop()).toBe(178)
2788
+ expect(root_child2.getComputedWidth()).toBe(100)
2789
+ expect(root_child2.getComputedHeight()).toBe(100)
2790
+
2791
+ expect(root_child3.getComputedLeft()).toBe(62)
2792
+ expect(root_child3.getComputedTop()).toBe(178)
2793
+ expect(root_child3.getComputedWidth()).toBe(100)
2794
+ expect(root_child3.getComputedHeight()).toBe(100)
2795
+
2796
+ expect(root_child4.getComputedLeft()).toBe(190)
2797
+ expect(root_child4.getComputedTop()).toBe(346)
2798
+ expect(root_child4.getComputedWidth()).toBe(100)
2799
+ expect(root_child4.getComputedHeight()).toBe(100)
2800
+ } finally {
2801
+ if (typeof root !== "undefined") {
2802
+ root.freeRecursive()
2803
+ }
2804
+
2805
+ config.free()
2806
+ }
2807
+ })
2808
+ test("row_gap_percent_wrapping_with_content_margin", () => {
2809
+ const config = Yoga.Config.create()
2810
+ let root
2811
+
2812
+ try {
2813
+ root = Yoga.Node.create(config)
2814
+ root.setFlexDirection(FlexDirection.Row)
2815
+ root.setPositionType(PositionType.Absolute)
2816
+ root.setFlexWrap(Wrap.Wrap)
2817
+ root.setMargin(Edge.Left, 10)
2818
+ root.setMargin(Edge.Top, 10)
2819
+ root.setMargin(Edge.Right, 10)
2820
+ root.setMargin(Edge.Bottom, 10)
2821
+ root.setWidth(300)
2822
+ root.setHeight(700)
2823
+ root.setGap(Gutter.Column, "10%")
2824
+ root.setGap(Gutter.Row, "10%")
2825
+
2826
+ const root_child0 = Yoga.Node.create(config)
2827
+ root_child0.setWidth(100)
2828
+ root_child0.setHeight(100)
2829
+ root.insertChild(root_child0, 0)
2830
+
2831
+ const root_child1 = Yoga.Node.create(config)
2832
+ root_child1.setWidth(100)
2833
+ root_child1.setHeight(100)
2834
+ root.insertChild(root_child1, 1)
2835
+
2836
+ const root_child2 = Yoga.Node.create(config)
2837
+ root_child2.setWidth(100)
2838
+ root_child2.setHeight(100)
2839
+ root.insertChild(root_child2, 2)
2840
+
2841
+ const root_child3 = Yoga.Node.create(config)
2842
+ root_child3.setWidth(100)
2843
+ root_child3.setHeight(100)
2844
+ root.insertChild(root_child3, 3)
2845
+
2846
+ const root_child4 = Yoga.Node.create(config)
2847
+ root_child4.setWidth(100)
2848
+ root_child4.setHeight(100)
2849
+ root.insertChild(root_child4, 4)
2850
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2851
+
2852
+ expect(root.getComputedLeft()).toBe(10)
2853
+ expect(root.getComputedTop()).toBe(10)
2854
+ expect(root.getComputedWidth()).toBe(300)
2855
+ expect(root.getComputedHeight()).toBe(700)
2856
+
2857
+ expect(root_child0.getComputedLeft()).toBe(0)
2858
+ expect(root_child0.getComputedTop()).toBe(0)
2859
+ expect(root_child0.getComputedWidth()).toBe(100)
2860
+ expect(root_child0.getComputedHeight()).toBe(100)
2861
+
2862
+ expect(root_child1.getComputedLeft()).toBe(130)
2863
+ expect(root_child1.getComputedTop()).toBe(0)
2864
+ expect(root_child1.getComputedWidth()).toBe(100)
2865
+ expect(root_child1.getComputedHeight()).toBe(100)
2866
+
2867
+ expect(root_child2.getComputedLeft()).toBe(0)
2868
+ expect(root_child2.getComputedTop()).toBe(170)
2869
+ expect(root_child2.getComputedWidth()).toBe(100)
2870
+ expect(root_child2.getComputedHeight()).toBe(100)
2871
+
2872
+ expect(root_child3.getComputedLeft()).toBe(130)
2873
+ expect(root_child3.getComputedTop()).toBe(170)
2874
+ expect(root_child3.getComputedWidth()).toBe(100)
2875
+ expect(root_child3.getComputedHeight()).toBe(100)
2876
+
2877
+ expect(root_child4.getComputedLeft()).toBe(0)
2878
+ expect(root_child4.getComputedTop()).toBe(340)
2879
+ expect(root_child4.getComputedWidth()).toBe(100)
2880
+ expect(root_child4.getComputedHeight()).toBe(100)
2881
+
2882
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2883
+
2884
+ expect(root.getComputedLeft()).toBe(10)
2885
+ expect(root.getComputedTop()).toBe(10)
2886
+ expect(root.getComputedWidth()).toBe(300)
2887
+ expect(root.getComputedHeight()).toBe(700)
2888
+
2889
+ expect(root_child0.getComputedLeft()).toBe(200)
2890
+ expect(root_child0.getComputedTop()).toBe(0)
2891
+ expect(root_child0.getComputedWidth()).toBe(100)
2892
+ expect(root_child0.getComputedHeight()).toBe(100)
2893
+
2894
+ expect(root_child1.getComputedLeft()).toBe(70)
2895
+ expect(root_child1.getComputedTop()).toBe(0)
2896
+ expect(root_child1.getComputedWidth()).toBe(100)
2897
+ expect(root_child1.getComputedHeight()).toBe(100)
2898
+
2899
+ expect(root_child2.getComputedLeft()).toBe(200)
2900
+ expect(root_child2.getComputedTop()).toBe(170)
2901
+ expect(root_child2.getComputedWidth()).toBe(100)
2902
+ expect(root_child2.getComputedHeight()).toBe(100)
2903
+
2904
+ expect(root_child3.getComputedLeft()).toBe(70)
2905
+ expect(root_child3.getComputedTop()).toBe(170)
2906
+ expect(root_child3.getComputedWidth()).toBe(100)
2907
+ expect(root_child3.getComputedHeight()).toBe(100)
2908
+
2909
+ expect(root_child4.getComputedLeft()).toBe(200)
2910
+ expect(root_child4.getComputedTop()).toBe(340)
2911
+ expect(root_child4.getComputedWidth()).toBe(100)
2912
+ expect(root_child4.getComputedHeight()).toBe(100)
2913
+ } finally {
2914
+ if (typeof root !== "undefined") {
2915
+ root.freeRecursive()
2916
+ }
2917
+
2918
+ config.free()
2919
+ }
2920
+ })
2921
+ test("row_gap_percent_wrapping_with_content_margin_and_padding", () => {
2922
+ const config = Yoga.Config.create()
2923
+ let root
2924
+
2925
+ try {
2926
+ root = Yoga.Node.create(config)
2927
+ root.setFlexDirection(FlexDirection.Row)
2928
+ root.setPositionType(PositionType.Absolute)
2929
+ root.setFlexWrap(Wrap.Wrap)
2930
+ root.setMargin(Edge.Left, 10)
2931
+ root.setMargin(Edge.Top, 10)
2932
+ root.setMargin(Edge.Right, 10)
2933
+ root.setMargin(Edge.Bottom, 10)
2934
+ root.setPadding(Edge.Left, 10)
2935
+ root.setPadding(Edge.Top, 10)
2936
+ root.setPadding(Edge.Right, 10)
2937
+ root.setPadding(Edge.Bottom, 10)
2938
+ root.setWidth(300)
2939
+ root.setHeight(700)
2940
+ root.setGap(Gutter.Column, "10%")
2941
+ root.setGap(Gutter.Row, "10%")
2942
+
2943
+ const root_child0 = Yoga.Node.create(config)
2944
+ root_child0.setWidth(100)
2945
+ root_child0.setHeight(100)
2946
+ root.insertChild(root_child0, 0)
2947
+
2948
+ const root_child1 = Yoga.Node.create(config)
2949
+ root_child1.setWidth(100)
2950
+ root_child1.setHeight(100)
2951
+ root.insertChild(root_child1, 1)
2952
+
2953
+ const root_child2 = Yoga.Node.create(config)
2954
+ root_child2.setWidth(100)
2955
+ root_child2.setHeight(100)
2956
+ root.insertChild(root_child2, 2)
2957
+
2958
+ const root_child3 = Yoga.Node.create(config)
2959
+ root_child3.setWidth(100)
2960
+ root_child3.setHeight(100)
2961
+ root.insertChild(root_child3, 3)
2962
+
2963
+ const root_child4 = Yoga.Node.create(config)
2964
+ root_child4.setWidth(100)
2965
+ root_child4.setHeight(100)
2966
+ root.insertChild(root_child4, 4)
2967
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2968
+
2969
+ expect(root.getComputedLeft()).toBe(10)
2970
+ expect(root.getComputedTop()).toBe(10)
2971
+ expect(root.getComputedWidth()).toBe(300)
2972
+ expect(root.getComputedHeight()).toBe(700)
2973
+
2974
+ expect(root_child0.getComputedLeft()).toBe(10)
2975
+ expect(root_child0.getComputedTop()).toBe(10)
2976
+ expect(root_child0.getComputedWidth()).toBe(100)
2977
+ expect(root_child0.getComputedHeight()).toBe(100)
2978
+
2979
+ expect(root_child1.getComputedLeft()).toBe(138)
2980
+ expect(root_child1.getComputedTop()).toBe(10)
2981
+ expect(root_child1.getComputedWidth()).toBe(100)
2982
+ expect(root_child1.getComputedHeight()).toBe(100)
2983
+
2984
+ expect(root_child2.getComputedLeft()).toBe(10)
2985
+ expect(root_child2.getComputedTop()).toBe(178)
2986
+ expect(root_child2.getComputedWidth()).toBe(100)
2987
+ expect(root_child2.getComputedHeight()).toBe(100)
2988
+
2989
+ expect(root_child3.getComputedLeft()).toBe(138)
2990
+ expect(root_child3.getComputedTop()).toBe(178)
2991
+ expect(root_child3.getComputedWidth()).toBe(100)
2992
+ expect(root_child3.getComputedHeight()).toBe(100)
2993
+
2994
+ expect(root_child4.getComputedLeft()).toBe(10)
2995
+ expect(root_child4.getComputedTop()).toBe(346)
2996
+ expect(root_child4.getComputedWidth()).toBe(100)
2997
+ expect(root_child4.getComputedHeight()).toBe(100)
2998
+
2999
+ root.calculateLayout(undefined, undefined, Direction.RTL)
3000
+
3001
+ expect(root.getComputedLeft()).toBe(10)
3002
+ expect(root.getComputedTop()).toBe(10)
3003
+ expect(root.getComputedWidth()).toBe(300)
3004
+ expect(root.getComputedHeight()).toBe(700)
3005
+
3006
+ expect(root_child0.getComputedLeft()).toBe(190)
3007
+ expect(root_child0.getComputedTop()).toBe(10)
3008
+ expect(root_child0.getComputedWidth()).toBe(100)
3009
+ expect(root_child0.getComputedHeight()).toBe(100)
3010
+
3011
+ expect(root_child1.getComputedLeft()).toBe(62)
3012
+ expect(root_child1.getComputedTop()).toBe(10)
3013
+ expect(root_child1.getComputedWidth()).toBe(100)
3014
+ expect(root_child1.getComputedHeight()).toBe(100)
3015
+
3016
+ expect(root_child2.getComputedLeft()).toBe(190)
3017
+ expect(root_child2.getComputedTop()).toBe(178)
3018
+ expect(root_child2.getComputedWidth()).toBe(100)
3019
+ expect(root_child2.getComputedHeight()).toBe(100)
3020
+
3021
+ expect(root_child3.getComputedLeft()).toBe(62)
3022
+ expect(root_child3.getComputedTop()).toBe(178)
3023
+ expect(root_child3.getComputedWidth()).toBe(100)
3024
+ expect(root_child3.getComputedHeight()).toBe(100)
3025
+
3026
+ expect(root_child4.getComputedLeft()).toBe(190)
3027
+ expect(root_child4.getComputedTop()).toBe(346)
3028
+ expect(root_child4.getComputedWidth()).toBe(100)
3029
+ expect(root_child4.getComputedHeight()).toBe(100)
3030
+ } finally {
3031
+ if (typeof root !== "undefined") {
3032
+ root.freeRecursive()
3033
+ }
3034
+
3035
+ config.free()
3036
+ }
3037
+ })
3038
+ test("row_gap_percent_wrapping_with_flexible_content", () => {
3039
+ const config = Yoga.Config.create()
3040
+ let root
3041
+
3042
+ try {
3043
+ root = Yoga.Node.create(config)
3044
+ root.setFlexDirection(FlexDirection.Row)
3045
+ root.setPositionType(PositionType.Absolute)
3046
+ root.setWidth(300)
3047
+ root.setHeight(300)
3048
+ root.setGap(Gutter.Column, "10%")
3049
+ root.setGap(Gutter.Row, "10%")
3050
+
3051
+ const root_child0 = Yoga.Node.create(config)
3052
+ root_child0.setFlexGrow(1)
3053
+ root_child0.setFlexShrink(1)
3054
+ root_child0.setFlexBasis("0%")
3055
+ root.insertChild(root_child0, 0)
3056
+
3057
+ const root_child1 = Yoga.Node.create(config)
3058
+ root_child1.setFlexGrow(1)
3059
+ root_child1.setFlexShrink(1)
3060
+ root_child1.setFlexBasis("0%")
3061
+ root.insertChild(root_child1, 1)
3062
+
3063
+ const root_child2 = Yoga.Node.create(config)
3064
+ root_child2.setFlexGrow(1)
3065
+ root_child2.setFlexShrink(1)
3066
+ root_child2.setFlexBasis("0%")
3067
+ root.insertChild(root_child2, 2)
3068
+ root.calculateLayout(undefined, undefined, Direction.LTR)
3069
+
3070
+ expect(root.getComputedLeft()).toBe(0)
3071
+ expect(root.getComputedTop()).toBe(0)
3072
+ expect(root.getComputedWidth()).toBe(300)
3073
+ expect(root.getComputedHeight()).toBe(300)
3074
+
3075
+ expect(root_child0.getComputedLeft()).toBe(0)
3076
+ expect(root_child0.getComputedTop()).toBe(0)
3077
+ expect(root_child0.getComputedWidth()).toBe(80)
3078
+ expect(root_child0.getComputedHeight()).toBe(300)
3079
+
3080
+ expect(root_child1.getComputedLeft()).toBe(110)
3081
+ expect(root_child1.getComputedTop()).toBe(0)
3082
+ expect(root_child1.getComputedWidth()).toBe(80)
3083
+ expect(root_child1.getComputedHeight()).toBe(300)
3084
+
3085
+ expect(root_child2.getComputedLeft()).toBe(220)
3086
+ expect(root_child2.getComputedTop()).toBe(0)
3087
+ expect(root_child2.getComputedWidth()).toBe(80)
3088
+ expect(root_child2.getComputedHeight()).toBe(300)
3089
+
3090
+ root.calculateLayout(undefined, undefined, Direction.RTL)
3091
+
3092
+ expect(root.getComputedLeft()).toBe(0)
3093
+ expect(root.getComputedTop()).toBe(0)
3094
+ expect(root.getComputedWidth()).toBe(300)
3095
+ expect(root.getComputedHeight()).toBe(300)
3096
+
3097
+ expect(root_child0.getComputedLeft()).toBe(220)
3098
+ expect(root_child0.getComputedTop()).toBe(0)
3099
+ expect(root_child0.getComputedWidth()).toBe(80)
3100
+ expect(root_child0.getComputedHeight()).toBe(300)
3101
+
3102
+ expect(root_child1.getComputedLeft()).toBe(110)
3103
+ expect(root_child1.getComputedTop()).toBe(0)
3104
+ expect(root_child1.getComputedWidth()).toBe(80)
3105
+ expect(root_child1.getComputedHeight()).toBe(300)
3106
+
3107
+ expect(root_child2.getComputedLeft()).toBe(0)
3108
+ expect(root_child2.getComputedTop()).toBe(0)
3109
+ expect(root_child2.getComputedWidth()).toBe(80)
3110
+ expect(root_child2.getComputedHeight()).toBe(300)
3111
+ } finally {
3112
+ if (typeof root !== "undefined") {
3113
+ root.freeRecursive()
3114
+ }
3115
+
3116
+ config.free()
3117
+ }
3118
+ })
3119
+ test("row_gap_percent_wrapping_with_mixed_flexible_content", () => {
3120
+ const config = Yoga.Config.create()
3121
+ let root
3122
+
3123
+ try {
3124
+ root = Yoga.Node.create(config)
3125
+ root.setFlexDirection(FlexDirection.Row)
3126
+ root.setPositionType(PositionType.Absolute)
3127
+ root.setWidth(300)
3128
+ root.setHeight(300)
3129
+ root.setGap(Gutter.Column, "10%")
3130
+ root.setGap(Gutter.Row, "10%")
3131
+
3132
+ const root_child0 = Yoga.Node.create(config)
3133
+ root_child0.setWidth(10)
3134
+ root.insertChild(root_child0, 0)
3135
+
3136
+ const root_child1 = Yoga.Node.create(config)
3137
+ root_child1.setFlexGrow(1)
3138
+ root_child1.setFlexShrink(1)
3139
+ root_child1.setFlexBasis("0%")
3140
+ root.insertChild(root_child1, 1)
3141
+
3142
+ const root_child2 = Yoga.Node.create(config)
3143
+ root_child2.setWidth("10%")
3144
+ root.insertChild(root_child2, 2)
3145
+ root.calculateLayout(undefined, undefined, Direction.LTR)
3146
+
3147
+ expect(root.getComputedLeft()).toBe(0)
3148
+ expect(root.getComputedTop()).toBe(0)
3149
+ expect(root.getComputedWidth()).toBe(300)
3150
+ expect(root.getComputedHeight()).toBe(300)
3151
+
3152
+ expect(root_child0.getComputedLeft()).toBe(0)
3153
+ expect(root_child0.getComputedTop()).toBe(0)
3154
+ expect(root_child0.getComputedWidth()).toBe(10)
3155
+ expect(root_child0.getComputedHeight()).toBe(300)
3156
+
3157
+ expect(root_child1.getComputedLeft()).toBe(40)
3158
+ expect(root_child1.getComputedTop()).toBe(0)
3159
+ expect(root_child1.getComputedWidth()).toBe(200)
3160
+ expect(root_child1.getComputedHeight()).toBe(300)
3161
+
3162
+ expect(root_child2.getComputedLeft()).toBe(270)
3163
+ expect(root_child2.getComputedTop()).toBe(0)
3164
+ expect(root_child2.getComputedWidth()).toBe(30)
3165
+ expect(root_child2.getComputedHeight()).toBe(300)
3166
+
3167
+ root.calculateLayout(undefined, undefined, Direction.RTL)
3168
+
3169
+ expect(root.getComputedLeft()).toBe(0)
3170
+ expect(root.getComputedTop()).toBe(0)
3171
+ expect(root.getComputedWidth()).toBe(300)
3172
+ expect(root.getComputedHeight()).toBe(300)
3173
+
3174
+ expect(root_child0.getComputedLeft()).toBe(290)
3175
+ expect(root_child0.getComputedTop()).toBe(0)
3176
+ expect(root_child0.getComputedWidth()).toBe(10)
3177
+ expect(root_child0.getComputedHeight()).toBe(300)
3178
+
3179
+ expect(root_child1.getComputedLeft()).toBe(60)
3180
+ expect(root_child1.getComputedTop()).toBe(0)
3181
+ expect(root_child1.getComputedWidth()).toBe(200)
3182
+ expect(root_child1.getComputedHeight()).toBe(300)
3183
+
3184
+ expect(root_child2.getComputedLeft()).toBe(0)
3185
+ expect(root_child2.getComputedTop()).toBe(0)
3186
+ expect(root_child2.getComputedWidth()).toBe(30)
3187
+ expect(root_child2.getComputedHeight()).toBe(300)
3188
+ } finally {
3189
+ if (typeof root !== "undefined") {
3190
+ root.freeRecursive()
3191
+ }
3192
+
3193
+ config.free()
3194
+ }
3195
+ })
3196
+ test.skip("row_gap_percent_wrapping_with_min_width", () => {
3197
+ const config = Yoga.Config.create()
3198
+ let root
3199
+
3200
+ try {
3201
+ root = Yoga.Node.create(config)
3202
+ root.setFlexDirection(FlexDirection.Row)
3203
+ root.setPositionType(PositionType.Absolute)
3204
+ root.setFlexWrap(Wrap.Wrap)
3205
+ root.setMinWidth(300)
3206
+ root.setGap(Gutter.Column, "10%")
3207
+ root.setGap(Gutter.Row, "10%")
3208
+
3209
+ const root_child0 = Yoga.Node.create(config)
3210
+ root_child0.setWidth(100)
3211
+ root_child0.setHeight(100)
3212
+ root.insertChild(root_child0, 0)
3213
+
3214
+ const root_child1 = Yoga.Node.create(config)
3215
+ root_child1.setWidth(100)
3216
+ root_child1.setHeight(100)
3217
+ root.insertChild(root_child1, 1)
3218
+
3219
+ const root_child2 = Yoga.Node.create(config)
3220
+ root_child2.setWidth(100)
3221
+ root_child2.setHeight(100)
3222
+ root.insertChild(root_child2, 2)
3223
+
3224
+ const root_child3 = Yoga.Node.create(config)
3225
+ root_child3.setWidth(100)
3226
+ root_child3.setHeight(100)
3227
+ root.insertChild(root_child3, 3)
3228
+
3229
+ const root_child4 = Yoga.Node.create(config)
3230
+ root_child4.setWidth(100)
3231
+ root_child4.setHeight(100)
3232
+ root.insertChild(root_child4, 4)
3233
+ root.calculateLayout(undefined, undefined, Direction.LTR)
3234
+
3235
+ expect(root.getComputedLeft()).toBe(0)
3236
+ expect(root.getComputedTop()).toBe(0)
3237
+ expect(root.getComputedWidth()).toBe(300)
3238
+ expect(root.getComputedHeight()).toBe(300)
3239
+
3240
+ expect(root_child0.getComputedLeft()).toBe(0)
3241
+ expect(root_child0.getComputedTop()).toBe(0)
3242
+ expect(root_child0.getComputedWidth()).toBe(100)
3243
+ expect(root_child0.getComputedHeight()).toBe(100)
3244
+
3245
+ expect(root_child1.getComputedLeft()).toBe(130)
3246
+ expect(root_child1.getComputedTop()).toBe(0)
3247
+ expect(root_child1.getComputedWidth()).toBe(100)
3248
+ expect(root_child1.getComputedHeight()).toBe(100)
3249
+
3250
+ expect(root_child2.getComputedLeft()).toBe(0)
3251
+ expect(root_child2.getComputedTop()).toBe(100)
3252
+ expect(root_child2.getComputedWidth()).toBe(100)
3253
+ expect(root_child2.getComputedHeight()).toBe(100)
3254
+
3255
+ expect(root_child3.getComputedLeft()).toBe(130)
3256
+ expect(root_child3.getComputedTop()).toBe(100)
3257
+ expect(root_child3.getComputedWidth()).toBe(100)
3258
+ expect(root_child3.getComputedHeight()).toBe(100)
3259
+
3260
+ expect(root_child4.getComputedLeft()).toBe(0)
3261
+ expect(root_child4.getComputedTop()).toBe(200)
3262
+ expect(root_child4.getComputedWidth()).toBe(100)
3263
+ expect(root_child4.getComputedHeight()).toBe(100)
3264
+
3265
+ root.calculateLayout(undefined, undefined, Direction.RTL)
3266
+
3267
+ expect(root.getComputedLeft()).toBe(0)
3268
+ expect(root.getComputedTop()).toBe(0)
3269
+ expect(root.getComputedWidth()).toBe(300)
3270
+ expect(root.getComputedHeight()).toBe(300)
3271
+
3272
+ expect(root_child0.getComputedLeft()).toBe(200)
3273
+ expect(root_child0.getComputedTop()).toBe(0)
3274
+ expect(root_child0.getComputedWidth()).toBe(100)
3275
+ expect(root_child0.getComputedHeight()).toBe(100)
3276
+
3277
+ expect(root_child1.getComputedLeft()).toBe(70)
3278
+ expect(root_child1.getComputedTop()).toBe(0)
3279
+ expect(root_child1.getComputedWidth()).toBe(100)
3280
+ expect(root_child1.getComputedHeight()).toBe(100)
3281
+
3282
+ expect(root_child2.getComputedLeft()).toBe(200)
3283
+ expect(root_child2.getComputedTop()).toBe(100)
3284
+ expect(root_child2.getComputedWidth()).toBe(100)
3285
+ expect(root_child2.getComputedHeight()).toBe(100)
3286
+
3287
+ expect(root_child3.getComputedLeft()).toBe(70)
3288
+ expect(root_child3.getComputedTop()).toBe(100)
3289
+ expect(root_child3.getComputedWidth()).toBe(100)
3290
+ expect(root_child3.getComputedHeight()).toBe(100)
3291
+
3292
+ expect(root_child4.getComputedLeft()).toBe(200)
3293
+ expect(root_child4.getComputedTop()).toBe(200)
3294
+ expect(root_child4.getComputedWidth()).toBe(100)
3295
+ expect(root_child4.getComputedHeight()).toBe(100)
3296
+ } finally {
3297
+ if (typeof root !== "undefined") {
3298
+ root.freeRecursive()
3299
+ }
3300
+
3301
+ config.free()
3302
+ }
3303
+ })