@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,2444 @@
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<<075a0b67003e5c4a1f51bd99da71c700>>
8
+ * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.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("align_items_stretch", () => {
32
+ const config = Yoga.Config.create()
33
+ let root
34
+
35
+ try {
36
+ root = Yoga.Node.create(config)
37
+ root.setPositionType(PositionType.Absolute)
38
+ root.setWidth(100)
39
+ root.setHeight(100)
40
+
41
+ const root_child0 = Yoga.Node.create(config)
42
+ root_child0.setHeight(10)
43
+ root.insertChild(root_child0, 0)
44
+ root.calculateLayout(undefined, undefined, Direction.LTR)
45
+
46
+ expect(root.getComputedLeft()).toBe(0)
47
+ expect(root.getComputedTop()).toBe(0)
48
+ expect(root.getComputedWidth()).toBe(100)
49
+ expect(root.getComputedHeight()).toBe(100)
50
+
51
+ expect(root_child0.getComputedLeft()).toBe(0)
52
+ expect(root_child0.getComputedTop()).toBe(0)
53
+ expect(root_child0.getComputedWidth()).toBe(100)
54
+ expect(root_child0.getComputedHeight()).toBe(10)
55
+
56
+ root.calculateLayout(undefined, undefined, Direction.RTL)
57
+
58
+ expect(root.getComputedLeft()).toBe(0)
59
+ expect(root.getComputedTop()).toBe(0)
60
+ expect(root.getComputedWidth()).toBe(100)
61
+ expect(root.getComputedHeight()).toBe(100)
62
+
63
+ expect(root_child0.getComputedLeft()).toBe(0)
64
+ expect(root_child0.getComputedTop()).toBe(0)
65
+ expect(root_child0.getComputedWidth()).toBe(100)
66
+ expect(root_child0.getComputedHeight()).toBe(10)
67
+ } finally {
68
+ if (typeof root !== "undefined") {
69
+ root.freeRecursive()
70
+ }
71
+
72
+ config.free()
73
+ }
74
+ })
75
+ test("align_items_center", () => {
76
+ const config = Yoga.Config.create()
77
+ let root
78
+
79
+ try {
80
+ root = Yoga.Node.create(config)
81
+ root.setAlignItems(Align.Center)
82
+ root.setPositionType(PositionType.Absolute)
83
+ root.setWidth(100)
84
+ root.setHeight(100)
85
+
86
+ const root_child0 = Yoga.Node.create(config)
87
+ root_child0.setWidth(10)
88
+ root_child0.setHeight(10)
89
+ root.insertChild(root_child0, 0)
90
+ root.calculateLayout(undefined, undefined, Direction.LTR)
91
+
92
+ expect(root.getComputedLeft()).toBe(0)
93
+ expect(root.getComputedTop()).toBe(0)
94
+ expect(root.getComputedWidth()).toBe(100)
95
+ expect(root.getComputedHeight()).toBe(100)
96
+
97
+ expect(root_child0.getComputedLeft()).toBe(45)
98
+ expect(root_child0.getComputedTop()).toBe(0)
99
+ expect(root_child0.getComputedWidth()).toBe(10)
100
+ expect(root_child0.getComputedHeight()).toBe(10)
101
+
102
+ root.calculateLayout(undefined, undefined, Direction.RTL)
103
+
104
+ expect(root.getComputedLeft()).toBe(0)
105
+ expect(root.getComputedTop()).toBe(0)
106
+ expect(root.getComputedWidth()).toBe(100)
107
+ expect(root.getComputedHeight()).toBe(100)
108
+
109
+ expect(root_child0.getComputedLeft()).toBe(45)
110
+ expect(root_child0.getComputedTop()).toBe(0)
111
+ expect(root_child0.getComputedWidth()).toBe(10)
112
+ expect(root_child0.getComputedHeight()).toBe(10)
113
+ } finally {
114
+ if (typeof root !== "undefined") {
115
+ root.freeRecursive()
116
+ }
117
+
118
+ config.free()
119
+ }
120
+ })
121
+ test("align_items_flex_start", () => {
122
+ const config = Yoga.Config.create()
123
+ let root
124
+
125
+ try {
126
+ root = Yoga.Node.create(config)
127
+ root.setAlignItems(Align.FlexStart)
128
+ root.setPositionType(PositionType.Absolute)
129
+ root.setWidth(100)
130
+ root.setHeight(100)
131
+
132
+ const root_child0 = Yoga.Node.create(config)
133
+ root_child0.setWidth(10)
134
+ root_child0.setHeight(10)
135
+ root.insertChild(root_child0, 0)
136
+ root.calculateLayout(undefined, undefined, Direction.LTR)
137
+
138
+ expect(root.getComputedLeft()).toBe(0)
139
+ expect(root.getComputedTop()).toBe(0)
140
+ expect(root.getComputedWidth()).toBe(100)
141
+ expect(root.getComputedHeight()).toBe(100)
142
+
143
+ expect(root_child0.getComputedLeft()).toBe(0)
144
+ expect(root_child0.getComputedTop()).toBe(0)
145
+ expect(root_child0.getComputedWidth()).toBe(10)
146
+ expect(root_child0.getComputedHeight()).toBe(10)
147
+
148
+ root.calculateLayout(undefined, undefined, Direction.RTL)
149
+
150
+ expect(root.getComputedLeft()).toBe(0)
151
+ expect(root.getComputedTop()).toBe(0)
152
+ expect(root.getComputedWidth()).toBe(100)
153
+ expect(root.getComputedHeight()).toBe(100)
154
+
155
+ expect(root_child0.getComputedLeft()).toBe(90)
156
+ expect(root_child0.getComputedTop()).toBe(0)
157
+ expect(root_child0.getComputedWidth()).toBe(10)
158
+ expect(root_child0.getComputedHeight()).toBe(10)
159
+ } finally {
160
+ if (typeof root !== "undefined") {
161
+ root.freeRecursive()
162
+ }
163
+
164
+ config.free()
165
+ }
166
+ })
167
+ test("align_items_flex_end", () => {
168
+ const config = Yoga.Config.create()
169
+ let root
170
+
171
+ try {
172
+ root = Yoga.Node.create(config)
173
+ root.setAlignItems(Align.FlexEnd)
174
+ root.setPositionType(PositionType.Absolute)
175
+ root.setWidth(100)
176
+ root.setHeight(100)
177
+
178
+ const root_child0 = Yoga.Node.create(config)
179
+ root_child0.setWidth(10)
180
+ root_child0.setHeight(10)
181
+ root.insertChild(root_child0, 0)
182
+ root.calculateLayout(undefined, undefined, Direction.LTR)
183
+
184
+ expect(root.getComputedLeft()).toBe(0)
185
+ expect(root.getComputedTop()).toBe(0)
186
+ expect(root.getComputedWidth()).toBe(100)
187
+ expect(root.getComputedHeight()).toBe(100)
188
+
189
+ expect(root_child0.getComputedLeft()).toBe(90)
190
+ expect(root_child0.getComputedTop()).toBe(0)
191
+ expect(root_child0.getComputedWidth()).toBe(10)
192
+ expect(root_child0.getComputedHeight()).toBe(10)
193
+
194
+ root.calculateLayout(undefined, undefined, Direction.RTL)
195
+
196
+ expect(root.getComputedLeft()).toBe(0)
197
+ expect(root.getComputedTop()).toBe(0)
198
+ expect(root.getComputedWidth()).toBe(100)
199
+ expect(root.getComputedHeight()).toBe(100)
200
+
201
+ expect(root_child0.getComputedLeft()).toBe(0)
202
+ expect(root_child0.getComputedTop()).toBe(0)
203
+ expect(root_child0.getComputedWidth()).toBe(10)
204
+ expect(root_child0.getComputedHeight()).toBe(10)
205
+ } finally {
206
+ if (typeof root !== "undefined") {
207
+ root.freeRecursive()
208
+ }
209
+
210
+ config.free()
211
+ }
212
+ })
213
+ test("align_baseline", () => {
214
+ const config = Yoga.Config.create()
215
+ let root
216
+
217
+ try {
218
+ root = Yoga.Node.create(config)
219
+ root.setFlexDirection(FlexDirection.Row)
220
+ root.setAlignItems(Align.Baseline)
221
+ root.setPositionType(PositionType.Absolute)
222
+ root.setWidth(100)
223
+ root.setHeight(100)
224
+
225
+ const root_child0 = Yoga.Node.create(config)
226
+ root_child0.setWidth(50)
227
+ root_child0.setHeight(50)
228
+ root.insertChild(root_child0, 0)
229
+
230
+ const root_child1 = Yoga.Node.create(config)
231
+ root_child1.setWidth(50)
232
+ root_child1.setHeight(20)
233
+ root.insertChild(root_child1, 1)
234
+ root.calculateLayout(undefined, undefined, Direction.LTR)
235
+
236
+ expect(root.getComputedLeft()).toBe(0)
237
+ expect(root.getComputedTop()).toBe(0)
238
+ expect(root.getComputedWidth()).toBe(100)
239
+ expect(root.getComputedHeight()).toBe(100)
240
+
241
+ expect(root_child0.getComputedLeft()).toBe(0)
242
+ expect(root_child0.getComputedTop()).toBe(0)
243
+ expect(root_child0.getComputedWidth()).toBe(50)
244
+ expect(root_child0.getComputedHeight()).toBe(50)
245
+
246
+ expect(root_child1.getComputedLeft()).toBe(50)
247
+ expect(root_child1.getComputedTop()).toBe(30)
248
+ expect(root_child1.getComputedWidth()).toBe(50)
249
+ expect(root_child1.getComputedHeight()).toBe(20)
250
+
251
+ root.calculateLayout(undefined, undefined, Direction.RTL)
252
+
253
+ expect(root.getComputedLeft()).toBe(0)
254
+ expect(root.getComputedTop()).toBe(0)
255
+ expect(root.getComputedWidth()).toBe(100)
256
+ expect(root.getComputedHeight()).toBe(100)
257
+
258
+ expect(root_child0.getComputedLeft()).toBe(50)
259
+ expect(root_child0.getComputedTop()).toBe(0)
260
+ expect(root_child0.getComputedWidth()).toBe(50)
261
+ expect(root_child0.getComputedHeight()).toBe(50)
262
+
263
+ expect(root_child1.getComputedLeft()).toBe(0)
264
+ expect(root_child1.getComputedTop()).toBe(30)
265
+ expect(root_child1.getComputedWidth()).toBe(50)
266
+ expect(root_child1.getComputedHeight()).toBe(20)
267
+ } finally {
268
+ if (typeof root !== "undefined") {
269
+ root.freeRecursive()
270
+ }
271
+
272
+ config.free()
273
+ }
274
+ })
275
+ test("align_baseline_child", () => {
276
+ const config = Yoga.Config.create()
277
+ let root
278
+
279
+ try {
280
+ root = Yoga.Node.create(config)
281
+ root.setFlexDirection(FlexDirection.Row)
282
+ root.setAlignItems(Align.Baseline)
283
+ root.setPositionType(PositionType.Absolute)
284
+ root.setWidth(100)
285
+ root.setHeight(100)
286
+
287
+ const root_child0 = Yoga.Node.create(config)
288
+ root_child0.setWidth(50)
289
+ root_child0.setHeight(50)
290
+ root.insertChild(root_child0, 0)
291
+
292
+ const root_child1 = Yoga.Node.create(config)
293
+ root_child1.setWidth(50)
294
+ root_child1.setHeight(20)
295
+ root.insertChild(root_child1, 1)
296
+
297
+ const root_child1_child0 = Yoga.Node.create(config)
298
+ root_child1_child0.setWidth(50)
299
+ root_child1_child0.setHeight(10)
300
+ root_child1.insertChild(root_child1_child0, 0)
301
+ root.calculateLayout(undefined, undefined, Direction.LTR)
302
+
303
+ expect(root.getComputedLeft()).toBe(0)
304
+ expect(root.getComputedTop()).toBe(0)
305
+ expect(root.getComputedWidth()).toBe(100)
306
+ expect(root.getComputedHeight()).toBe(100)
307
+
308
+ expect(root_child0.getComputedLeft()).toBe(0)
309
+ expect(root_child0.getComputedTop()).toBe(0)
310
+ expect(root_child0.getComputedWidth()).toBe(50)
311
+ expect(root_child0.getComputedHeight()).toBe(50)
312
+
313
+ expect(root_child1.getComputedLeft()).toBe(50)
314
+ expect(root_child1.getComputedTop()).toBe(40)
315
+ expect(root_child1.getComputedWidth()).toBe(50)
316
+ expect(root_child1.getComputedHeight()).toBe(20)
317
+
318
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
319
+ expect(root_child1_child0.getComputedTop()).toBe(0)
320
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
321
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
322
+
323
+ root.calculateLayout(undefined, undefined, Direction.RTL)
324
+
325
+ expect(root.getComputedLeft()).toBe(0)
326
+ expect(root.getComputedTop()).toBe(0)
327
+ expect(root.getComputedWidth()).toBe(100)
328
+ expect(root.getComputedHeight()).toBe(100)
329
+
330
+ expect(root_child0.getComputedLeft()).toBe(50)
331
+ expect(root_child0.getComputedTop()).toBe(0)
332
+ expect(root_child0.getComputedWidth()).toBe(50)
333
+ expect(root_child0.getComputedHeight()).toBe(50)
334
+
335
+ expect(root_child1.getComputedLeft()).toBe(0)
336
+ expect(root_child1.getComputedTop()).toBe(40)
337
+ expect(root_child1.getComputedWidth()).toBe(50)
338
+ expect(root_child1.getComputedHeight()).toBe(20)
339
+
340
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
341
+ expect(root_child1_child0.getComputedTop()).toBe(0)
342
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
343
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
344
+ } finally {
345
+ if (typeof root !== "undefined") {
346
+ root.freeRecursive()
347
+ }
348
+
349
+ config.free()
350
+ }
351
+ })
352
+ test("align_baseline_child_multiline", () => {
353
+ const config = Yoga.Config.create()
354
+ let root
355
+
356
+ try {
357
+ root = Yoga.Node.create(config)
358
+ root.setFlexDirection(FlexDirection.Row)
359
+ root.setAlignItems(Align.Baseline)
360
+ root.setPositionType(PositionType.Absolute)
361
+ root.setWidth(100)
362
+ root.setHeight(100)
363
+
364
+ const root_child0 = Yoga.Node.create(config)
365
+ root_child0.setWidth(50)
366
+ root_child0.setHeight(60)
367
+ root.insertChild(root_child0, 0)
368
+
369
+ const root_child1 = Yoga.Node.create(config)
370
+ root_child1.setFlexDirection(FlexDirection.Row)
371
+ root_child1.setFlexWrap(Wrap.Wrap)
372
+ root_child1.setWidth(50)
373
+ root_child1.setHeight(25)
374
+ root.insertChild(root_child1, 1)
375
+
376
+ const root_child1_child0 = Yoga.Node.create(config)
377
+ root_child1_child0.setWidth(25)
378
+ root_child1_child0.setHeight(20)
379
+ root_child1.insertChild(root_child1_child0, 0)
380
+
381
+ const root_child1_child1 = Yoga.Node.create(config)
382
+ root_child1_child1.setWidth(25)
383
+ root_child1_child1.setHeight(10)
384
+ root_child1.insertChild(root_child1_child1, 1)
385
+
386
+ const root_child1_child2 = Yoga.Node.create(config)
387
+ root_child1_child2.setWidth(25)
388
+ root_child1_child2.setHeight(20)
389
+ root_child1.insertChild(root_child1_child2, 2)
390
+
391
+ const root_child1_child3 = Yoga.Node.create(config)
392
+ root_child1_child3.setWidth(25)
393
+ root_child1_child3.setHeight(10)
394
+ root_child1.insertChild(root_child1_child3, 3)
395
+ root.calculateLayout(undefined, undefined, Direction.LTR)
396
+
397
+ expect(root.getComputedLeft()).toBe(0)
398
+ expect(root.getComputedTop()).toBe(0)
399
+ expect(root.getComputedWidth()).toBe(100)
400
+ expect(root.getComputedHeight()).toBe(100)
401
+
402
+ expect(root_child0.getComputedLeft()).toBe(0)
403
+ expect(root_child0.getComputedTop()).toBe(0)
404
+ expect(root_child0.getComputedWidth()).toBe(50)
405
+ expect(root_child0.getComputedHeight()).toBe(60)
406
+
407
+ expect(root_child1.getComputedLeft()).toBe(50)
408
+ expect(root_child1.getComputedTop()).toBe(40)
409
+ expect(root_child1.getComputedWidth()).toBe(50)
410
+ expect(root_child1.getComputedHeight()).toBe(25)
411
+
412
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
413
+ expect(root_child1_child0.getComputedTop()).toBe(0)
414
+ expect(root_child1_child0.getComputedWidth()).toBe(25)
415
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
416
+
417
+ expect(root_child1_child1.getComputedLeft()).toBe(25)
418
+ expect(root_child1_child1.getComputedTop()).toBe(0)
419
+ expect(root_child1_child1.getComputedWidth()).toBe(25)
420
+ expect(root_child1_child1.getComputedHeight()).toBe(10)
421
+
422
+ expect(root_child1_child2.getComputedLeft()).toBe(0)
423
+ expect(root_child1_child2.getComputedTop()).toBe(20)
424
+ expect(root_child1_child2.getComputedWidth()).toBe(25)
425
+ expect(root_child1_child2.getComputedHeight()).toBe(20)
426
+
427
+ expect(root_child1_child3.getComputedLeft()).toBe(25)
428
+ expect(root_child1_child3.getComputedTop()).toBe(20)
429
+ expect(root_child1_child3.getComputedWidth()).toBe(25)
430
+ expect(root_child1_child3.getComputedHeight()).toBe(10)
431
+
432
+ root.calculateLayout(undefined, undefined, Direction.RTL)
433
+
434
+ expect(root.getComputedLeft()).toBe(0)
435
+ expect(root.getComputedTop()).toBe(0)
436
+ expect(root.getComputedWidth()).toBe(100)
437
+ expect(root.getComputedHeight()).toBe(100)
438
+
439
+ expect(root_child0.getComputedLeft()).toBe(50)
440
+ expect(root_child0.getComputedTop()).toBe(0)
441
+ expect(root_child0.getComputedWidth()).toBe(50)
442
+ expect(root_child0.getComputedHeight()).toBe(60)
443
+
444
+ expect(root_child1.getComputedLeft()).toBe(0)
445
+ expect(root_child1.getComputedTop()).toBe(40)
446
+ expect(root_child1.getComputedWidth()).toBe(50)
447
+ expect(root_child1.getComputedHeight()).toBe(25)
448
+
449
+ expect(root_child1_child0.getComputedLeft()).toBe(25)
450
+ expect(root_child1_child0.getComputedTop()).toBe(0)
451
+ expect(root_child1_child0.getComputedWidth()).toBe(25)
452
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
453
+
454
+ expect(root_child1_child1.getComputedLeft()).toBe(0)
455
+ expect(root_child1_child1.getComputedTop()).toBe(0)
456
+ expect(root_child1_child1.getComputedWidth()).toBe(25)
457
+ expect(root_child1_child1.getComputedHeight()).toBe(10)
458
+
459
+ expect(root_child1_child2.getComputedLeft()).toBe(25)
460
+ expect(root_child1_child2.getComputedTop()).toBe(20)
461
+ expect(root_child1_child2.getComputedWidth()).toBe(25)
462
+ expect(root_child1_child2.getComputedHeight()).toBe(20)
463
+
464
+ expect(root_child1_child3.getComputedLeft()).toBe(0)
465
+ expect(root_child1_child3.getComputedTop()).toBe(20)
466
+ expect(root_child1_child3.getComputedWidth()).toBe(25)
467
+ expect(root_child1_child3.getComputedHeight()).toBe(10)
468
+ } finally {
469
+ if (typeof root !== "undefined") {
470
+ root.freeRecursive()
471
+ }
472
+
473
+ config.free()
474
+ }
475
+ })
476
+ test("align_baseline_child_multiline_override", () => {
477
+ const config = Yoga.Config.create()
478
+ let root
479
+
480
+ try {
481
+ root = Yoga.Node.create(config)
482
+ root.setFlexDirection(FlexDirection.Row)
483
+ root.setAlignItems(Align.Baseline)
484
+ root.setPositionType(PositionType.Absolute)
485
+ root.setWidth(100)
486
+ root.setHeight(100)
487
+
488
+ const root_child0 = Yoga.Node.create(config)
489
+ root_child0.setWidth(50)
490
+ root_child0.setHeight(60)
491
+ root.insertChild(root_child0, 0)
492
+
493
+ const root_child1 = Yoga.Node.create(config)
494
+ root_child1.setFlexDirection(FlexDirection.Row)
495
+ root_child1.setFlexWrap(Wrap.Wrap)
496
+ root_child1.setWidth(50)
497
+ root_child1.setHeight(25)
498
+ root.insertChild(root_child1, 1)
499
+
500
+ const root_child1_child0 = Yoga.Node.create(config)
501
+ root_child1_child0.setWidth(25)
502
+ root_child1_child0.setHeight(20)
503
+ root_child1.insertChild(root_child1_child0, 0)
504
+
505
+ const root_child1_child1 = Yoga.Node.create(config)
506
+ root_child1_child1.setAlignSelf(Align.Baseline)
507
+ root_child1_child1.setWidth(25)
508
+ root_child1_child1.setHeight(10)
509
+ root_child1.insertChild(root_child1_child1, 1)
510
+
511
+ const root_child1_child2 = Yoga.Node.create(config)
512
+ root_child1_child2.setWidth(25)
513
+ root_child1_child2.setHeight(20)
514
+ root_child1.insertChild(root_child1_child2, 2)
515
+
516
+ const root_child1_child3 = Yoga.Node.create(config)
517
+ root_child1_child3.setAlignSelf(Align.Baseline)
518
+ root_child1_child3.setWidth(25)
519
+ root_child1_child3.setHeight(10)
520
+ root_child1.insertChild(root_child1_child3, 3)
521
+ root.calculateLayout(undefined, undefined, Direction.LTR)
522
+
523
+ expect(root.getComputedLeft()).toBe(0)
524
+ expect(root.getComputedTop()).toBe(0)
525
+ expect(root.getComputedWidth()).toBe(100)
526
+ expect(root.getComputedHeight()).toBe(100)
527
+
528
+ expect(root_child0.getComputedLeft()).toBe(0)
529
+ expect(root_child0.getComputedTop()).toBe(0)
530
+ expect(root_child0.getComputedWidth()).toBe(50)
531
+ expect(root_child0.getComputedHeight()).toBe(60)
532
+
533
+ expect(root_child1.getComputedLeft()).toBe(50)
534
+ expect(root_child1.getComputedTop()).toBe(50)
535
+ expect(root_child1.getComputedWidth()).toBe(50)
536
+ expect(root_child1.getComputedHeight()).toBe(25)
537
+
538
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
539
+ expect(root_child1_child0.getComputedTop()).toBe(0)
540
+ expect(root_child1_child0.getComputedWidth()).toBe(25)
541
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
542
+
543
+ expect(root_child1_child1.getComputedLeft()).toBe(25)
544
+ expect(root_child1_child1.getComputedTop()).toBe(0)
545
+ expect(root_child1_child1.getComputedWidth()).toBe(25)
546
+ expect(root_child1_child1.getComputedHeight()).toBe(10)
547
+
548
+ expect(root_child1_child2.getComputedLeft()).toBe(0)
549
+ expect(root_child1_child2.getComputedTop()).toBe(20)
550
+ expect(root_child1_child2.getComputedWidth()).toBe(25)
551
+ expect(root_child1_child2.getComputedHeight()).toBe(20)
552
+
553
+ expect(root_child1_child3.getComputedLeft()).toBe(25)
554
+ expect(root_child1_child3.getComputedTop()).toBe(20)
555
+ expect(root_child1_child3.getComputedWidth()).toBe(25)
556
+ expect(root_child1_child3.getComputedHeight()).toBe(10)
557
+
558
+ root.calculateLayout(undefined, undefined, Direction.RTL)
559
+
560
+ expect(root.getComputedLeft()).toBe(0)
561
+ expect(root.getComputedTop()).toBe(0)
562
+ expect(root.getComputedWidth()).toBe(100)
563
+ expect(root.getComputedHeight()).toBe(100)
564
+
565
+ expect(root_child0.getComputedLeft()).toBe(50)
566
+ expect(root_child0.getComputedTop()).toBe(0)
567
+ expect(root_child0.getComputedWidth()).toBe(50)
568
+ expect(root_child0.getComputedHeight()).toBe(60)
569
+
570
+ expect(root_child1.getComputedLeft()).toBe(0)
571
+ expect(root_child1.getComputedTop()).toBe(50)
572
+ expect(root_child1.getComputedWidth()).toBe(50)
573
+ expect(root_child1.getComputedHeight()).toBe(25)
574
+
575
+ expect(root_child1_child0.getComputedLeft()).toBe(25)
576
+ expect(root_child1_child0.getComputedTop()).toBe(0)
577
+ expect(root_child1_child0.getComputedWidth()).toBe(25)
578
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
579
+
580
+ expect(root_child1_child1.getComputedLeft()).toBe(0)
581
+ expect(root_child1_child1.getComputedTop()).toBe(0)
582
+ expect(root_child1_child1.getComputedWidth()).toBe(25)
583
+ expect(root_child1_child1.getComputedHeight()).toBe(10)
584
+
585
+ expect(root_child1_child2.getComputedLeft()).toBe(25)
586
+ expect(root_child1_child2.getComputedTop()).toBe(20)
587
+ expect(root_child1_child2.getComputedWidth()).toBe(25)
588
+ expect(root_child1_child2.getComputedHeight()).toBe(20)
589
+
590
+ expect(root_child1_child3.getComputedLeft()).toBe(0)
591
+ expect(root_child1_child3.getComputedTop()).toBe(20)
592
+ expect(root_child1_child3.getComputedWidth()).toBe(25)
593
+ expect(root_child1_child3.getComputedHeight()).toBe(10)
594
+ } finally {
595
+ if (typeof root !== "undefined") {
596
+ root.freeRecursive()
597
+ }
598
+
599
+ config.free()
600
+ }
601
+ })
602
+ test("align_baseline_child_multiline_no_override_on_secondline", () => {
603
+ const config = Yoga.Config.create()
604
+ let root
605
+
606
+ try {
607
+ root = Yoga.Node.create(config)
608
+ root.setFlexDirection(FlexDirection.Row)
609
+ root.setAlignItems(Align.Baseline)
610
+ root.setPositionType(PositionType.Absolute)
611
+ root.setWidth(100)
612
+ root.setHeight(100)
613
+
614
+ const root_child0 = Yoga.Node.create(config)
615
+ root_child0.setWidth(50)
616
+ root_child0.setHeight(60)
617
+ root.insertChild(root_child0, 0)
618
+
619
+ const root_child1 = Yoga.Node.create(config)
620
+ root_child1.setFlexDirection(FlexDirection.Row)
621
+ root_child1.setFlexWrap(Wrap.Wrap)
622
+ root_child1.setWidth(50)
623
+ root_child1.setHeight(25)
624
+ root.insertChild(root_child1, 1)
625
+
626
+ const root_child1_child0 = Yoga.Node.create(config)
627
+ root_child1_child0.setWidth(25)
628
+ root_child1_child0.setHeight(20)
629
+ root_child1.insertChild(root_child1_child0, 0)
630
+
631
+ const root_child1_child1 = Yoga.Node.create(config)
632
+ root_child1_child1.setWidth(25)
633
+ root_child1_child1.setHeight(10)
634
+ root_child1.insertChild(root_child1_child1, 1)
635
+
636
+ const root_child1_child2 = Yoga.Node.create(config)
637
+ root_child1_child2.setWidth(25)
638
+ root_child1_child2.setHeight(20)
639
+ root_child1.insertChild(root_child1_child2, 2)
640
+
641
+ const root_child1_child3 = Yoga.Node.create(config)
642
+ root_child1_child3.setAlignSelf(Align.Baseline)
643
+ root_child1_child3.setWidth(25)
644
+ root_child1_child3.setHeight(10)
645
+ root_child1.insertChild(root_child1_child3, 3)
646
+ root.calculateLayout(undefined, undefined, Direction.LTR)
647
+
648
+ expect(root.getComputedLeft()).toBe(0)
649
+ expect(root.getComputedTop()).toBe(0)
650
+ expect(root.getComputedWidth()).toBe(100)
651
+ expect(root.getComputedHeight()).toBe(100)
652
+
653
+ expect(root_child0.getComputedLeft()).toBe(0)
654
+ expect(root_child0.getComputedTop()).toBe(0)
655
+ expect(root_child0.getComputedWidth()).toBe(50)
656
+ expect(root_child0.getComputedHeight()).toBe(60)
657
+
658
+ expect(root_child1.getComputedLeft()).toBe(50)
659
+ expect(root_child1.getComputedTop()).toBe(40)
660
+ expect(root_child1.getComputedWidth()).toBe(50)
661
+ expect(root_child1.getComputedHeight()).toBe(25)
662
+
663
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
664
+ expect(root_child1_child0.getComputedTop()).toBe(0)
665
+ expect(root_child1_child0.getComputedWidth()).toBe(25)
666
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
667
+
668
+ expect(root_child1_child1.getComputedLeft()).toBe(25)
669
+ expect(root_child1_child1.getComputedTop()).toBe(0)
670
+ expect(root_child1_child1.getComputedWidth()).toBe(25)
671
+ expect(root_child1_child1.getComputedHeight()).toBe(10)
672
+
673
+ expect(root_child1_child2.getComputedLeft()).toBe(0)
674
+ expect(root_child1_child2.getComputedTop()).toBe(20)
675
+ expect(root_child1_child2.getComputedWidth()).toBe(25)
676
+ expect(root_child1_child2.getComputedHeight()).toBe(20)
677
+
678
+ expect(root_child1_child3.getComputedLeft()).toBe(25)
679
+ expect(root_child1_child3.getComputedTop()).toBe(20)
680
+ expect(root_child1_child3.getComputedWidth()).toBe(25)
681
+ expect(root_child1_child3.getComputedHeight()).toBe(10)
682
+
683
+ root.calculateLayout(undefined, undefined, Direction.RTL)
684
+
685
+ expect(root.getComputedLeft()).toBe(0)
686
+ expect(root.getComputedTop()).toBe(0)
687
+ expect(root.getComputedWidth()).toBe(100)
688
+ expect(root.getComputedHeight()).toBe(100)
689
+
690
+ expect(root_child0.getComputedLeft()).toBe(50)
691
+ expect(root_child0.getComputedTop()).toBe(0)
692
+ expect(root_child0.getComputedWidth()).toBe(50)
693
+ expect(root_child0.getComputedHeight()).toBe(60)
694
+
695
+ expect(root_child1.getComputedLeft()).toBe(0)
696
+ expect(root_child1.getComputedTop()).toBe(40)
697
+ expect(root_child1.getComputedWidth()).toBe(50)
698
+ expect(root_child1.getComputedHeight()).toBe(25)
699
+
700
+ expect(root_child1_child0.getComputedLeft()).toBe(25)
701
+ expect(root_child1_child0.getComputedTop()).toBe(0)
702
+ expect(root_child1_child0.getComputedWidth()).toBe(25)
703
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
704
+
705
+ expect(root_child1_child1.getComputedLeft()).toBe(0)
706
+ expect(root_child1_child1.getComputedTop()).toBe(0)
707
+ expect(root_child1_child1.getComputedWidth()).toBe(25)
708
+ expect(root_child1_child1.getComputedHeight()).toBe(10)
709
+
710
+ expect(root_child1_child2.getComputedLeft()).toBe(25)
711
+ expect(root_child1_child2.getComputedTop()).toBe(20)
712
+ expect(root_child1_child2.getComputedWidth()).toBe(25)
713
+ expect(root_child1_child2.getComputedHeight()).toBe(20)
714
+
715
+ expect(root_child1_child3.getComputedLeft()).toBe(0)
716
+ expect(root_child1_child3.getComputedTop()).toBe(20)
717
+ expect(root_child1_child3.getComputedWidth()).toBe(25)
718
+ expect(root_child1_child3.getComputedHeight()).toBe(10)
719
+ } finally {
720
+ if (typeof root !== "undefined") {
721
+ root.freeRecursive()
722
+ }
723
+
724
+ config.free()
725
+ }
726
+ })
727
+ test("align_baseline_child_top", () => {
728
+ const config = Yoga.Config.create()
729
+ let root
730
+
731
+ try {
732
+ root = Yoga.Node.create(config)
733
+ root.setFlexDirection(FlexDirection.Row)
734
+ root.setAlignItems(Align.Baseline)
735
+ root.setPositionType(PositionType.Absolute)
736
+ root.setWidth(100)
737
+ root.setHeight(100)
738
+
739
+ const root_child0 = Yoga.Node.create(config)
740
+ root_child0.setPosition(Edge.Top, 10)
741
+ root_child0.setWidth(50)
742
+ root_child0.setHeight(50)
743
+ root.insertChild(root_child0, 0)
744
+
745
+ const root_child1 = Yoga.Node.create(config)
746
+ root_child1.setWidth(50)
747
+ root_child1.setHeight(20)
748
+ root.insertChild(root_child1, 1)
749
+
750
+ const root_child1_child0 = Yoga.Node.create(config)
751
+ root_child1_child0.setWidth(50)
752
+ root_child1_child0.setHeight(10)
753
+ root_child1.insertChild(root_child1_child0, 0)
754
+ root.calculateLayout(undefined, undefined, Direction.LTR)
755
+
756
+ expect(root.getComputedLeft()).toBe(0)
757
+ expect(root.getComputedTop()).toBe(0)
758
+ expect(root.getComputedWidth()).toBe(100)
759
+ expect(root.getComputedHeight()).toBe(100)
760
+
761
+ expect(root_child0.getComputedLeft()).toBe(0)
762
+ expect(root_child0.getComputedTop()).toBe(10)
763
+ expect(root_child0.getComputedWidth()).toBe(50)
764
+ expect(root_child0.getComputedHeight()).toBe(50)
765
+
766
+ expect(root_child1.getComputedLeft()).toBe(50)
767
+ expect(root_child1.getComputedTop()).toBe(40)
768
+ expect(root_child1.getComputedWidth()).toBe(50)
769
+ expect(root_child1.getComputedHeight()).toBe(20)
770
+
771
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
772
+ expect(root_child1_child0.getComputedTop()).toBe(0)
773
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
774
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
775
+
776
+ root.calculateLayout(undefined, undefined, Direction.RTL)
777
+
778
+ expect(root.getComputedLeft()).toBe(0)
779
+ expect(root.getComputedTop()).toBe(0)
780
+ expect(root.getComputedWidth()).toBe(100)
781
+ expect(root.getComputedHeight()).toBe(100)
782
+
783
+ expect(root_child0.getComputedLeft()).toBe(50)
784
+ expect(root_child0.getComputedTop()).toBe(10)
785
+ expect(root_child0.getComputedWidth()).toBe(50)
786
+ expect(root_child0.getComputedHeight()).toBe(50)
787
+
788
+ expect(root_child1.getComputedLeft()).toBe(0)
789
+ expect(root_child1.getComputedTop()).toBe(40)
790
+ expect(root_child1.getComputedWidth()).toBe(50)
791
+ expect(root_child1.getComputedHeight()).toBe(20)
792
+
793
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
794
+ expect(root_child1_child0.getComputedTop()).toBe(0)
795
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
796
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
797
+ } finally {
798
+ if (typeof root !== "undefined") {
799
+ root.freeRecursive()
800
+ }
801
+
802
+ config.free()
803
+ }
804
+ })
805
+ test("align_baseline_child_top2", () => {
806
+ const config = Yoga.Config.create()
807
+ let root
808
+
809
+ try {
810
+ root = Yoga.Node.create(config)
811
+ root.setFlexDirection(FlexDirection.Row)
812
+ root.setAlignItems(Align.Baseline)
813
+ root.setPositionType(PositionType.Absolute)
814
+ root.setWidth(100)
815
+ root.setHeight(100)
816
+
817
+ const root_child0 = Yoga.Node.create(config)
818
+ root_child0.setWidth(50)
819
+ root_child0.setHeight(50)
820
+ root.insertChild(root_child0, 0)
821
+
822
+ const root_child1 = Yoga.Node.create(config)
823
+ root_child1.setPosition(Edge.Top, 5)
824
+ root_child1.setWidth(50)
825
+ root_child1.setHeight(20)
826
+ root.insertChild(root_child1, 1)
827
+
828
+ const root_child1_child0 = Yoga.Node.create(config)
829
+ root_child1_child0.setWidth(50)
830
+ root_child1_child0.setHeight(10)
831
+ root_child1.insertChild(root_child1_child0, 0)
832
+ root.calculateLayout(undefined, undefined, Direction.LTR)
833
+
834
+ expect(root.getComputedLeft()).toBe(0)
835
+ expect(root.getComputedTop()).toBe(0)
836
+ expect(root.getComputedWidth()).toBe(100)
837
+ expect(root.getComputedHeight()).toBe(100)
838
+
839
+ expect(root_child0.getComputedLeft()).toBe(0)
840
+ expect(root_child0.getComputedTop()).toBe(0)
841
+ expect(root_child0.getComputedWidth()).toBe(50)
842
+ expect(root_child0.getComputedHeight()).toBe(50)
843
+
844
+ expect(root_child1.getComputedLeft()).toBe(50)
845
+ expect(root_child1.getComputedTop()).toBe(45)
846
+ expect(root_child1.getComputedWidth()).toBe(50)
847
+ expect(root_child1.getComputedHeight()).toBe(20)
848
+
849
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
850
+ expect(root_child1_child0.getComputedTop()).toBe(0)
851
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
852
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
853
+
854
+ root.calculateLayout(undefined, undefined, Direction.RTL)
855
+
856
+ expect(root.getComputedLeft()).toBe(0)
857
+ expect(root.getComputedTop()).toBe(0)
858
+ expect(root.getComputedWidth()).toBe(100)
859
+ expect(root.getComputedHeight()).toBe(100)
860
+
861
+ expect(root_child0.getComputedLeft()).toBe(50)
862
+ expect(root_child0.getComputedTop()).toBe(0)
863
+ expect(root_child0.getComputedWidth()).toBe(50)
864
+ expect(root_child0.getComputedHeight()).toBe(50)
865
+
866
+ expect(root_child1.getComputedLeft()).toBe(0)
867
+ expect(root_child1.getComputedTop()).toBe(45)
868
+ expect(root_child1.getComputedWidth()).toBe(50)
869
+ expect(root_child1.getComputedHeight()).toBe(20)
870
+
871
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
872
+ expect(root_child1_child0.getComputedTop()).toBe(0)
873
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
874
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
875
+ } finally {
876
+ if (typeof root !== "undefined") {
877
+ root.freeRecursive()
878
+ }
879
+
880
+ config.free()
881
+ }
882
+ })
883
+ test("align_baseline_double_nested_child", () => {
884
+ const config = Yoga.Config.create()
885
+ let root
886
+
887
+ try {
888
+ root = Yoga.Node.create(config)
889
+ root.setFlexDirection(FlexDirection.Row)
890
+ root.setAlignItems(Align.Baseline)
891
+ root.setPositionType(PositionType.Absolute)
892
+ root.setWidth(100)
893
+ root.setHeight(100)
894
+
895
+ const root_child0 = Yoga.Node.create(config)
896
+ root_child0.setWidth(50)
897
+ root_child0.setHeight(50)
898
+ root.insertChild(root_child0, 0)
899
+
900
+ const root_child0_child0 = Yoga.Node.create(config)
901
+ root_child0_child0.setWidth(50)
902
+ root_child0_child0.setHeight(20)
903
+ root_child0.insertChild(root_child0_child0, 0)
904
+
905
+ const root_child1 = Yoga.Node.create(config)
906
+ root_child1.setWidth(50)
907
+ root_child1.setHeight(20)
908
+ root.insertChild(root_child1, 1)
909
+
910
+ const root_child1_child0 = Yoga.Node.create(config)
911
+ root_child1_child0.setWidth(50)
912
+ root_child1_child0.setHeight(15)
913
+ root_child1.insertChild(root_child1_child0, 0)
914
+ root.calculateLayout(undefined, undefined, Direction.LTR)
915
+
916
+ expect(root.getComputedLeft()).toBe(0)
917
+ expect(root.getComputedTop()).toBe(0)
918
+ expect(root.getComputedWidth()).toBe(100)
919
+ expect(root.getComputedHeight()).toBe(100)
920
+
921
+ expect(root_child0.getComputedLeft()).toBe(0)
922
+ expect(root_child0.getComputedTop()).toBe(0)
923
+ expect(root_child0.getComputedWidth()).toBe(50)
924
+ expect(root_child0.getComputedHeight()).toBe(50)
925
+
926
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
927
+ expect(root_child0_child0.getComputedTop()).toBe(0)
928
+ expect(root_child0_child0.getComputedWidth()).toBe(50)
929
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
930
+
931
+ expect(root_child1.getComputedLeft()).toBe(50)
932
+ expect(root_child1.getComputedTop()).toBe(5)
933
+ expect(root_child1.getComputedWidth()).toBe(50)
934
+ expect(root_child1.getComputedHeight()).toBe(20)
935
+
936
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
937
+ expect(root_child1_child0.getComputedTop()).toBe(0)
938
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
939
+ expect(root_child1_child0.getComputedHeight()).toBe(15)
940
+
941
+ root.calculateLayout(undefined, undefined, Direction.RTL)
942
+
943
+ expect(root.getComputedLeft()).toBe(0)
944
+ expect(root.getComputedTop()).toBe(0)
945
+ expect(root.getComputedWidth()).toBe(100)
946
+ expect(root.getComputedHeight()).toBe(100)
947
+
948
+ expect(root_child0.getComputedLeft()).toBe(50)
949
+ expect(root_child0.getComputedTop()).toBe(0)
950
+ expect(root_child0.getComputedWidth()).toBe(50)
951
+ expect(root_child0.getComputedHeight()).toBe(50)
952
+
953
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
954
+ expect(root_child0_child0.getComputedTop()).toBe(0)
955
+ expect(root_child0_child0.getComputedWidth()).toBe(50)
956
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
957
+
958
+ expect(root_child1.getComputedLeft()).toBe(0)
959
+ expect(root_child1.getComputedTop()).toBe(5)
960
+ expect(root_child1.getComputedWidth()).toBe(50)
961
+ expect(root_child1.getComputedHeight()).toBe(20)
962
+
963
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
964
+ expect(root_child1_child0.getComputedTop()).toBe(0)
965
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
966
+ expect(root_child1_child0.getComputedHeight()).toBe(15)
967
+ } finally {
968
+ if (typeof root !== "undefined") {
969
+ root.freeRecursive()
970
+ }
971
+
972
+ config.free()
973
+ }
974
+ })
975
+ test("align_baseline_column", () => {
976
+ const config = Yoga.Config.create()
977
+ let root
978
+
979
+ try {
980
+ root = Yoga.Node.create(config)
981
+ root.setAlignItems(Align.Baseline)
982
+ root.setPositionType(PositionType.Absolute)
983
+ root.setWidth(100)
984
+ root.setHeight(100)
985
+
986
+ const root_child0 = Yoga.Node.create(config)
987
+ root_child0.setWidth(50)
988
+ root_child0.setHeight(50)
989
+ root.insertChild(root_child0, 0)
990
+
991
+ const root_child1 = Yoga.Node.create(config)
992
+ root_child1.setWidth(50)
993
+ root_child1.setHeight(20)
994
+ root.insertChild(root_child1, 1)
995
+ root.calculateLayout(undefined, undefined, Direction.LTR)
996
+
997
+ expect(root.getComputedLeft()).toBe(0)
998
+ expect(root.getComputedTop()).toBe(0)
999
+ expect(root.getComputedWidth()).toBe(100)
1000
+ expect(root.getComputedHeight()).toBe(100)
1001
+
1002
+ expect(root_child0.getComputedLeft()).toBe(0)
1003
+ expect(root_child0.getComputedTop()).toBe(0)
1004
+ expect(root_child0.getComputedWidth()).toBe(50)
1005
+ expect(root_child0.getComputedHeight()).toBe(50)
1006
+
1007
+ expect(root_child1.getComputedLeft()).toBe(0)
1008
+ expect(root_child1.getComputedTop()).toBe(50)
1009
+ expect(root_child1.getComputedWidth()).toBe(50)
1010
+ expect(root_child1.getComputedHeight()).toBe(20)
1011
+
1012
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1013
+
1014
+ expect(root.getComputedLeft()).toBe(0)
1015
+ expect(root.getComputedTop()).toBe(0)
1016
+ expect(root.getComputedWidth()).toBe(100)
1017
+ expect(root.getComputedHeight()).toBe(100)
1018
+
1019
+ expect(root_child0.getComputedLeft()).toBe(50)
1020
+ expect(root_child0.getComputedTop()).toBe(0)
1021
+ expect(root_child0.getComputedWidth()).toBe(50)
1022
+ expect(root_child0.getComputedHeight()).toBe(50)
1023
+
1024
+ expect(root_child1.getComputedLeft()).toBe(50)
1025
+ expect(root_child1.getComputedTop()).toBe(50)
1026
+ expect(root_child1.getComputedWidth()).toBe(50)
1027
+ expect(root_child1.getComputedHeight()).toBe(20)
1028
+ } finally {
1029
+ if (typeof root !== "undefined") {
1030
+ root.freeRecursive()
1031
+ }
1032
+
1033
+ config.free()
1034
+ }
1035
+ })
1036
+ test("align_baseline_child_margin", () => {
1037
+ const config = Yoga.Config.create()
1038
+ let root
1039
+
1040
+ try {
1041
+ root = Yoga.Node.create(config)
1042
+ root.setFlexDirection(FlexDirection.Row)
1043
+ root.setAlignItems(Align.Baseline)
1044
+ root.setPositionType(PositionType.Absolute)
1045
+ root.setWidth(100)
1046
+ root.setHeight(100)
1047
+
1048
+ const root_child0 = Yoga.Node.create(config)
1049
+ root_child0.setMargin(Edge.Left, 5)
1050
+ root_child0.setMargin(Edge.Top, 5)
1051
+ root_child0.setMargin(Edge.Right, 5)
1052
+ root_child0.setMargin(Edge.Bottom, 5)
1053
+ root_child0.setWidth(50)
1054
+ root_child0.setHeight(50)
1055
+ root.insertChild(root_child0, 0)
1056
+
1057
+ const root_child1 = Yoga.Node.create(config)
1058
+ root_child1.setWidth(50)
1059
+ root_child1.setHeight(20)
1060
+ root.insertChild(root_child1, 1)
1061
+
1062
+ const root_child1_child0 = Yoga.Node.create(config)
1063
+ root_child1_child0.setMargin(Edge.Left, 1)
1064
+ root_child1_child0.setMargin(Edge.Top, 1)
1065
+ root_child1_child0.setMargin(Edge.Right, 1)
1066
+ root_child1_child0.setMargin(Edge.Bottom, 1)
1067
+ root_child1_child0.setWidth(50)
1068
+ root_child1_child0.setHeight(10)
1069
+ root_child1.insertChild(root_child1_child0, 0)
1070
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1071
+
1072
+ expect(root.getComputedLeft()).toBe(0)
1073
+ expect(root.getComputedTop()).toBe(0)
1074
+ expect(root.getComputedWidth()).toBe(100)
1075
+ expect(root.getComputedHeight()).toBe(100)
1076
+
1077
+ expect(root_child0.getComputedLeft()).toBe(5)
1078
+ expect(root_child0.getComputedTop()).toBe(5)
1079
+ expect(root_child0.getComputedWidth()).toBe(50)
1080
+ expect(root_child0.getComputedHeight()).toBe(50)
1081
+
1082
+ expect(root_child1.getComputedLeft()).toBe(60)
1083
+ expect(root_child1.getComputedTop()).toBe(44)
1084
+ expect(root_child1.getComputedWidth()).toBe(50)
1085
+ expect(root_child1.getComputedHeight()).toBe(20)
1086
+
1087
+ expect(root_child1_child0.getComputedLeft()).toBe(1)
1088
+ expect(root_child1_child0.getComputedTop()).toBe(1)
1089
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
1090
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
1091
+
1092
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1093
+
1094
+ expect(root.getComputedLeft()).toBe(0)
1095
+ expect(root.getComputedTop()).toBe(0)
1096
+ expect(root.getComputedWidth()).toBe(100)
1097
+ expect(root.getComputedHeight()).toBe(100)
1098
+
1099
+ expect(root_child0.getComputedLeft()).toBe(45)
1100
+ expect(root_child0.getComputedTop()).toBe(5)
1101
+ expect(root_child0.getComputedWidth()).toBe(50)
1102
+ expect(root_child0.getComputedHeight()).toBe(50)
1103
+
1104
+ expect(root_child1.getComputedLeft()).toBe(-10)
1105
+ expect(root_child1.getComputedTop()).toBe(44)
1106
+ expect(root_child1.getComputedWidth()).toBe(50)
1107
+ expect(root_child1.getComputedHeight()).toBe(20)
1108
+
1109
+ expect(root_child1_child0.getComputedLeft()).toBe(-1)
1110
+ expect(root_child1_child0.getComputedTop()).toBe(1)
1111
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
1112
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
1113
+ } finally {
1114
+ if (typeof root !== "undefined") {
1115
+ root.freeRecursive()
1116
+ }
1117
+
1118
+ config.free()
1119
+ }
1120
+ })
1121
+ test("align_baseline_child_padding", () => {
1122
+ const config = Yoga.Config.create()
1123
+ let root
1124
+
1125
+ try {
1126
+ root = Yoga.Node.create(config)
1127
+ root.setFlexDirection(FlexDirection.Row)
1128
+ root.setAlignItems(Align.Baseline)
1129
+ root.setPositionType(PositionType.Absolute)
1130
+ root.setPadding(Edge.Left, 5)
1131
+ root.setPadding(Edge.Top, 5)
1132
+ root.setPadding(Edge.Right, 5)
1133
+ root.setPadding(Edge.Bottom, 5)
1134
+ root.setWidth(100)
1135
+ root.setHeight(100)
1136
+
1137
+ const root_child0 = Yoga.Node.create(config)
1138
+ root_child0.setWidth(50)
1139
+ root_child0.setHeight(50)
1140
+ root.insertChild(root_child0, 0)
1141
+
1142
+ const root_child1 = Yoga.Node.create(config)
1143
+ root_child1.setPadding(Edge.Left, 5)
1144
+ root_child1.setPadding(Edge.Top, 5)
1145
+ root_child1.setPadding(Edge.Right, 5)
1146
+ root_child1.setPadding(Edge.Bottom, 5)
1147
+ root_child1.setWidth(50)
1148
+ root_child1.setHeight(20)
1149
+ root.insertChild(root_child1, 1)
1150
+
1151
+ const root_child1_child0 = Yoga.Node.create(config)
1152
+ root_child1_child0.setWidth(50)
1153
+ root_child1_child0.setHeight(10)
1154
+ root_child1.insertChild(root_child1_child0, 0)
1155
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1156
+
1157
+ expect(root.getComputedLeft()).toBe(0)
1158
+ expect(root.getComputedTop()).toBe(0)
1159
+ expect(root.getComputedWidth()).toBe(100)
1160
+ expect(root.getComputedHeight()).toBe(100)
1161
+
1162
+ expect(root_child0.getComputedLeft()).toBe(5)
1163
+ expect(root_child0.getComputedTop()).toBe(5)
1164
+ expect(root_child0.getComputedWidth()).toBe(50)
1165
+ expect(root_child0.getComputedHeight()).toBe(50)
1166
+
1167
+ expect(root_child1.getComputedLeft()).toBe(55)
1168
+ expect(root_child1.getComputedTop()).toBe(40)
1169
+ expect(root_child1.getComputedWidth()).toBe(50)
1170
+ expect(root_child1.getComputedHeight()).toBe(20)
1171
+
1172
+ expect(root_child1_child0.getComputedLeft()).toBe(5)
1173
+ expect(root_child1_child0.getComputedTop()).toBe(5)
1174
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
1175
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
1176
+
1177
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1178
+
1179
+ expect(root.getComputedLeft()).toBe(0)
1180
+ expect(root.getComputedTop()).toBe(0)
1181
+ expect(root.getComputedWidth()).toBe(100)
1182
+ expect(root.getComputedHeight()).toBe(100)
1183
+
1184
+ expect(root_child0.getComputedLeft()).toBe(45)
1185
+ expect(root_child0.getComputedTop()).toBe(5)
1186
+ expect(root_child0.getComputedWidth()).toBe(50)
1187
+ expect(root_child0.getComputedHeight()).toBe(50)
1188
+
1189
+ expect(root_child1.getComputedLeft()).toBe(-5)
1190
+ expect(root_child1.getComputedTop()).toBe(40)
1191
+ expect(root_child1.getComputedWidth()).toBe(50)
1192
+ expect(root_child1.getComputedHeight()).toBe(20)
1193
+
1194
+ expect(root_child1_child0.getComputedLeft()).toBe(-5)
1195
+ expect(root_child1_child0.getComputedTop()).toBe(5)
1196
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
1197
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
1198
+ } finally {
1199
+ if (typeof root !== "undefined") {
1200
+ root.freeRecursive()
1201
+ }
1202
+
1203
+ config.free()
1204
+ }
1205
+ })
1206
+ test("align_baseline_multiline", () => {
1207
+ const config = Yoga.Config.create()
1208
+ let root
1209
+
1210
+ try {
1211
+ root = Yoga.Node.create(config)
1212
+ root.setFlexDirection(FlexDirection.Row)
1213
+ root.setAlignItems(Align.Baseline)
1214
+ root.setPositionType(PositionType.Absolute)
1215
+ root.setFlexWrap(Wrap.Wrap)
1216
+ root.setWidth(100)
1217
+ root.setHeight(100)
1218
+
1219
+ const root_child0 = Yoga.Node.create(config)
1220
+ root_child0.setWidth(50)
1221
+ root_child0.setHeight(50)
1222
+ root.insertChild(root_child0, 0)
1223
+
1224
+ const root_child1 = Yoga.Node.create(config)
1225
+ root_child1.setWidth(50)
1226
+ root_child1.setHeight(20)
1227
+ root.insertChild(root_child1, 1)
1228
+
1229
+ const root_child1_child0 = Yoga.Node.create(config)
1230
+ root_child1_child0.setWidth(50)
1231
+ root_child1_child0.setHeight(10)
1232
+ root_child1.insertChild(root_child1_child0, 0)
1233
+
1234
+ const root_child2 = Yoga.Node.create(config)
1235
+ root_child2.setWidth(50)
1236
+ root_child2.setHeight(20)
1237
+ root.insertChild(root_child2, 2)
1238
+
1239
+ const root_child2_child0 = Yoga.Node.create(config)
1240
+ root_child2_child0.setWidth(50)
1241
+ root_child2_child0.setHeight(10)
1242
+ root_child2.insertChild(root_child2_child0, 0)
1243
+
1244
+ const root_child3 = Yoga.Node.create(config)
1245
+ root_child3.setWidth(50)
1246
+ root_child3.setHeight(50)
1247
+ root.insertChild(root_child3, 3)
1248
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1249
+
1250
+ expect(root.getComputedLeft()).toBe(0)
1251
+ expect(root.getComputedTop()).toBe(0)
1252
+ expect(root.getComputedWidth()).toBe(100)
1253
+ expect(root.getComputedHeight()).toBe(100)
1254
+
1255
+ expect(root_child0.getComputedLeft()).toBe(0)
1256
+ expect(root_child0.getComputedTop()).toBe(0)
1257
+ expect(root_child0.getComputedWidth()).toBe(50)
1258
+ expect(root_child0.getComputedHeight()).toBe(50)
1259
+
1260
+ expect(root_child1.getComputedLeft()).toBe(50)
1261
+ expect(root_child1.getComputedTop()).toBe(40)
1262
+ expect(root_child1.getComputedWidth()).toBe(50)
1263
+ expect(root_child1.getComputedHeight()).toBe(20)
1264
+
1265
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
1266
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1267
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
1268
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
1269
+
1270
+ expect(root_child2.getComputedLeft()).toBe(0)
1271
+ expect(root_child2.getComputedTop()).toBe(100)
1272
+ expect(root_child2.getComputedWidth()).toBe(50)
1273
+ expect(root_child2.getComputedHeight()).toBe(20)
1274
+
1275
+ expect(root_child2_child0.getComputedLeft()).toBe(0)
1276
+ expect(root_child2_child0.getComputedTop()).toBe(0)
1277
+ expect(root_child2_child0.getComputedWidth()).toBe(50)
1278
+ expect(root_child2_child0.getComputedHeight()).toBe(10)
1279
+
1280
+ expect(root_child3.getComputedLeft()).toBe(50)
1281
+ expect(root_child3.getComputedTop()).toBe(60)
1282
+ expect(root_child3.getComputedWidth()).toBe(50)
1283
+ expect(root_child3.getComputedHeight()).toBe(50)
1284
+
1285
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1286
+
1287
+ expect(root.getComputedLeft()).toBe(0)
1288
+ expect(root.getComputedTop()).toBe(0)
1289
+ expect(root.getComputedWidth()).toBe(100)
1290
+ expect(root.getComputedHeight()).toBe(100)
1291
+
1292
+ expect(root_child0.getComputedLeft()).toBe(50)
1293
+ expect(root_child0.getComputedTop()).toBe(0)
1294
+ expect(root_child0.getComputedWidth()).toBe(50)
1295
+ expect(root_child0.getComputedHeight()).toBe(50)
1296
+
1297
+ expect(root_child1.getComputedLeft()).toBe(0)
1298
+ expect(root_child1.getComputedTop()).toBe(40)
1299
+ expect(root_child1.getComputedWidth()).toBe(50)
1300
+ expect(root_child1.getComputedHeight()).toBe(20)
1301
+
1302
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
1303
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1304
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
1305
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
1306
+
1307
+ expect(root_child2.getComputedLeft()).toBe(50)
1308
+ expect(root_child2.getComputedTop()).toBe(100)
1309
+ expect(root_child2.getComputedWidth()).toBe(50)
1310
+ expect(root_child2.getComputedHeight()).toBe(20)
1311
+
1312
+ expect(root_child2_child0.getComputedLeft()).toBe(0)
1313
+ expect(root_child2_child0.getComputedTop()).toBe(0)
1314
+ expect(root_child2_child0.getComputedWidth()).toBe(50)
1315
+ expect(root_child2_child0.getComputedHeight()).toBe(10)
1316
+
1317
+ expect(root_child3.getComputedLeft()).toBe(0)
1318
+ expect(root_child3.getComputedTop()).toBe(60)
1319
+ expect(root_child3.getComputedWidth()).toBe(50)
1320
+ expect(root_child3.getComputedHeight()).toBe(50)
1321
+ } finally {
1322
+ if (typeof root !== "undefined") {
1323
+ root.freeRecursive()
1324
+ }
1325
+
1326
+ config.free()
1327
+ }
1328
+ })
1329
+ test.skip("align_baseline_multiline_column", () => {
1330
+ const config = Yoga.Config.create()
1331
+ let root
1332
+
1333
+ try {
1334
+ root = Yoga.Node.create(config)
1335
+ root.setAlignItems(Align.Baseline)
1336
+ root.setPositionType(PositionType.Absolute)
1337
+ root.setFlexWrap(Wrap.Wrap)
1338
+ root.setWidth(100)
1339
+ root.setHeight(100)
1340
+
1341
+ const root_child0 = Yoga.Node.create(config)
1342
+ root_child0.setWidth(50)
1343
+ root_child0.setHeight(50)
1344
+ root.insertChild(root_child0, 0)
1345
+
1346
+ const root_child1 = Yoga.Node.create(config)
1347
+ root_child1.setWidth(30)
1348
+ root_child1.setHeight(50)
1349
+ root.insertChild(root_child1, 1)
1350
+
1351
+ const root_child1_child0 = Yoga.Node.create(config)
1352
+ root_child1_child0.setWidth(20)
1353
+ root_child1_child0.setHeight(20)
1354
+ root_child1.insertChild(root_child1_child0, 0)
1355
+
1356
+ const root_child2 = Yoga.Node.create(config)
1357
+ root_child2.setWidth(40)
1358
+ root_child2.setHeight(70)
1359
+ root.insertChild(root_child2, 2)
1360
+
1361
+ const root_child2_child0 = Yoga.Node.create(config)
1362
+ root_child2_child0.setWidth(10)
1363
+ root_child2_child0.setHeight(10)
1364
+ root_child2.insertChild(root_child2_child0, 0)
1365
+
1366
+ const root_child3 = Yoga.Node.create(config)
1367
+ root_child3.setWidth(50)
1368
+ root_child3.setHeight(20)
1369
+ root.insertChild(root_child3, 3)
1370
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1371
+
1372
+ expect(root.getComputedLeft()).toBe(0)
1373
+ expect(root.getComputedTop()).toBe(0)
1374
+ expect(root.getComputedWidth()).toBe(100)
1375
+ expect(root.getComputedHeight()).toBe(100)
1376
+
1377
+ expect(root_child0.getComputedLeft()).toBe(0)
1378
+ expect(root_child0.getComputedTop()).toBe(0)
1379
+ expect(root_child0.getComputedWidth()).toBe(50)
1380
+ expect(root_child0.getComputedHeight()).toBe(50)
1381
+
1382
+ expect(root_child1.getComputedLeft()).toBe(0)
1383
+ expect(root_child1.getComputedTop()).toBe(50)
1384
+ expect(root_child1.getComputedWidth()).toBe(30)
1385
+ expect(root_child1.getComputedHeight()).toBe(50)
1386
+
1387
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
1388
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1389
+ expect(root_child1_child0.getComputedWidth()).toBe(20)
1390
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
1391
+
1392
+ expect(root_child2.getComputedLeft()).toBe(50)
1393
+ expect(root_child2.getComputedTop()).toBe(0)
1394
+ expect(root_child2.getComputedWidth()).toBe(40)
1395
+ expect(root_child2.getComputedHeight()).toBe(70)
1396
+
1397
+ expect(root_child2_child0.getComputedLeft()).toBe(0)
1398
+ expect(root_child2_child0.getComputedTop()).toBe(0)
1399
+ expect(root_child2_child0.getComputedWidth()).toBe(10)
1400
+ expect(root_child2_child0.getComputedHeight()).toBe(10)
1401
+
1402
+ expect(root_child3.getComputedLeft()).toBe(50)
1403
+ expect(root_child3.getComputedTop()).toBe(70)
1404
+ expect(root_child3.getComputedWidth()).toBe(50)
1405
+ expect(root_child3.getComputedHeight()).toBe(20)
1406
+
1407
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1408
+
1409
+ expect(root.getComputedLeft()).toBe(0)
1410
+ expect(root.getComputedTop()).toBe(0)
1411
+ expect(root.getComputedWidth()).toBe(100)
1412
+ expect(root.getComputedHeight()).toBe(100)
1413
+
1414
+ expect(root_child0.getComputedLeft()).toBe(50)
1415
+ expect(root_child0.getComputedTop()).toBe(0)
1416
+ expect(root_child0.getComputedWidth()).toBe(50)
1417
+ expect(root_child0.getComputedHeight()).toBe(50)
1418
+
1419
+ expect(root_child1.getComputedLeft()).toBe(50)
1420
+ expect(root_child1.getComputedTop()).toBe(50)
1421
+ expect(root_child1.getComputedWidth()).toBe(30)
1422
+ expect(root_child1.getComputedHeight()).toBe(50)
1423
+
1424
+ expect(root_child1_child0.getComputedLeft()).toBe(10)
1425
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1426
+ expect(root_child1_child0.getComputedWidth()).toBe(20)
1427
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
1428
+
1429
+ expect(root_child2.getComputedLeft()).toBe(0)
1430
+ expect(root_child2.getComputedTop()).toBe(0)
1431
+ expect(root_child2.getComputedWidth()).toBe(40)
1432
+ expect(root_child2.getComputedHeight()).toBe(70)
1433
+
1434
+ expect(root_child2_child0.getComputedLeft()).toBe(30)
1435
+ expect(root_child2_child0.getComputedTop()).toBe(0)
1436
+ expect(root_child2_child0.getComputedWidth()).toBe(10)
1437
+ expect(root_child2_child0.getComputedHeight()).toBe(10)
1438
+
1439
+ expect(root_child3.getComputedLeft()).toBe(0)
1440
+ expect(root_child3.getComputedTop()).toBe(70)
1441
+ expect(root_child3.getComputedWidth()).toBe(50)
1442
+ expect(root_child3.getComputedHeight()).toBe(20)
1443
+ } finally {
1444
+ if (typeof root !== "undefined") {
1445
+ root.freeRecursive()
1446
+ }
1447
+
1448
+ config.free()
1449
+ }
1450
+ })
1451
+ test.skip("align_baseline_multiline_column2", () => {
1452
+ const config = Yoga.Config.create()
1453
+ let root
1454
+
1455
+ try {
1456
+ root = Yoga.Node.create(config)
1457
+ root.setAlignItems(Align.Baseline)
1458
+ root.setPositionType(PositionType.Absolute)
1459
+ root.setFlexWrap(Wrap.Wrap)
1460
+ root.setWidth(100)
1461
+ root.setHeight(100)
1462
+
1463
+ const root_child0 = Yoga.Node.create(config)
1464
+ root_child0.setWidth(50)
1465
+ root_child0.setHeight(50)
1466
+ root.insertChild(root_child0, 0)
1467
+
1468
+ const root_child1 = Yoga.Node.create(config)
1469
+ root_child1.setWidth(30)
1470
+ root_child1.setHeight(50)
1471
+ root.insertChild(root_child1, 1)
1472
+
1473
+ const root_child1_child0 = Yoga.Node.create(config)
1474
+ root_child1_child0.setWidth(20)
1475
+ root_child1_child0.setHeight(20)
1476
+ root_child1.insertChild(root_child1_child0, 0)
1477
+
1478
+ const root_child2 = Yoga.Node.create(config)
1479
+ root_child2.setWidth(40)
1480
+ root_child2.setHeight(70)
1481
+ root.insertChild(root_child2, 2)
1482
+
1483
+ const root_child2_child0 = Yoga.Node.create(config)
1484
+ root_child2_child0.setWidth(10)
1485
+ root_child2_child0.setHeight(10)
1486
+ root_child2.insertChild(root_child2_child0, 0)
1487
+
1488
+ const root_child3 = Yoga.Node.create(config)
1489
+ root_child3.setWidth(50)
1490
+ root_child3.setHeight(20)
1491
+ root.insertChild(root_child3, 3)
1492
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1493
+
1494
+ expect(root.getComputedLeft()).toBe(0)
1495
+ expect(root.getComputedTop()).toBe(0)
1496
+ expect(root.getComputedWidth()).toBe(100)
1497
+ expect(root.getComputedHeight()).toBe(100)
1498
+
1499
+ expect(root_child0.getComputedLeft()).toBe(0)
1500
+ expect(root_child0.getComputedTop()).toBe(0)
1501
+ expect(root_child0.getComputedWidth()).toBe(50)
1502
+ expect(root_child0.getComputedHeight()).toBe(50)
1503
+
1504
+ expect(root_child1.getComputedLeft()).toBe(0)
1505
+ expect(root_child1.getComputedTop()).toBe(50)
1506
+ expect(root_child1.getComputedWidth()).toBe(30)
1507
+ expect(root_child1.getComputedHeight()).toBe(50)
1508
+
1509
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
1510
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1511
+ expect(root_child1_child0.getComputedWidth()).toBe(20)
1512
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
1513
+
1514
+ expect(root_child2.getComputedLeft()).toBe(50)
1515
+ expect(root_child2.getComputedTop()).toBe(0)
1516
+ expect(root_child2.getComputedWidth()).toBe(40)
1517
+ expect(root_child2.getComputedHeight()).toBe(70)
1518
+
1519
+ expect(root_child2_child0.getComputedLeft()).toBe(0)
1520
+ expect(root_child2_child0.getComputedTop()).toBe(0)
1521
+ expect(root_child2_child0.getComputedWidth()).toBe(10)
1522
+ expect(root_child2_child0.getComputedHeight()).toBe(10)
1523
+
1524
+ expect(root_child3.getComputedLeft()).toBe(50)
1525
+ expect(root_child3.getComputedTop()).toBe(70)
1526
+ expect(root_child3.getComputedWidth()).toBe(50)
1527
+ expect(root_child3.getComputedHeight()).toBe(20)
1528
+
1529
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1530
+
1531
+ expect(root.getComputedLeft()).toBe(0)
1532
+ expect(root.getComputedTop()).toBe(0)
1533
+ expect(root.getComputedWidth()).toBe(100)
1534
+ expect(root.getComputedHeight()).toBe(100)
1535
+
1536
+ expect(root_child0.getComputedLeft()).toBe(50)
1537
+ expect(root_child0.getComputedTop()).toBe(0)
1538
+ expect(root_child0.getComputedWidth()).toBe(50)
1539
+ expect(root_child0.getComputedHeight()).toBe(50)
1540
+
1541
+ expect(root_child1.getComputedLeft()).toBe(50)
1542
+ expect(root_child1.getComputedTop()).toBe(50)
1543
+ expect(root_child1.getComputedWidth()).toBe(30)
1544
+ expect(root_child1.getComputedHeight()).toBe(50)
1545
+
1546
+ expect(root_child1_child0.getComputedLeft()).toBe(10)
1547
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1548
+ expect(root_child1_child0.getComputedWidth()).toBe(20)
1549
+ expect(root_child1_child0.getComputedHeight()).toBe(20)
1550
+
1551
+ expect(root_child2.getComputedLeft()).toBe(0)
1552
+ expect(root_child2.getComputedTop()).toBe(0)
1553
+ expect(root_child2.getComputedWidth()).toBe(40)
1554
+ expect(root_child2.getComputedHeight()).toBe(70)
1555
+
1556
+ expect(root_child2_child0.getComputedLeft()).toBe(30)
1557
+ expect(root_child2_child0.getComputedTop()).toBe(0)
1558
+ expect(root_child2_child0.getComputedWidth()).toBe(10)
1559
+ expect(root_child2_child0.getComputedHeight()).toBe(10)
1560
+
1561
+ expect(root_child3.getComputedLeft()).toBe(0)
1562
+ expect(root_child3.getComputedTop()).toBe(70)
1563
+ expect(root_child3.getComputedWidth()).toBe(50)
1564
+ expect(root_child3.getComputedHeight()).toBe(20)
1565
+ } finally {
1566
+ if (typeof root !== "undefined") {
1567
+ root.freeRecursive()
1568
+ }
1569
+
1570
+ config.free()
1571
+ }
1572
+ })
1573
+ test("align_baseline_multiline_row_and_column", () => {
1574
+ const config = Yoga.Config.create()
1575
+ let root
1576
+
1577
+ try {
1578
+ root = Yoga.Node.create(config)
1579
+ root.setFlexDirection(FlexDirection.Row)
1580
+ root.setAlignItems(Align.Baseline)
1581
+ root.setPositionType(PositionType.Absolute)
1582
+ root.setFlexWrap(Wrap.Wrap)
1583
+ root.setWidth(100)
1584
+ root.setHeight(100)
1585
+
1586
+ const root_child0 = Yoga.Node.create(config)
1587
+ root_child0.setWidth(50)
1588
+ root_child0.setHeight(50)
1589
+ root.insertChild(root_child0, 0)
1590
+
1591
+ const root_child1 = Yoga.Node.create(config)
1592
+ root_child1.setWidth(50)
1593
+ root_child1.setHeight(50)
1594
+ root.insertChild(root_child1, 1)
1595
+
1596
+ const root_child1_child0 = Yoga.Node.create(config)
1597
+ root_child1_child0.setWidth(50)
1598
+ root_child1_child0.setHeight(10)
1599
+ root_child1.insertChild(root_child1_child0, 0)
1600
+
1601
+ const root_child2 = Yoga.Node.create(config)
1602
+ root_child2.setWidth(50)
1603
+ root_child2.setHeight(20)
1604
+ root.insertChild(root_child2, 2)
1605
+
1606
+ const root_child2_child0 = Yoga.Node.create(config)
1607
+ root_child2_child0.setWidth(50)
1608
+ root_child2_child0.setHeight(10)
1609
+ root_child2.insertChild(root_child2_child0, 0)
1610
+
1611
+ const root_child3 = Yoga.Node.create(config)
1612
+ root_child3.setWidth(50)
1613
+ root_child3.setHeight(20)
1614
+ root.insertChild(root_child3, 3)
1615
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1616
+
1617
+ expect(root.getComputedLeft()).toBe(0)
1618
+ expect(root.getComputedTop()).toBe(0)
1619
+ expect(root.getComputedWidth()).toBe(100)
1620
+ expect(root.getComputedHeight()).toBe(100)
1621
+
1622
+ expect(root_child0.getComputedLeft()).toBe(0)
1623
+ expect(root_child0.getComputedTop()).toBe(0)
1624
+ expect(root_child0.getComputedWidth()).toBe(50)
1625
+ expect(root_child0.getComputedHeight()).toBe(50)
1626
+
1627
+ expect(root_child1.getComputedLeft()).toBe(50)
1628
+ expect(root_child1.getComputedTop()).toBe(40)
1629
+ expect(root_child1.getComputedWidth()).toBe(50)
1630
+ expect(root_child1.getComputedHeight()).toBe(50)
1631
+
1632
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
1633
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1634
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
1635
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
1636
+
1637
+ expect(root_child2.getComputedLeft()).toBe(0)
1638
+ expect(root_child2.getComputedTop()).toBe(100)
1639
+ expect(root_child2.getComputedWidth()).toBe(50)
1640
+ expect(root_child2.getComputedHeight()).toBe(20)
1641
+
1642
+ expect(root_child2_child0.getComputedLeft()).toBe(0)
1643
+ expect(root_child2_child0.getComputedTop()).toBe(0)
1644
+ expect(root_child2_child0.getComputedWidth()).toBe(50)
1645
+ expect(root_child2_child0.getComputedHeight()).toBe(10)
1646
+
1647
+ expect(root_child3.getComputedLeft()).toBe(50)
1648
+ expect(root_child3.getComputedTop()).toBe(90)
1649
+ expect(root_child3.getComputedWidth()).toBe(50)
1650
+ expect(root_child3.getComputedHeight()).toBe(20)
1651
+
1652
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1653
+
1654
+ expect(root.getComputedLeft()).toBe(0)
1655
+ expect(root.getComputedTop()).toBe(0)
1656
+ expect(root.getComputedWidth()).toBe(100)
1657
+ expect(root.getComputedHeight()).toBe(100)
1658
+
1659
+ expect(root_child0.getComputedLeft()).toBe(50)
1660
+ expect(root_child0.getComputedTop()).toBe(0)
1661
+ expect(root_child0.getComputedWidth()).toBe(50)
1662
+ expect(root_child0.getComputedHeight()).toBe(50)
1663
+
1664
+ expect(root_child1.getComputedLeft()).toBe(0)
1665
+ expect(root_child1.getComputedTop()).toBe(40)
1666
+ expect(root_child1.getComputedWidth()).toBe(50)
1667
+ expect(root_child1.getComputedHeight()).toBe(50)
1668
+
1669
+ expect(root_child1_child0.getComputedLeft()).toBe(0)
1670
+ expect(root_child1_child0.getComputedTop()).toBe(0)
1671
+ expect(root_child1_child0.getComputedWidth()).toBe(50)
1672
+ expect(root_child1_child0.getComputedHeight()).toBe(10)
1673
+
1674
+ expect(root_child2.getComputedLeft()).toBe(50)
1675
+ expect(root_child2.getComputedTop()).toBe(100)
1676
+ expect(root_child2.getComputedWidth()).toBe(50)
1677
+ expect(root_child2.getComputedHeight()).toBe(20)
1678
+
1679
+ expect(root_child2_child0.getComputedLeft()).toBe(0)
1680
+ expect(root_child2_child0.getComputedTop()).toBe(0)
1681
+ expect(root_child2_child0.getComputedWidth()).toBe(50)
1682
+ expect(root_child2_child0.getComputedHeight()).toBe(10)
1683
+
1684
+ expect(root_child3.getComputedLeft()).toBe(0)
1685
+ expect(root_child3.getComputedTop()).toBe(90)
1686
+ expect(root_child3.getComputedWidth()).toBe(50)
1687
+ expect(root_child3.getComputedHeight()).toBe(20)
1688
+ } finally {
1689
+ if (typeof root !== "undefined") {
1690
+ root.freeRecursive()
1691
+ }
1692
+
1693
+ config.free()
1694
+ }
1695
+ })
1696
+ test("align_items_center_child_with_margin_bigger_than_parent", () => {
1697
+ const config = Yoga.Config.create()
1698
+ let root
1699
+
1700
+ try {
1701
+ root = Yoga.Node.create(config)
1702
+ root.setJustifyContent(Justify.Center)
1703
+ root.setAlignItems(Align.Center)
1704
+ root.setPositionType(PositionType.Absolute)
1705
+ root.setWidth(52)
1706
+ root.setHeight(52)
1707
+
1708
+ const root_child0 = Yoga.Node.create(config)
1709
+ root_child0.setAlignItems(Align.Center)
1710
+ root.insertChild(root_child0, 0)
1711
+
1712
+ const root_child0_child0 = Yoga.Node.create(config)
1713
+ root_child0_child0.setMargin(Edge.Left, 10)
1714
+ root_child0_child0.setMargin(Edge.Right, 10)
1715
+ root_child0_child0.setWidth(52)
1716
+ root_child0_child0.setHeight(52)
1717
+ root_child0.insertChild(root_child0_child0, 0)
1718
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1719
+
1720
+ expect(root.getComputedLeft()).toBe(0)
1721
+ expect(root.getComputedTop()).toBe(0)
1722
+ expect(root.getComputedWidth()).toBe(52)
1723
+ expect(root.getComputedHeight()).toBe(52)
1724
+
1725
+ expect(root_child0.getComputedLeft()).toBe(-10)
1726
+ expect(root_child0.getComputedTop()).toBe(0)
1727
+ expect(root_child0.getComputedWidth()).toBe(72)
1728
+ expect(root_child0.getComputedHeight()).toBe(52)
1729
+
1730
+ expect(root_child0_child0.getComputedLeft()).toBe(10)
1731
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1732
+ expect(root_child0_child0.getComputedWidth()).toBe(52)
1733
+ expect(root_child0_child0.getComputedHeight()).toBe(52)
1734
+
1735
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1736
+
1737
+ expect(root.getComputedLeft()).toBe(0)
1738
+ expect(root.getComputedTop()).toBe(0)
1739
+ expect(root.getComputedWidth()).toBe(52)
1740
+ expect(root.getComputedHeight()).toBe(52)
1741
+
1742
+ expect(root_child0.getComputedLeft()).toBe(-10)
1743
+ expect(root_child0.getComputedTop()).toBe(0)
1744
+ expect(root_child0.getComputedWidth()).toBe(72)
1745
+ expect(root_child0.getComputedHeight()).toBe(52)
1746
+
1747
+ expect(root_child0_child0.getComputedLeft()).toBe(10)
1748
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1749
+ expect(root_child0_child0.getComputedWidth()).toBe(52)
1750
+ expect(root_child0_child0.getComputedHeight()).toBe(52)
1751
+ } finally {
1752
+ if (typeof root !== "undefined") {
1753
+ root.freeRecursive()
1754
+ }
1755
+
1756
+ config.free()
1757
+ }
1758
+ })
1759
+ test("align_items_flex_end_child_with_margin_bigger_than_parent", () => {
1760
+ const config = Yoga.Config.create()
1761
+ let root
1762
+
1763
+ try {
1764
+ root = Yoga.Node.create(config)
1765
+ root.setJustifyContent(Justify.Center)
1766
+ root.setAlignItems(Align.Center)
1767
+ root.setPositionType(PositionType.Absolute)
1768
+ root.setWidth(52)
1769
+ root.setHeight(52)
1770
+
1771
+ const root_child0 = Yoga.Node.create(config)
1772
+ root_child0.setAlignItems(Align.FlexEnd)
1773
+ root.insertChild(root_child0, 0)
1774
+
1775
+ const root_child0_child0 = Yoga.Node.create(config)
1776
+ root_child0_child0.setMargin(Edge.Left, 10)
1777
+ root_child0_child0.setMargin(Edge.Right, 10)
1778
+ root_child0_child0.setWidth(52)
1779
+ root_child0_child0.setHeight(52)
1780
+ root_child0.insertChild(root_child0_child0, 0)
1781
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1782
+
1783
+ expect(root.getComputedLeft()).toBe(0)
1784
+ expect(root.getComputedTop()).toBe(0)
1785
+ expect(root.getComputedWidth()).toBe(52)
1786
+ expect(root.getComputedHeight()).toBe(52)
1787
+
1788
+ expect(root_child0.getComputedLeft()).toBe(-10)
1789
+ expect(root_child0.getComputedTop()).toBe(0)
1790
+ expect(root_child0.getComputedWidth()).toBe(72)
1791
+ expect(root_child0.getComputedHeight()).toBe(52)
1792
+
1793
+ expect(root_child0_child0.getComputedLeft()).toBe(10)
1794
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1795
+ expect(root_child0_child0.getComputedWidth()).toBe(52)
1796
+ expect(root_child0_child0.getComputedHeight()).toBe(52)
1797
+
1798
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1799
+
1800
+ expect(root.getComputedLeft()).toBe(0)
1801
+ expect(root.getComputedTop()).toBe(0)
1802
+ expect(root.getComputedWidth()).toBe(52)
1803
+ expect(root.getComputedHeight()).toBe(52)
1804
+
1805
+ expect(root_child0.getComputedLeft()).toBe(-10)
1806
+ expect(root_child0.getComputedTop()).toBe(0)
1807
+ expect(root_child0.getComputedWidth()).toBe(72)
1808
+ expect(root_child0.getComputedHeight()).toBe(52)
1809
+
1810
+ expect(root_child0_child0.getComputedLeft()).toBe(10)
1811
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1812
+ expect(root_child0_child0.getComputedWidth()).toBe(52)
1813
+ expect(root_child0_child0.getComputedHeight()).toBe(52)
1814
+ } finally {
1815
+ if (typeof root !== "undefined") {
1816
+ root.freeRecursive()
1817
+ }
1818
+
1819
+ config.free()
1820
+ }
1821
+ })
1822
+ test("align_items_center_child_without_margin_bigger_than_parent", () => {
1823
+ const config = Yoga.Config.create()
1824
+ let root
1825
+
1826
+ try {
1827
+ root = Yoga.Node.create(config)
1828
+ root.setJustifyContent(Justify.Center)
1829
+ root.setAlignItems(Align.Center)
1830
+ root.setPositionType(PositionType.Absolute)
1831
+ root.setWidth(52)
1832
+ root.setHeight(52)
1833
+
1834
+ const root_child0 = Yoga.Node.create(config)
1835
+ root_child0.setAlignItems(Align.Center)
1836
+ root.insertChild(root_child0, 0)
1837
+
1838
+ const root_child0_child0 = Yoga.Node.create(config)
1839
+ root_child0_child0.setWidth(72)
1840
+ root_child0_child0.setHeight(72)
1841
+ root_child0.insertChild(root_child0_child0, 0)
1842
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1843
+
1844
+ expect(root.getComputedLeft()).toBe(0)
1845
+ expect(root.getComputedTop()).toBe(0)
1846
+ expect(root.getComputedWidth()).toBe(52)
1847
+ expect(root.getComputedHeight()).toBe(52)
1848
+
1849
+ expect(root_child0.getComputedLeft()).toBe(-10)
1850
+ expect(root_child0.getComputedTop()).toBe(-10)
1851
+ expect(root_child0.getComputedWidth()).toBe(72)
1852
+ expect(root_child0.getComputedHeight()).toBe(72)
1853
+
1854
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1855
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1856
+ expect(root_child0_child0.getComputedWidth()).toBe(72)
1857
+ expect(root_child0_child0.getComputedHeight()).toBe(72)
1858
+
1859
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1860
+
1861
+ expect(root.getComputedLeft()).toBe(0)
1862
+ expect(root.getComputedTop()).toBe(0)
1863
+ expect(root.getComputedWidth()).toBe(52)
1864
+ expect(root.getComputedHeight()).toBe(52)
1865
+
1866
+ expect(root_child0.getComputedLeft()).toBe(-10)
1867
+ expect(root_child0.getComputedTop()).toBe(-10)
1868
+ expect(root_child0.getComputedWidth()).toBe(72)
1869
+ expect(root_child0.getComputedHeight()).toBe(72)
1870
+
1871
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1872
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1873
+ expect(root_child0_child0.getComputedWidth()).toBe(72)
1874
+ expect(root_child0_child0.getComputedHeight()).toBe(72)
1875
+ } finally {
1876
+ if (typeof root !== "undefined") {
1877
+ root.freeRecursive()
1878
+ }
1879
+
1880
+ config.free()
1881
+ }
1882
+ })
1883
+ test("align_items_flex_end_child_without_margin_bigger_than_parent", () => {
1884
+ const config = Yoga.Config.create()
1885
+ let root
1886
+
1887
+ try {
1888
+ root = Yoga.Node.create(config)
1889
+ root.setJustifyContent(Justify.Center)
1890
+ root.setAlignItems(Align.Center)
1891
+ root.setPositionType(PositionType.Absolute)
1892
+ root.setWidth(52)
1893
+ root.setHeight(52)
1894
+
1895
+ const root_child0 = Yoga.Node.create(config)
1896
+ root_child0.setAlignItems(Align.FlexEnd)
1897
+ root.insertChild(root_child0, 0)
1898
+
1899
+ const root_child0_child0 = Yoga.Node.create(config)
1900
+ root_child0_child0.setWidth(72)
1901
+ root_child0_child0.setHeight(72)
1902
+ root_child0.insertChild(root_child0_child0, 0)
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(52)
1908
+ expect(root.getComputedHeight()).toBe(52)
1909
+
1910
+ expect(root_child0.getComputedLeft()).toBe(-10)
1911
+ expect(root_child0.getComputedTop()).toBe(-10)
1912
+ expect(root_child0.getComputedWidth()).toBe(72)
1913
+ expect(root_child0.getComputedHeight()).toBe(72)
1914
+
1915
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1916
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1917
+ expect(root_child0_child0.getComputedWidth()).toBe(72)
1918
+ expect(root_child0_child0.getComputedHeight()).toBe(72)
1919
+
1920
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1921
+
1922
+ expect(root.getComputedLeft()).toBe(0)
1923
+ expect(root.getComputedTop()).toBe(0)
1924
+ expect(root.getComputedWidth()).toBe(52)
1925
+ expect(root.getComputedHeight()).toBe(52)
1926
+
1927
+ expect(root_child0.getComputedLeft()).toBe(-10)
1928
+ expect(root_child0.getComputedTop()).toBe(-10)
1929
+ expect(root_child0.getComputedWidth()).toBe(72)
1930
+ expect(root_child0.getComputedHeight()).toBe(72)
1931
+
1932
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1933
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1934
+ expect(root_child0_child0.getComputedWidth()).toBe(72)
1935
+ expect(root_child0_child0.getComputedHeight()).toBe(72)
1936
+ } finally {
1937
+ if (typeof root !== "undefined") {
1938
+ root.freeRecursive()
1939
+ }
1940
+
1941
+ config.free()
1942
+ }
1943
+ })
1944
+ test("align_center_should_size_based_on_content", () => {
1945
+ const config = Yoga.Config.create()
1946
+ let root
1947
+
1948
+ try {
1949
+ root = Yoga.Node.create(config)
1950
+ root.setAlignItems(Align.Center)
1951
+ root.setPositionType(PositionType.Absolute)
1952
+ root.setMargin(Edge.Top, 20)
1953
+ root.setWidth(100)
1954
+ root.setHeight(100)
1955
+
1956
+ const root_child0 = Yoga.Node.create(config)
1957
+ root_child0.setJustifyContent(Justify.Center)
1958
+ root_child0.setFlexShrink(1)
1959
+ root.insertChild(root_child0, 0)
1960
+
1961
+ const root_child0_child0 = Yoga.Node.create(config)
1962
+ root_child0_child0.setFlexGrow(1)
1963
+ root_child0_child0.setFlexShrink(1)
1964
+ root_child0.insertChild(root_child0_child0, 0)
1965
+
1966
+ const root_child0_child0_child0 = Yoga.Node.create(config)
1967
+ root_child0_child0_child0.setWidth(20)
1968
+ root_child0_child0_child0.setHeight(20)
1969
+ root_child0_child0.insertChild(root_child0_child0_child0, 0)
1970
+ root.calculateLayout(undefined, undefined, Direction.LTR)
1971
+
1972
+ expect(root.getComputedLeft()).toBe(0)
1973
+ expect(root.getComputedTop()).toBe(20)
1974
+ expect(root.getComputedWidth()).toBe(100)
1975
+ expect(root.getComputedHeight()).toBe(100)
1976
+
1977
+ expect(root_child0.getComputedLeft()).toBe(40)
1978
+ expect(root_child0.getComputedTop()).toBe(0)
1979
+ expect(root_child0.getComputedWidth()).toBe(20)
1980
+ expect(root_child0.getComputedHeight()).toBe(20)
1981
+
1982
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
1983
+ expect(root_child0_child0.getComputedTop()).toBe(0)
1984
+ expect(root_child0_child0.getComputedWidth()).toBe(20)
1985
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
1986
+
1987
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
1988
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
1989
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(20)
1990
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(20)
1991
+
1992
+ root.calculateLayout(undefined, undefined, Direction.RTL)
1993
+
1994
+ expect(root.getComputedLeft()).toBe(0)
1995
+ expect(root.getComputedTop()).toBe(20)
1996
+ expect(root.getComputedWidth()).toBe(100)
1997
+ expect(root.getComputedHeight()).toBe(100)
1998
+
1999
+ expect(root_child0.getComputedLeft()).toBe(40)
2000
+ expect(root_child0.getComputedTop()).toBe(0)
2001
+ expect(root_child0.getComputedWidth()).toBe(20)
2002
+ expect(root_child0.getComputedHeight()).toBe(20)
2003
+
2004
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
2005
+ expect(root_child0_child0.getComputedTop()).toBe(0)
2006
+ expect(root_child0_child0.getComputedWidth()).toBe(20)
2007
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
2008
+
2009
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
2010
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
2011
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(20)
2012
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(20)
2013
+ } finally {
2014
+ if (typeof root !== "undefined") {
2015
+ root.freeRecursive()
2016
+ }
2017
+
2018
+ config.free()
2019
+ }
2020
+ })
2021
+ test("align_stretch_should_size_based_on_parent", () => {
2022
+ const config = Yoga.Config.create()
2023
+ let root
2024
+
2025
+ try {
2026
+ root = Yoga.Node.create(config)
2027
+ root.setPositionType(PositionType.Absolute)
2028
+ root.setMargin(Edge.Top, 20)
2029
+ root.setWidth(100)
2030
+ root.setHeight(100)
2031
+
2032
+ const root_child0 = Yoga.Node.create(config)
2033
+ root_child0.setJustifyContent(Justify.Center)
2034
+ root_child0.setFlexShrink(1)
2035
+ root.insertChild(root_child0, 0)
2036
+
2037
+ const root_child0_child0 = Yoga.Node.create(config)
2038
+ root_child0_child0.setFlexGrow(1)
2039
+ root_child0_child0.setFlexShrink(1)
2040
+ root_child0.insertChild(root_child0_child0, 0)
2041
+
2042
+ const root_child0_child0_child0 = Yoga.Node.create(config)
2043
+ root_child0_child0_child0.setWidth(20)
2044
+ root_child0_child0_child0.setHeight(20)
2045
+ root_child0_child0.insertChild(root_child0_child0_child0, 0)
2046
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2047
+
2048
+ expect(root.getComputedLeft()).toBe(0)
2049
+ expect(root.getComputedTop()).toBe(20)
2050
+ expect(root.getComputedWidth()).toBe(100)
2051
+ expect(root.getComputedHeight()).toBe(100)
2052
+
2053
+ expect(root_child0.getComputedLeft()).toBe(0)
2054
+ expect(root_child0.getComputedTop()).toBe(0)
2055
+ expect(root_child0.getComputedWidth()).toBe(100)
2056
+ expect(root_child0.getComputedHeight()).toBe(20)
2057
+
2058
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
2059
+ expect(root_child0_child0.getComputedTop()).toBe(0)
2060
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
2061
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
2062
+
2063
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
2064
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
2065
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(20)
2066
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(20)
2067
+
2068
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2069
+
2070
+ expect(root.getComputedLeft()).toBe(0)
2071
+ expect(root.getComputedTop()).toBe(20)
2072
+ expect(root.getComputedWidth()).toBe(100)
2073
+ expect(root.getComputedHeight()).toBe(100)
2074
+
2075
+ expect(root_child0.getComputedLeft()).toBe(0)
2076
+ expect(root_child0.getComputedTop()).toBe(0)
2077
+ expect(root_child0.getComputedWidth()).toBe(100)
2078
+ expect(root_child0.getComputedHeight()).toBe(20)
2079
+
2080
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
2081
+ expect(root_child0_child0.getComputedTop()).toBe(0)
2082
+ expect(root_child0_child0.getComputedWidth()).toBe(100)
2083
+ expect(root_child0_child0.getComputedHeight()).toBe(20)
2084
+
2085
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(80)
2086
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
2087
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(20)
2088
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(20)
2089
+ } finally {
2090
+ if (typeof root !== "undefined") {
2091
+ root.freeRecursive()
2092
+ }
2093
+
2094
+ config.free()
2095
+ }
2096
+ })
2097
+ test("align_flex_start_with_shrinking_children", () => {
2098
+ const config = Yoga.Config.create()
2099
+ let root
2100
+
2101
+ try {
2102
+ root = Yoga.Node.create(config)
2103
+ root.setPositionType(PositionType.Absolute)
2104
+ root.setWidth(500)
2105
+ root.setHeight(500)
2106
+
2107
+ const root_child0 = Yoga.Node.create(config)
2108
+ root_child0.setAlignItems(Align.FlexStart)
2109
+ root.insertChild(root_child0, 0)
2110
+
2111
+ const root_child0_child0 = Yoga.Node.create(config)
2112
+ root_child0_child0.setFlexGrow(1)
2113
+ root_child0_child0.setFlexShrink(1)
2114
+ root_child0.insertChild(root_child0_child0, 0)
2115
+
2116
+ const root_child0_child0_child0 = Yoga.Node.create(config)
2117
+ root_child0_child0_child0.setFlexGrow(1)
2118
+ root_child0_child0_child0.setFlexShrink(1)
2119
+ root_child0_child0.insertChild(root_child0_child0_child0, 0)
2120
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2121
+
2122
+ expect(root.getComputedLeft()).toBe(0)
2123
+ expect(root.getComputedTop()).toBe(0)
2124
+ expect(root.getComputedWidth()).toBe(500)
2125
+ expect(root.getComputedHeight()).toBe(500)
2126
+
2127
+ expect(root_child0.getComputedLeft()).toBe(0)
2128
+ expect(root_child0.getComputedTop()).toBe(0)
2129
+ expect(root_child0.getComputedWidth()).toBe(500)
2130
+ expect(root_child0.getComputedHeight()).toBe(0)
2131
+
2132
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
2133
+ expect(root_child0_child0.getComputedTop()).toBe(0)
2134
+ expect(root_child0_child0.getComputedWidth()).toBe(0)
2135
+ expect(root_child0_child0.getComputedHeight()).toBe(0)
2136
+
2137
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
2138
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
2139
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(0)
2140
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(0)
2141
+
2142
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2143
+
2144
+ expect(root.getComputedLeft()).toBe(0)
2145
+ expect(root.getComputedTop()).toBe(0)
2146
+ expect(root.getComputedWidth()).toBe(500)
2147
+ expect(root.getComputedHeight()).toBe(500)
2148
+
2149
+ expect(root_child0.getComputedLeft()).toBe(0)
2150
+ expect(root_child0.getComputedTop()).toBe(0)
2151
+ expect(root_child0.getComputedWidth()).toBe(500)
2152
+ expect(root_child0.getComputedHeight()).toBe(0)
2153
+
2154
+ expect(root_child0_child0.getComputedLeft()).toBe(500)
2155
+ expect(root_child0_child0.getComputedTop()).toBe(0)
2156
+ expect(root_child0_child0.getComputedWidth()).toBe(0)
2157
+ expect(root_child0_child0.getComputedHeight()).toBe(0)
2158
+
2159
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
2160
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
2161
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(0)
2162
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(0)
2163
+ } finally {
2164
+ if (typeof root !== "undefined") {
2165
+ root.freeRecursive()
2166
+ }
2167
+
2168
+ config.free()
2169
+ }
2170
+ })
2171
+ test("align_flex_start_with_stretching_children", () => {
2172
+ const config = Yoga.Config.create()
2173
+ let root
2174
+
2175
+ try {
2176
+ root = Yoga.Node.create(config)
2177
+ root.setPositionType(PositionType.Absolute)
2178
+ root.setWidth(500)
2179
+ root.setHeight(500)
2180
+
2181
+ const root_child0 = Yoga.Node.create(config)
2182
+ root.insertChild(root_child0, 0)
2183
+
2184
+ const root_child0_child0 = Yoga.Node.create(config)
2185
+ root_child0_child0.setFlexGrow(1)
2186
+ root_child0_child0.setFlexShrink(1)
2187
+ root_child0.insertChild(root_child0_child0, 0)
2188
+
2189
+ const root_child0_child0_child0 = Yoga.Node.create(config)
2190
+ root_child0_child0_child0.setFlexGrow(1)
2191
+ root_child0_child0_child0.setFlexShrink(1)
2192
+ root_child0_child0.insertChild(root_child0_child0_child0, 0)
2193
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2194
+
2195
+ expect(root.getComputedLeft()).toBe(0)
2196
+ expect(root.getComputedTop()).toBe(0)
2197
+ expect(root.getComputedWidth()).toBe(500)
2198
+ expect(root.getComputedHeight()).toBe(500)
2199
+
2200
+ expect(root_child0.getComputedLeft()).toBe(0)
2201
+ expect(root_child0.getComputedTop()).toBe(0)
2202
+ expect(root_child0.getComputedWidth()).toBe(500)
2203
+ expect(root_child0.getComputedHeight()).toBe(0)
2204
+
2205
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
2206
+ expect(root_child0_child0.getComputedTop()).toBe(0)
2207
+ expect(root_child0_child0.getComputedWidth()).toBe(500)
2208
+ expect(root_child0_child0.getComputedHeight()).toBe(0)
2209
+
2210
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
2211
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
2212
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(500)
2213
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(0)
2214
+
2215
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2216
+
2217
+ expect(root.getComputedLeft()).toBe(0)
2218
+ expect(root.getComputedTop()).toBe(0)
2219
+ expect(root.getComputedWidth()).toBe(500)
2220
+ expect(root.getComputedHeight()).toBe(500)
2221
+
2222
+ expect(root_child0.getComputedLeft()).toBe(0)
2223
+ expect(root_child0.getComputedTop()).toBe(0)
2224
+ expect(root_child0.getComputedWidth()).toBe(500)
2225
+ expect(root_child0.getComputedHeight()).toBe(0)
2226
+
2227
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
2228
+ expect(root_child0_child0.getComputedTop()).toBe(0)
2229
+ expect(root_child0_child0.getComputedWidth()).toBe(500)
2230
+ expect(root_child0_child0.getComputedHeight()).toBe(0)
2231
+
2232
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
2233
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
2234
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(500)
2235
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(0)
2236
+ } finally {
2237
+ if (typeof root !== "undefined") {
2238
+ root.freeRecursive()
2239
+ }
2240
+
2241
+ config.free()
2242
+ }
2243
+ })
2244
+ test("align_flex_start_with_shrinking_children_with_stretch", () => {
2245
+ const config = Yoga.Config.create()
2246
+ let root
2247
+
2248
+ try {
2249
+ root = Yoga.Node.create(config)
2250
+ root.setPositionType(PositionType.Absolute)
2251
+ root.setWidth(500)
2252
+ root.setHeight(500)
2253
+
2254
+ const root_child0 = Yoga.Node.create(config)
2255
+ root_child0.setAlignItems(Align.FlexStart)
2256
+ root.insertChild(root_child0, 0)
2257
+
2258
+ const root_child0_child0 = Yoga.Node.create(config)
2259
+ root_child0_child0.setFlexGrow(1)
2260
+ root_child0_child0.setFlexShrink(1)
2261
+ root_child0.insertChild(root_child0_child0, 0)
2262
+
2263
+ const root_child0_child0_child0 = Yoga.Node.create(config)
2264
+ root_child0_child0_child0.setFlexGrow(1)
2265
+ root_child0_child0_child0.setFlexShrink(1)
2266
+ root_child0_child0.insertChild(root_child0_child0_child0, 0)
2267
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2268
+
2269
+ expect(root.getComputedLeft()).toBe(0)
2270
+ expect(root.getComputedTop()).toBe(0)
2271
+ expect(root.getComputedWidth()).toBe(500)
2272
+ expect(root.getComputedHeight()).toBe(500)
2273
+
2274
+ expect(root_child0.getComputedLeft()).toBe(0)
2275
+ expect(root_child0.getComputedTop()).toBe(0)
2276
+ expect(root_child0.getComputedWidth()).toBe(500)
2277
+ expect(root_child0.getComputedHeight()).toBe(0)
2278
+
2279
+ expect(root_child0_child0.getComputedLeft()).toBe(0)
2280
+ expect(root_child0_child0.getComputedTop()).toBe(0)
2281
+ expect(root_child0_child0.getComputedWidth()).toBe(0)
2282
+ expect(root_child0_child0.getComputedHeight()).toBe(0)
2283
+
2284
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
2285
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
2286
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(0)
2287
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(0)
2288
+
2289
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2290
+
2291
+ expect(root.getComputedLeft()).toBe(0)
2292
+ expect(root.getComputedTop()).toBe(0)
2293
+ expect(root.getComputedWidth()).toBe(500)
2294
+ expect(root.getComputedHeight()).toBe(500)
2295
+
2296
+ expect(root_child0.getComputedLeft()).toBe(0)
2297
+ expect(root_child0.getComputedTop()).toBe(0)
2298
+ expect(root_child0.getComputedWidth()).toBe(500)
2299
+ expect(root_child0.getComputedHeight()).toBe(0)
2300
+
2301
+ expect(root_child0_child0.getComputedLeft()).toBe(500)
2302
+ expect(root_child0_child0.getComputedTop()).toBe(0)
2303
+ expect(root_child0_child0.getComputedWidth()).toBe(0)
2304
+ expect(root_child0_child0.getComputedHeight()).toBe(0)
2305
+
2306
+ expect(root_child0_child0_child0.getComputedLeft()).toBe(0)
2307
+ expect(root_child0_child0_child0.getComputedTop()).toBe(0)
2308
+ expect(root_child0_child0_child0.getComputedWidth()).toBe(0)
2309
+ expect(root_child0_child0_child0.getComputedHeight()).toBe(0)
2310
+ } finally {
2311
+ if (typeof root !== "undefined") {
2312
+ root.freeRecursive()
2313
+ }
2314
+
2315
+ config.free()
2316
+ }
2317
+ })
2318
+ test("align_flex_end_with_row_reverse", () => {
2319
+ const config = Yoga.Config.create()
2320
+ let root
2321
+
2322
+ try {
2323
+ root = Yoga.Node.create(config)
2324
+ root.setAlignItems(Align.FlexEnd)
2325
+ root.setPositionType(PositionType.Absolute)
2326
+ root.setFlexWrap(Wrap.Wrap)
2327
+ root.setWidth(100)
2328
+ root.setHeight(75)
2329
+
2330
+ const root_child0 = Yoga.Node.create(config)
2331
+ root_child0.setMargin(Edge.Left, 3)
2332
+ root_child0.setMargin(Edge.Right, 5)
2333
+ root_child0.setWidth(50)
2334
+ root_child0.setHeight(50)
2335
+ root.insertChild(root_child0, 0)
2336
+
2337
+ const root_child1 = Yoga.Node.create(config)
2338
+ root_child1.setWidth(50)
2339
+ root_child1.setHeight(50)
2340
+ root.insertChild(root_child1, 1)
2341
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2342
+
2343
+ expect(root.getComputedLeft()).toBe(0)
2344
+ expect(root.getComputedTop()).toBe(0)
2345
+ expect(root.getComputedWidth()).toBe(100)
2346
+ expect(root.getComputedHeight()).toBe(75)
2347
+
2348
+ expect(root_child0.getComputedLeft()).toBe(3)
2349
+ expect(root_child0.getComputedTop()).toBe(0)
2350
+ expect(root_child0.getComputedWidth()).toBe(50)
2351
+ expect(root_child0.getComputedHeight()).toBe(50)
2352
+
2353
+ expect(root_child1.getComputedLeft()).toBe(58)
2354
+ expect(root_child1.getComputedTop()).toBe(0)
2355
+ expect(root_child1.getComputedWidth()).toBe(50)
2356
+ expect(root_child1.getComputedHeight()).toBe(50)
2357
+
2358
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2359
+
2360
+ expect(root.getComputedLeft()).toBe(0)
2361
+ expect(root.getComputedTop()).toBe(0)
2362
+ expect(root.getComputedWidth()).toBe(100)
2363
+ expect(root.getComputedHeight()).toBe(75)
2364
+
2365
+ expect(root_child0.getComputedLeft()).toBe(45)
2366
+ expect(root_child0.getComputedTop()).toBe(0)
2367
+ expect(root_child0.getComputedWidth()).toBe(50)
2368
+ expect(root_child0.getComputedHeight()).toBe(50)
2369
+
2370
+ expect(root_child1.getComputedLeft()).toBe(-8)
2371
+ expect(root_child1.getComputedTop()).toBe(0)
2372
+ expect(root_child1.getComputedWidth()).toBe(50)
2373
+ expect(root_child1.getComputedHeight()).toBe(50)
2374
+ } finally {
2375
+ if (typeof root !== "undefined") {
2376
+ root.freeRecursive()
2377
+ }
2378
+
2379
+ config.free()
2380
+ }
2381
+ })
2382
+ test("align_stretch_with_row_reverse", () => {
2383
+ const config = Yoga.Config.create()
2384
+ let root
2385
+
2386
+ try {
2387
+ root = Yoga.Node.create(config)
2388
+ root.setPositionType(PositionType.Absolute)
2389
+ root.setFlexWrap(Wrap.Wrap)
2390
+ root.setWidth(100)
2391
+ root.setHeight(75)
2392
+
2393
+ const root_child0 = Yoga.Node.create(config)
2394
+ root_child0.setMargin(Edge.Left, 3)
2395
+ root_child0.setMargin(Edge.Right, 5)
2396
+ root_child0.setWidth(50)
2397
+ root_child0.setHeight(50)
2398
+ root.insertChild(root_child0, 0)
2399
+
2400
+ const root_child1 = Yoga.Node.create(config)
2401
+ root_child1.setWidth(50)
2402
+ root_child1.setHeight(50)
2403
+ root.insertChild(root_child1, 1)
2404
+ root.calculateLayout(undefined, undefined, Direction.LTR)
2405
+
2406
+ expect(root.getComputedLeft()).toBe(0)
2407
+ expect(root.getComputedTop()).toBe(0)
2408
+ expect(root.getComputedWidth()).toBe(100)
2409
+ expect(root.getComputedHeight()).toBe(75)
2410
+
2411
+ expect(root_child0.getComputedLeft()).toBe(3)
2412
+ expect(root_child0.getComputedTop()).toBe(0)
2413
+ expect(root_child0.getComputedWidth()).toBe(50)
2414
+ expect(root_child0.getComputedHeight()).toBe(50)
2415
+
2416
+ expect(root_child1.getComputedLeft()).toBe(58)
2417
+ expect(root_child1.getComputedTop()).toBe(0)
2418
+ expect(root_child1.getComputedWidth()).toBe(50)
2419
+ expect(root_child1.getComputedHeight()).toBe(50)
2420
+
2421
+ root.calculateLayout(undefined, undefined, Direction.RTL)
2422
+
2423
+ expect(root.getComputedLeft()).toBe(0)
2424
+ expect(root.getComputedTop()).toBe(0)
2425
+ expect(root.getComputedWidth()).toBe(100)
2426
+ expect(root.getComputedHeight()).toBe(75)
2427
+
2428
+ expect(root_child0.getComputedLeft()).toBe(45)
2429
+ expect(root_child0.getComputedTop()).toBe(0)
2430
+ expect(root_child0.getComputedWidth()).toBe(50)
2431
+ expect(root_child0.getComputedHeight()).toBe(50)
2432
+
2433
+ expect(root_child1.getComputedLeft()).toBe(-8)
2434
+ expect(root_child1.getComputedTop()).toBe(0)
2435
+ expect(root_child1.getComputedWidth()).toBe(50)
2436
+ expect(root_child1.getComputedHeight()).toBe(50)
2437
+ } finally {
2438
+ if (typeof root !== "undefined") {
2439
+ root.freeRecursive()
2440
+ }
2441
+
2442
+ config.free()
2443
+ }
2444
+ })