react-nitro-yoga 0.0.0-stage → 0.0.1-alpha.7

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 (529) hide show
  1. package/Generated/.gitattributes +1 -0
  2. package/Generated/api.d.ts +100 -0
  3. package/Generated/ffigen_yoga_adapters.h +52 -0
  4. package/Generated/native.d.ts +84 -0
  5. package/Generated/native.ts +283 -0
  6. package/Generated/yoga.c +1087 -0
  7. package/LICENSE +21 -0
  8. package/Package.swift +57 -0
  9. package/README.md +61 -2
  10. package/Sources/ReactNitroYoga/InstallHermesBindings.cpp +11 -0
  11. package/Sources/ReactNitroYoga/SHUnit.h +16 -0
  12. package/include/ReactNitroYoga/InstallHermesBindings.hpp +12 -0
  13. package/package.json +26 -4
  14. package/yoga/.clang-format +109 -0
  15. package/yoga/.clang-tidy +217 -0
  16. package/yoga/.editorconfig +11 -0
  17. package/yoga/.eslintrc.cjs +84 -0
  18. package/yoga/.github/ISSUE_TEMPLATE.md +21 -0
  19. package/yoga/.github/actions/black/action.yml +25 -0
  20. package/yoga/.github/actions/cache-emsdk/action.yml +10 -0
  21. package/yoga/.github/actions/install-ninja/action.yml +14 -0
  22. package/yoga/.github/actions/setup-android/action.yml +12 -0
  23. package/yoga/.github/actions/setup-apple/action.yml +8 -0
  24. package/yoga/.github/actions/setup-cpp/action.yml +34 -0
  25. package/yoga/.github/actions/setup-js/action.yml +18 -0
  26. package/yoga/.github/workflows/publish-android-release.yml +38 -0
  27. package/yoga/.github/workflows/publish-android-snashot.yml +36 -0
  28. package/yoga/.github/workflows/publish-npm-release.yml +25 -0
  29. package/yoga/.github/workflows/validate-android.yml +30 -0
  30. package/yoga/.github/workflows/validate-cpp.yml +101 -0
  31. package/yoga/.github/workflows/validate-format.yml +36 -0
  32. package/yoga/.github/workflows/validate-js.yml +119 -0
  33. package/yoga/.github/workflows/validate-swiftpm.yml +29 -0
  34. package/yoga/.github/workflows/validate-tests.yml +35 -0
  35. package/yoga/.github/workflows/validate-website.yml +45 -0
  36. package/yoga/.prettierignore +3 -0
  37. package/yoga/.prettierrc.js +16 -0
  38. package/yoga/.vscode/extensions.json +7 -0
  39. package/yoga/.vscode/launch.json +25 -0
  40. package/yoga/.vscode/settings.json +20 -0
  41. package/yoga/.vscode/tasks.json +23 -0
  42. package/yoga/CMakeLists.txt +58 -0
  43. package/yoga/CODE_OF_CONDUCT.md +76 -0
  44. package/yoga/CONTRIBUTING.md +44 -0
  45. package/yoga/LICENSE +21 -0
  46. package/yoga/LICENSE-examples +9 -0
  47. package/yoga/Package.swift +32 -0
  48. package/yoga/README.md +36 -0
  49. package/yoga/benchmark/Benchmark.cpp +400 -0
  50. package/yoga/benchmark/Benchmark.h +39 -0
  51. package/yoga/benchmark/CMakeLists.txt +27 -0
  52. package/yoga/benchmark/TreeDeserialization.cpp +248 -0
  53. package/yoga/benchmark/TreeDeserialization.h +52 -0
  54. package/yoga/benchmark/YGBenchmark.c +183 -0
  55. package/yoga/benchmark/benchmark +15 -0
  56. package/yoga/benchmark/captures/chat-mac.json +24426 -0
  57. package/yoga/benchmark/captures/feed-android.json +10335 -0
  58. package/yoga/benchmark/captures/profile-ios.json +1955 -0
  59. package/yoga/benchmark/captures/rendering-sample-mac.json +1927 -0
  60. package/yoga/build.gradle +46 -0
  61. package/yoga/build_fuzz_tests +28 -0
  62. package/yoga/capture/CMakeLists.txt +23 -0
  63. package/yoga/capture/CaptureTree.cpp +100 -0
  64. package/yoga/capture/CaptureTree.h +47 -0
  65. package/yoga/capture/NodeToString.cpp +359 -0
  66. package/yoga/capture/NodeToString.h +40 -0
  67. package/yoga/cmake/project-defaults.cmake +50 -0
  68. package/yoga/cmake/yoga-config.cmake.in +10 -0
  69. package/yoga/enums.py +394 -0
  70. package/yoga/fuzz/CMakeLists.txt +21 -0
  71. package/yoga/fuzz/FuzzLayout.cpp +57 -0
  72. package/yoga/gentest/babel.config.cjs +12 -0
  73. package/yoga/gentest/fixtures/YGAbsolutePositionTest.html +168 -0
  74. package/yoga/gentest/fixtures/YGAlignContentTest.html +479 -0
  75. package/yoga/gentest/fixtures/YGAlignItemsTest.html +227 -0
  76. package/yoga/gentest/fixtures/YGAlignSelfTest.html +23 -0
  77. package/yoga/gentest/fixtures/YGAndroidNewsFeed.html +28 -0
  78. package/yoga/gentest/fixtures/YGAspectRatioTest.html +3 -0
  79. package/yoga/gentest/fixtures/YGAutoTest.html +25 -0
  80. package/yoga/gentest/fixtures/YGBorderTest.html +18 -0
  81. package/yoga/gentest/fixtures/YGBoxSizingTest.html +240 -0
  82. package/yoga/gentest/fixtures/YGDimensionTest.html +9 -0
  83. package/yoga/gentest/fixtures/YGDisplayTest.html +89 -0
  84. package/yoga/gentest/fixtures/YGFlexBasisFitContentTest.html +55 -0
  85. package/yoga/gentest/fixtures/YGFlexDirectionTest.html +391 -0
  86. package/yoga/gentest/fixtures/YGFlexTest.html +53 -0
  87. package/yoga/gentest/fixtures/YGFlexWrapTest.html +160 -0
  88. package/yoga/gentest/fixtures/YGGapTest.html +233 -0
  89. package/yoga/gentest/fixtures/YGIntrinsicSizeTest.html +295 -0
  90. package/yoga/gentest/fixtures/YGJustifyContentTest.html +164 -0
  91. package/yoga/gentest/fixtures/YGMarginTest.html +157 -0
  92. package/yoga/gentest/fixtures/YGMinMaxDimensionTest.html +116 -0
  93. package/yoga/gentest/fixtures/YGPaddingTest.html +29 -0
  94. package/yoga/gentest/fixtures/YGPercentageTest.html +125 -0
  95. package/yoga/gentest/fixtures/YGRoundingTest.html +95 -0
  96. package/yoga/gentest/fixtures/YGSizeOverflowTest.html +17 -0
  97. package/yoga/gentest/fixtures/YGStaticPositionTest.html +712 -0
  98. package/yoga/gentest/fonts/Ahem.ttf +0 -0
  99. package/yoga/gentest/gentest-driver.ts +141 -0
  100. package/yoga/gentest/gentest-validate.ts +43 -0
  101. package/yoga/gentest/package.json +24 -0
  102. package/yoga/gentest/scripts/gentest-validate.ts +43 -0
  103. package/yoga/gentest/signedsource.d.ts +10 -0
  104. package/yoga/gentest/src/ChromePool.ts +78 -0
  105. package/yoga/gentest/src/CssToYoga.ts +958 -0
  106. package/yoga/gentest/src/buildLayoutTree.ts +98 -0
  107. package/yoga/gentest/src/cli.ts +163 -0
  108. package/yoga/gentest/src/emitters/CppEmitter.ts +452 -0
  109. package/yoga/gentest/src/emitters/Emitter.ts +204 -0
  110. package/yoga/gentest/src/emitters/JavaEmitter.ts +469 -0
  111. package/yoga/gentest/src/emitters/JavascriptEmitter.ts +353 -0
  112. package/yoga/gentest/src/types.ts +41 -0
  113. package/yoga/gentest/test-template.html +42 -0
  114. package/yoga/gentest/tsconfig.json +13 -0
  115. package/yoga/gradle/wrapper/gradle-wrapper.jar +0 -0
  116. package/yoga/gradle/wrapper/gradle-wrapper.properties +7 -0
  117. package/yoga/gradle.properties +14 -0
  118. package/yoga/gradlew +251 -0
  119. package/yoga/gradlew.bat +94 -0
  120. package/yoga/java/AndroidManifest.xml +14 -0
  121. package/yoga/java/CMakeLists.txt +22 -0
  122. package/yoga/java/build.gradle.kts +127 -0
  123. package/yoga/java/com/facebook/yoga/LayoutPassReason.kt +35 -0
  124. package/yoga/java/com/facebook/yoga/YogaAlign.kt +45 -0
  125. package/yoga/java/com/facebook/yoga/YogaBaselineFunction.kt +16 -0
  126. package/yoga/java/com/facebook/yoga/YogaBoxSizing.kt +27 -0
  127. package/yoga/java/com/facebook/yoga/YogaConfig.kt +48 -0
  128. package/yoga/java/com/facebook/yoga/YogaConfigFactory.kt +12 -0
  129. package/yoga/java/com/facebook/yoga/YogaConfigJNIBase.kt +70 -0
  130. package/yoga/java/com/facebook/yoga/YogaConfigJNIFinalizer.kt +30 -0
  131. package/yoga/java/com/facebook/yoga/YogaConstants.kt +18 -0
  132. package/yoga/java/com/facebook/yoga/YogaDimension.kt +27 -0
  133. package/yoga/java/com/facebook/yoga/YogaDirection.kt +29 -0
  134. package/yoga/java/com/facebook/yoga/YogaDisplay.kt +31 -0
  135. package/yoga/java/com/facebook/yoga/YogaEdge.kt +41 -0
  136. package/yoga/java/com/facebook/yoga/YogaErrata.kt +39 -0
  137. package/yoga/java/com/facebook/yoga/YogaExperimentalFeature.kt +27 -0
  138. package/yoga/java/com/facebook/yoga/YogaFlexDirection.kt +31 -0
  139. package/yoga/java/com/facebook/yoga/YogaGridTrackType.kt +33 -0
  140. package/yoga/java/com/facebook/yoga/YogaGutter.kt +29 -0
  141. package/yoga/java/com/facebook/yoga/YogaJustify.kt +43 -0
  142. package/yoga/java/com/facebook/yoga/YogaLayoutType.kt +27 -0
  143. package/yoga/java/com/facebook/yoga/YogaLogLevel.kt +39 -0
  144. package/yoga/java/com/facebook/yoga/YogaLogger.kt +19 -0
  145. package/yoga/java/com/facebook/yoga/YogaMeasureFunction.kt +19 -0
  146. package/yoga/java/com/facebook/yoga/YogaMeasureMode.kt +29 -0
  147. package/yoga/java/com/facebook/yoga/YogaMeasureOutput.kt +29 -0
  148. package/yoga/java/com/facebook/yoga/YogaNative.kt +347 -0
  149. package/yoga/java/com/facebook/yoga/YogaNode.kt +254 -0
  150. package/yoga/java/com/facebook/yoga/YogaNodeFactory.kt +14 -0
  151. package/yoga/java/com/facebook/yoga/YogaNodeJNIBase.kt +762 -0
  152. package/yoga/java/com/facebook/yoga/YogaNodeJNIFinalizer.kt +33 -0
  153. package/yoga/java/com/facebook/yoga/YogaNodeType.kt +27 -0
  154. package/yoga/java/com/facebook/yoga/YogaOverflow.kt +29 -0
  155. package/yoga/java/com/facebook/yoga/YogaPositionType.kt +29 -0
  156. package/yoga/java/com/facebook/yoga/YogaProps.kt +205 -0
  157. package/yoga/java/com/facebook/yoga/YogaStyleInputs.kt +51 -0
  158. package/yoga/java/com/facebook/yoga/YogaUnit.kt +37 -0
  159. package/yoga/java/com/facebook/yoga/YogaValue.kt +66 -0
  160. package/yoga/java/com/facebook/yoga/YogaWrap.kt +29 -0
  161. package/yoga/java/com/facebook/yoga/annotations/DoNotStrip.kt +19 -0
  162. package/yoga/java/gen/com/facebook/yoga/BuildConfig.java +15 -0
  163. package/yoga/java/jni/LayoutContext.cpp +34 -0
  164. package/yoga/java/jni/LayoutContext.h +29 -0
  165. package/yoga/java/jni/ScopedGlobalRef.h +140 -0
  166. package/yoga/java/jni/ScopedLocalRef.h +141 -0
  167. package/yoga/java/jni/YGJNI.h +77 -0
  168. package/yoga/java/jni/YGJNIVanilla.cpp +1178 -0
  169. package/yoga/java/jni/YGJNIVanilla.h +12 -0
  170. package/yoga/java/jni/YGJTypesVanilla.h +52 -0
  171. package/yoga/java/jni/YogaJniException.cpp +49 -0
  172. package/yoga/java/jni/YogaJniException.h +35 -0
  173. package/yoga/java/jni/common.cpp +109 -0
  174. package/yoga/java/jni/common.h +73 -0
  175. package/yoga/java/jni/corefunctions.cpp +91 -0
  176. package/yoga/java/jni/corefunctions.h +50 -0
  177. package/yoga/java/jni/macros.h +23 -0
  178. package/yoga/java/jni/tests/corefunctionsTest.cpp +247 -0
  179. package/yoga/java/jni/yogajni.cpp +18 -0
  180. package/yoga/java/proguard-rules.pro +10 -0
  181. package/yoga/java/res/values/strings.xml +12 -0
  182. package/yoga/java/tests/com/facebook/yoga/TestParametrization.kt +29 -0
  183. package/yoga/java/tests/com/facebook/yoga/YGAlignBaselineTest.kt +117 -0
  184. package/yoga/java/tests/com/facebook/yoga/YogaExceptionTest.kt +140 -0
  185. package/yoga/java/tests/com/facebook/yoga/YogaLoggerTest.kt +77 -0
  186. package/yoga/java/tests/com/facebook/yoga/YogaNodeStylePropertiesTest.kt +1020 -0
  187. package/yoga/java/tests/com/facebook/yoga/YogaNodeTest.kt +319 -0
  188. package/yoga/java/tests/com/facebook/yoga/YogaValueTest.kt +23 -0
  189. package/yoga/java/tests/com/facebook/yoga/utils/TestUtils.kt +99 -0
  190. package/yoga/java/tests/generated/com/facebook/yoga/YGAbsolutePositionTest.java +1670 -0
  191. package/yoga/java/tests/generated/com/facebook/yoga/YGAlignContentTest.java +5440 -0
  192. package/yoga/java/tests/generated/com/facebook/yoga/YGAlignItemsTest.java +2132 -0
  193. package/yoga/java/tests/generated/com/facebook/yoga/YGAlignSelfTest.java +271 -0
  194. package/yoga/java/tests/generated/com/facebook/yoga/YGAndroidNewsFeed.java +313 -0
  195. package/yoga/java/tests/generated/com/facebook/yoga/YGAspectRatioTest.java +73 -0
  196. package/yoga/java/tests/generated/com/facebook/yoga/YGAutoTest.java +326 -0
  197. package/yoga/java/tests/generated/com/facebook/yoga/YGBorderTest.java +222 -0
  198. package/yoga/java/tests/generated/com/facebook/yoga/YGBoxSizingTest.java +2165 -0
  199. package/yoga/java/tests/generated/com/facebook/yoga/YGDimensionTest.java +122 -0
  200. package/yoga/java/tests/generated/com/facebook/yoga/YGDisplayContentsTest.java +107 -0
  201. package/yoga/java/tests/generated/com/facebook/yoga/YGDisplayTest.java +1021 -0
  202. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexBasisFitContentTest.java +391 -0
  203. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexDirectionTest.java +4118 -0
  204. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexTest.java +630 -0
  205. package/yoga/java/tests/generated/com/facebook/yoga/YGFlexWrapTest.java +1863 -0
  206. package/yoga/java/tests/generated/com/facebook/yoga/YGGapTest.java +2988 -0
  207. package/yoga/java/tests/generated/com/facebook/yoga/YGIntrinsicSizeTest.java +926 -0
  208. package/yoga/java/tests/generated/com/facebook/yoga/YGJustifyContentTest.java +1865 -0
  209. package/yoga/java/tests/generated/com/facebook/yoga/YGMarginTest.java +1796 -0
  210. package/yoga/java/tests/generated/com/facebook/yoga/YGMinMaxDimensionTest.java +1210 -0
  211. package/yoga/java/tests/generated/com/facebook/yoga/YGPaddingTest.java +307 -0
  212. package/yoga/java/tests/generated/com/facebook/yoga/YGPercentageTest.java +1345 -0
  213. package/yoga/java/tests/generated/com/facebook/yoga/YGRoundingTest.java +1099 -0
  214. package/yoga/java/tests/generated/com/facebook/yoga/YGSizeOverflowTest.java +195 -0
  215. package/yoga/java/tests/generated/com/facebook/yoga/YGStaticPositionTest.java +5992 -0
  216. package/yoga/java/yogajni.version +13 -0
  217. package/yoga/javascript/CMakeLists.txt +59 -0
  218. package/yoga/javascript/README.md +27 -0
  219. package/yoga/javascript/babel.config.cjs +30 -0
  220. package/yoga/javascript/jest.config.js +14 -0
  221. package/yoga/javascript/jest.setup.js +12 -0
  222. package/yoga/javascript/just.config.cjs +258 -0
  223. package/yoga/javascript/package.json +52 -0
  224. package/yoga/javascript/src/generated/YGEnums.ts +249 -0
  225. package/yoga/javascript/src/index.ts +23 -0
  226. package/yoga/javascript/src/load.ts +25 -0
  227. package/yoga/javascript/src/wasm_bridge.c +155 -0
  228. package/yoga/javascript/src/wrapAssembly.ts +1025 -0
  229. package/yoga/javascript/tests/Benchmarks/YGBenchmark.test.ts +110 -0
  230. package/yoga/javascript/tests/YGAlignBaselineTest.test.ts +104 -0
  231. package/yoga/javascript/tests/YGComputedBorderTest.test.ts +25 -0
  232. package/yoga/javascript/tests/YGComputedMarginTest.test.ts +25 -0
  233. package/yoga/javascript/tests/YGComputedPaddingTest.test.ts +25 -0
  234. package/yoga/javascript/tests/YGDirtiedTest.test.ts +149 -0
  235. package/yoga/javascript/tests/YGErrataTest.test.ts +34 -0
  236. package/yoga/javascript/tests/YGFlexBasisAuto.test.ts +21 -0
  237. package/yoga/javascript/tests/YGHadOverflowTest.test.ts +110 -0
  238. package/yoga/javascript/tests/YGHasNewLayout.test.ts +81 -0
  239. package/yoga/javascript/tests/YGMeasureCacheTest.test.ts +29 -0
  240. package/yoga/javascript/tests/YGMeasureTest.test.ts +66 -0
  241. package/yoga/javascript/tests/bin/run-bench.ts +60 -0
  242. package/yoga/javascript/tests/generated/YGAbsolutePositionTest.test.ts +1531 -0
  243. package/yoga/javascript/tests/generated/YGAlignContentTest.test.ts +5181 -0
  244. package/yoga/javascript/tests/generated/YGAlignItemsTest.test.ts +2013 -0
  245. package/yoga/javascript/tests/generated/YGAlignSelfTest.test.ts +248 -0
  246. package/yoga/javascript/tests/generated/YGAndroidNewsFeed.test.ts +306 -0
  247. package/yoga/javascript/tests/generated/YGAspectRatioTest.test.ts +66 -0
  248. package/yoga/javascript/tests/generated/YGAutoTest.test.ts +303 -0
  249. package/yoga/javascript/tests/generated/YGBorderTest.test.ts +199 -0
  250. package/yoga/javascript/tests/generated/YGBoxSizingTest.test.ts +1978 -0
  251. package/yoga/javascript/tests/generated/YGDimensionTest.test.ts +111 -0
  252. package/yoga/javascript/tests/generated/YGDisplayContentsTest.test.ts +99 -0
  253. package/yoga/javascript/tests/generated/YGDisplayTest.test.ts +962 -0
  254. package/yoga/javascript/tests/generated/YGFlexBasisFitContentTest.test.ts +364 -0
  255. package/yoga/javascript/tests/generated/YGFlexDirectionTest.test.ts +3903 -0
  256. package/yoga/javascript/tests/generated/YGFlexTest.test.ts +587 -0
  257. package/yoga/javascript/tests/generated/YGFlexWrapTest.test.ts +1768 -0
  258. package/yoga/javascript/tests/generated/YGGapTest.test.ts +2857 -0
  259. package/yoga/javascript/tests/generated/YGIntrinsicSizeTest.test.ts +843 -0
  260. package/yoga/javascript/tests/generated/YGJustifyContentTest.test.ts +1750 -0
  261. package/yoga/javascript/tests/generated/YGMarginTest.test.ts +1657 -0
  262. package/yoga/javascript/tests/generated/YGMinMaxDimensionTest.test.ts +1111 -0
  263. package/yoga/javascript/tests/generated/YGPaddingTest.test.ts +276 -0
  264. package/yoga/javascript/tests/generated/YGPercentageTest.test.ts +1246 -0
  265. package/yoga/javascript/tests/generated/YGRoundingTest.test.ts +1044 -0
  266. package/yoga/javascript/tests/generated/YGSizeOverflowTest.test.ts +180 -0
  267. package/yoga/javascript/tests/generated/YGStaticPositionTest.test.ts +5741 -0
  268. package/yoga/javascript/tests/tools/MeasureCounter.ts +66 -0
  269. package/yoga/javascript/tests/tools/globals.ts +19 -0
  270. package/yoga/javascript/tests/tools/utils.ts +90 -0
  271. package/yoga/javascript/tsconfig.json +23 -0
  272. package/yoga/lib/jni/jni.h +13 -0
  273. package/yoga/lib/jni/real/jni.h +1141 -0
  274. package/yoga/lib/jsr-305/jsr305.jar +0 -0
  275. package/yoga/lib/nlohmann/json.hpp +24766 -0
  276. package/yoga/lib/soloader/soloader-0.5.1.aar +0 -0
  277. package/yoga/package.json +44 -0
  278. package/yoga/scripts/clang-format +52 -0
  279. package/yoga/scripts/clang-format.js +93 -0
  280. package/yoga/scripts/format-kotlin.js +88 -0
  281. package/yoga/scripts/format-python.js +150 -0
  282. package/yoga/scripts/format-utils.js +82 -0
  283. package/yoga/set-version.py +37 -0
  284. package/yoga/settings.gradle.kts +29 -0
  285. package/yoga/test/AssertFatalTest.cpp +70 -0
  286. package/yoga/tests/.clang-tidy +7 -0
  287. package/yoga/tests/CMakeLists.txt +35 -0
  288. package/yoga/tests/CacheTest.cpp +229 -0
  289. package/yoga/tests/EventPublisherTest.cpp +162 -0
  290. package/yoga/tests/EventsTest.cpp +362 -0
  291. package/yoga/tests/FlexGapTest.cpp +93 -0
  292. package/yoga/tests/FloatOptionalTest.cpp +214 -0
  293. package/yoga/tests/GridStyleTest.cpp +103 -0
  294. package/yoga/tests/OrdinalsTest.cpp +35 -0
  295. package/yoga/tests/SmallValueBufferTest.cpp +161 -0
  296. package/yoga/tests/StyleTest.cpp +48 -0
  297. package/yoga/tests/StyleValuePoolTest.cpp +146 -0
  298. package/yoga/tests/YGAlignBaselineTest.cpp +837 -0
  299. package/yoga/tests/YGAspectRatioTest.cpp +898 -0
  300. package/yoga/tests/YGAutoMinSizeTest.cpp +581 -0
  301. package/yoga/tests/YGBaselineFuncTest.cpp +62 -0
  302. package/yoga/tests/YGCloneNodeTest.cpp +131 -0
  303. package/yoga/tests/YGComputedMarginTest.cpp +117 -0
  304. package/yoga/tests/YGComputedPaddingTest.cpp +119 -0
  305. package/yoga/tests/YGConfigTest.cpp +239 -0
  306. package/yoga/tests/YGContentsNodeHasNewLayoutTest.cpp +190 -0
  307. package/yoga/tests/YGDefaultValuesTest.cpp +175 -0
  308. package/yoga/tests/YGDirtiedTest.cpp +110 -0
  309. package/yoga/tests/YGDirtyMarkingTest.cpp +341 -0
  310. package/yoga/tests/YGEdgeTest.cpp +161 -0
  311. package/yoga/tests/YGFirstChildMinWidthTest.cpp +133 -0
  312. package/yoga/tests/YGFlexBasisFitContentTest.cpp +241 -0
  313. package/yoga/tests/YGFlexShrinkBorderBugTest.cpp +48 -0
  314. package/yoga/tests/YGHadOverflowTest.cpp +135 -0
  315. package/yoga/tests/YGLayoutableChildrenTest.cpp +191 -0
  316. package/yoga/tests/YGMeasureCacheTest.cpp +178 -0
  317. package/yoga/tests/YGMeasureModeTest.cpp +332 -0
  318. package/yoga/tests/YGMeasureTest.cpp +1010 -0
  319. package/yoga/tests/YGNodeCallbackTest.cpp +80 -0
  320. package/yoga/tests/YGNodeChildTest.cpp +68 -0
  321. package/yoga/tests/YGPersistenceTest.cpp +291 -0
  322. package/yoga/tests/YGPersistentNodeCloningTest.cpp +214 -0
  323. package/yoga/tests/YGRelayoutTest.cpp +255 -0
  324. package/yoga/tests/YGRoundingFunctionTest.cpp +186 -0
  325. package/yoga/tests/YGRoundingMeasureFuncTest.cpp +139 -0
  326. package/yoga/tests/YGScaleChangeTest.cpp +176 -0
  327. package/yoga/tests/YGStyleTest.cpp +75 -0
  328. package/yoga/tests/YGTreeMutationTest.cpp +115 -0
  329. package/yoga/tests/YGValueTest.cpp +23 -0
  330. package/yoga/tests/YGZeroOutLayoutRecursivelyTest.cpp +37 -0
  331. package/yoga/tests/generated/YGAbsolutePositionTest.cpp +1685 -0
  332. package/yoga/tests/generated/YGAlignContentTest.cpp +5485 -0
  333. package/yoga/tests/generated/YGAlignItemsTest.cpp +2142 -0
  334. package/yoga/tests/generated/YGAlignSelfTest.cpp +257 -0
  335. package/yoga/tests/generated/YGAndroidNewsFeed.cpp +295 -0
  336. package/yoga/tests/generated/YGAspectRatioTest.cpp +55 -0
  337. package/yoga/tests/generated/YGAutoTest.cpp +312 -0
  338. package/yoga/tests/generated/YGBorderTest.cpp +208 -0
  339. package/yoga/tests/generated/YGBoxSizingTest.cpp +2192 -0
  340. package/yoga/tests/generated/YGDimensionTest.cpp +105 -0
  341. package/yoga/tests/generated/YGDisplayContentsTest.cpp +89 -0
  342. package/yoga/tests/generated/YGDisplayTest.cpp +1016 -0
  343. package/yoga/tests/generated/YGFlexBasisFitContentTest.cpp +378 -0
  344. package/yoga/tests/generated/YGFlexDirectionTest.cpp +4152 -0
  345. package/yoga/tests/generated/YGFlexTest.cpp +621 -0
  346. package/yoga/tests/generated/YGFlexWrapTest.cpp +1867 -0
  347. package/yoga/tests/generated/YGGapTest.cpp +3001 -0
  348. package/yoga/tests/generated/YGIntrinsicSizeTest.cpp +924 -0
  349. package/yoga/tests/generated/YGJustifyContentTest.cpp +1874 -0
  350. package/yoga/tests/generated/YGMarginTest.cpp +1811 -0
  351. package/yoga/tests/generated/YGMinMaxDimensionTest.cpp +1215 -0
  352. package/yoga/tests/generated/YGPaddingTest.cpp +295 -0
  353. package/yoga/tests/generated/YGPercentageTest.cpp +1350 -0
  354. package/yoga/tests/generated/YGRoundingTest.cpp +1093 -0
  355. package/yoga/tests/generated/YGSizeOverflowTest.cpp +179 -0
  356. package/yoga/tests/generated/YGStaticPositionTest.cpp +6035 -0
  357. package/yoga/tests/util/TestUtil.cpp +164 -0
  358. package/yoga/tests/util/TestUtil.h +43 -0
  359. package/yoga/unit_tests +25 -0
  360. package/yoga/unit_tests.bat +28 -0
  361. package/yoga/website/.eslintrc.cjs +26 -0
  362. package/yoga/website/README.md +41 -0
  363. package/yoga/website/babel.config.cjs +10 -0
  364. package/yoga/website/blog/2023-06-30-announcing-yoga-2.0.md +183 -0
  365. package/yoga/website/blog/2024-06-24-announcing-yoga-3.1.md +67 -0
  366. package/yoga/website/blog/2024-12-02-announcing-yoga-3.2.md +84 -0
  367. package/yoga/website/blog/authors.yml +10 -0
  368. package/yoga/website/blog/yoga-3-release/2024-03-14-announcing-yoga-3.0.md +586 -0
  369. package/yoga/website/blog/yoga-3-release/img/image1.png +0 -0
  370. package/yoga/website/blog/yoga-3-release/img/image10.png +0 -0
  371. package/yoga/website/blog/yoga-3-release/img/image11.png +0 -0
  372. package/yoga/website/blog/yoga-3-release/img/image12.png +0 -0
  373. package/yoga/website/blog/yoga-3-release/img/image13.png +0 -0
  374. package/yoga/website/blog/yoga-3-release/img/image14.png +0 -0
  375. package/yoga/website/blog/yoga-3-release/img/image15.png +0 -0
  376. package/yoga/website/blog/yoga-3-release/img/image16.png +0 -0
  377. package/yoga/website/blog/yoga-3-release/img/image17.png +0 -0
  378. package/yoga/website/blog/yoga-3-release/img/image2.png +0 -0
  379. package/yoga/website/blog/yoga-3-release/img/image3.png +0 -0
  380. package/yoga/website/blog/yoga-3-release/img/image4.png +0 -0
  381. package/yoga/website/blog/yoga-3-release/img/image5.png +0 -0
  382. package/yoga/website/blog/yoga-3-release/img/image6.png +0 -0
  383. package/yoga/website/blog/yoga-3-release/img/image7.png +0 -0
  384. package/yoga/website/blog/yoga-3-release/img/image8.png +0 -0
  385. package/yoga/website/blog/yoga-3-release/img/image9.png +0 -0
  386. package/yoga/website/docs/about-yoga.md +13 -0
  387. package/yoga/website/docs/advanced/_category_.json +4 -0
  388. package/yoga/website/docs/advanced/containing-block.md +89 -0
  389. package/yoga/website/docs/advanced/external-layout-systems.mdx +106 -0
  390. package/yoga/website/docs/advanced/incremental-layout.mdx +87 -0
  391. package/yoga/website/docs/getting-started/_category_.json +4 -0
  392. package/yoga/website/docs/getting-started/configuring-yoga.mdx +165 -0
  393. package/yoga/website/docs/getting-started/laying-out-a-tree.mdx +178 -0
  394. package/yoga/website/docs/img/config-contextual.svg +17 -0
  395. package/yoga/website/docs/img/config-per-node.svg +17 -0
  396. package/yoga/website/docs/img/config-uniform.svg +17 -0
  397. package/yoga/website/docs/img/invalidation-clean-tree.svg +17 -0
  398. package/yoga/website/docs/img/invalidation-dirtied-tree.svg +17 -0
  399. package/yoga/website/docs/img/invalidation-new-layout-tree.svg +17 -0
  400. package/yoga/website/docs/img/pixel-grid-after.png +0 -0
  401. package/yoga/website/docs/img/pixel-grid-before.png +0 -0
  402. package/yoga/website/docs/img/wireframe-example.svg +105 -0
  403. package/yoga/website/docs/styling/_category_.json +4 -0
  404. package/yoga/website/docs/styling/align-content.mdx +47 -0
  405. package/yoga/website/docs/styling/align-items-self.mdx +48 -0
  406. package/yoga/website/docs/styling/aspect-ratio.mdx +27 -0
  407. package/yoga/website/docs/styling/display.mdx +25 -0
  408. package/yoga/website/docs/styling/flex-basis-grow-shrink.mdx +65 -0
  409. package/yoga/website/docs/styling/flex-direction.mdx +37 -0
  410. package/yoga/website/docs/styling/flex-wrap.mdx +33 -0
  411. package/yoga/website/docs/styling/gap.mdx +49 -0
  412. package/yoga/website/docs/styling/index.md +48 -0
  413. package/yoga/website/docs/styling/insets.mdx +62 -0
  414. package/yoga/website/docs/styling/justify-content.mdx +43 -0
  415. package/yoga/website/docs/styling/layout-direction.mdx +34 -0
  416. package/yoga/website/docs/styling/margin-padding-border.mdx +41 -0
  417. package/yoga/website/docs/styling/min-max-width-height.mdx +52 -0
  418. package/yoga/website/docs/styling/position.mdx +37 -0
  419. package/yoga/website/docs/styling/width-height.mdx +37 -0
  420. package/yoga/website/docusaurus.config.js +113 -0
  421. package/yoga/website/package.json +43 -0
  422. package/yoga/website/sidebars.cjs +27 -0
  423. package/yoga/website/src/components/EditorToolbar.module.css +77 -0
  424. package/yoga/website/src/components/EditorToolbar.tsx +72 -0
  425. package/yoga/website/src/components/FlexStyle.ts +439 -0
  426. package/yoga/website/src/components/LayoutBox.module.css +68 -0
  427. package/yoga/website/src/components/LayoutBox.tsx +61 -0
  428. package/yoga/website/src/components/Playground.module.css +130 -0
  429. package/yoga/website/src/components/Playground.tsx +187 -0
  430. package/yoga/website/src/components/YogaViewer.tsx +128 -0
  431. package/yoga/website/src/css/custom.css +37 -0
  432. package/yoga/website/src/pages/index.module.css +34 -0
  433. package/yoga/website/src/pages/index.tsx +84 -0
  434. package/yoga/website/src/pages/markdown-page.md +7 -0
  435. package/yoga/website/src/pages/playground.module.css +11 -0
  436. package/yoga/website/src/pages/playground.tsx +56 -0
  437. package/yoga/website/static/.nojekyll +0 -0
  438. package/yoga/website/static/img/docusaurus.png +0 -0
  439. package/yoga/website/static/img/favicon.svg +17 -0
  440. package/yoga/website/static/img/link.svg +4 -0
  441. package/yoga/website/static/img/logo.svg +17 -0
  442. package/yoga/website/static/img/meta_oss.svg +1 -0
  443. package/yoga/website/static/img/opengraph.png +0 -0
  444. package/yoga/website/static/img/undraw_docusaurus_mountain.svg +171 -0
  445. package/yoga/website/static/img/undraw_docusaurus_react.svg +170 -0
  446. package/yoga/website/static/img/undraw_docusaurus_tree.svg +40 -0
  447. package/yoga/website/tsconfig.json +10 -0
  448. package/yoga/yarn.lock +11499 -0
  449. package/yoga/yoga/CMakeLists.txt +41 -0
  450. package/yoga/yoga/YGConfig.cpp +92 -0
  451. package/yoga/yoga/YGConfig.h +158 -0
  452. package/yoga/yoga/YGEnums.cpp +304 -0
  453. package/yoga/yoga/YGEnums.h +163 -0
  454. package/yoga/yoga/YGMacros.h +101 -0
  455. package/yoga/yoga/YGNode.cpp +407 -0
  456. package/yoga/yoga/YGNode.h +373 -0
  457. package/yoga/yoga/YGNodeLayout.cpp +100 -0
  458. package/yoga/yoga/YGNodeLayout.h +43 -0
  459. package/yoga/yoga/YGNodeStyle.cpp +774 -0
  460. package/yoga/yoga/YGNodeStyle.h +243 -0
  461. package/yoga/yoga/YGPixelGrid.cpp +22 -0
  462. package/yoga/yoga/YGPixelGrid.h +29 -0
  463. package/yoga/yoga/YGValue.cpp +20 -0
  464. package/yoga/yoga/YGValue.h +83 -0
  465. package/yoga/yoga/Yoga.h +21 -0
  466. package/yoga/yoga/algorithm/AbsoluteLayout.cpp +595 -0
  467. package/yoga/yoga/algorithm/AbsoluteLayout.h +41 -0
  468. package/yoga/yoga/algorithm/Align.h +83 -0
  469. package/yoga/yoga/algorithm/Baseline.cpp +78 -0
  470. package/yoga/yoga/algorithm/Baseline.h +21 -0
  471. package/yoga/yoga/algorithm/BoundAxis.h +79 -0
  472. package/yoga/yoga/algorithm/Cache.cpp +121 -0
  473. package/yoga/yoga/algorithm/Cache.h +30 -0
  474. package/yoga/yoga/algorithm/CalculateLayout.cpp +2968 -0
  475. package/yoga/yoga/algorithm/CalculateLayout.h +60 -0
  476. package/yoga/yoga/algorithm/FlexDirection.h +120 -0
  477. package/yoga/yoga/algorithm/FlexLine.cpp +124 -0
  478. package/yoga/yoga/algorithm/FlexLine.h +75 -0
  479. package/yoga/yoga/algorithm/PixelGrid.cpp +138 -0
  480. package/yoga/yoga/algorithm/PixelGrid.h +29 -0
  481. package/yoga/yoga/algorithm/SizingMode.h +73 -0
  482. package/yoga/yoga/algorithm/TrailingPosition.h +44 -0
  483. package/yoga/yoga/config/Config.cpp +135 -0
  484. package/yoga/yoga/config/Config.h +93 -0
  485. package/yoga/yoga/debug/AssertFatal.cpp +54 -0
  486. package/yoga/yoga/debug/AssertFatal.h +29 -0
  487. package/yoga/yoga/debug/Log.cpp +107 -0
  488. package/yoga/yoga/debug/Log.h +34 -0
  489. package/yoga/yoga/enums/Align.h +49 -0
  490. package/yoga/yoga/enums/BoxSizing.h +40 -0
  491. package/yoga/yoga/enums/Dimension.h +40 -0
  492. package/yoga/yoga/enums/Direction.h +41 -0
  493. package/yoga/yoga/enums/Display.h +42 -0
  494. package/yoga/yoga/enums/Edge.h +47 -0
  495. package/yoga/yoga/enums/Errata.h +43 -0
  496. package/yoga/yoga/enums/ExperimentalFeature.h +40 -0
  497. package/yoga/yoga/enums/FlexDirection.h +42 -0
  498. package/yoga/yoga/enums/GridTrackType.h +43 -0
  499. package/yoga/yoga/enums/Gutter.h +41 -0
  500. package/yoga/yoga/enums/Justify.h +48 -0
  501. package/yoga/yoga/enums/LogLevel.h +44 -0
  502. package/yoga/yoga/enums/MeasureMode.h +41 -0
  503. package/yoga/yoga/enums/NodeType.h +40 -0
  504. package/yoga/yoga/enums/Overflow.h +41 -0
  505. package/yoga/yoga/enums/PhysicalEdge.h +21 -0
  506. package/yoga/yoga/enums/PositionType.h +41 -0
  507. package/yoga/yoga/enums/Unit.h +45 -0
  508. package/yoga/yoga/enums/Wrap.h +41 -0
  509. package/yoga/yoga/enums/YogaEnums.h +84 -0
  510. package/yoga/yoga/event/event.cpp +89 -0
  511. package/yoga/yoga/event/event.h +131 -0
  512. package/yoga/yoga/module.modulemap +21 -0
  513. package/yoga/yoga/node/CachedMeasurement.h +53 -0
  514. package/yoga/yoga/node/LayoutResults.cpp +48 -0
  515. package/yoga/yoga/node/LayoutResults.h +136 -0
  516. package/yoga/yoga/node/LayoutableChildren.h +148 -0
  517. package/yoga/yoga/node/Node.cpp +509 -0
  518. package/yoga/yoga/node/Node.h +372 -0
  519. package/yoga/yoga/numeric/Comparison.h +81 -0
  520. package/yoga/yoga/numeric/FloatOptional.h +84 -0
  521. package/yoga/yoga/style/GridLine.h +53 -0
  522. package/yoga/yoga/style/GridStyle.h +80 -0
  523. package/yoga/yoga/style/GridTrack.h +63 -0
  524. package/yoga/yoga/style/SmallValueBuffer.h +133 -0
  525. package/yoga/yoga/style/Style.h +932 -0
  526. package/yoga/yoga/style/StyleLength.h +121 -0
  527. package/yoga/yoga/style/StyleSizeLength.h +152 -0
  528. package/yoga/yoga/style/StyleValueHandle.h +114 -0
  529. package/yoga/yoga/style/StyleValuePool.h +194 -0
@@ -0,0 +1,2132 @@
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<<56bad92abb0a9a39d9e964bf4d5b2c48>>
8
+ * generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGAlignItemsTest.html
9
+ */
10
+
11
+ package com.facebook.yoga;
12
+
13
+ import static org.junit.Assert.assertEquals;
14
+
15
+ import org.junit.Ignore;
16
+ import org.junit.Test;
17
+ import org.junit.runner.RunWith;
18
+ import org.junit.runners.Parameterized;
19
+ import com.facebook.yoga.utils.TestUtils;
20
+
21
+ @RunWith(Parameterized.class)
22
+ public class YGAlignItemsTest {
23
+ @Parameterized.Parameters(name = "{0}")
24
+ public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
25
+ return TestParametrization.nodeFactories();
26
+ }
27
+
28
+ @Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
29
+
30
+ @Test
31
+ public void test_align_items_stretch() {
32
+ YogaConfig config = YogaConfigFactory.create();
33
+
34
+ final YogaNode root = createNode(config);
35
+ root.setPositionType(YogaPositionType.ABSOLUTE);
36
+ root.setWidth(100f);
37
+ root.setHeight(100f);
38
+
39
+ final YogaNode root_child0 = createNode(config);
40
+ root_child0.setHeight(10f);
41
+ root.addChildAt(root_child0, 0);
42
+ root.setDirection(YogaDirection.LTR);
43
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
44
+
45
+ assertEquals(0f, root.getLayoutX(), 0.0f);
46
+ assertEquals(0f, root.getLayoutY(), 0.0f);
47
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
48
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
49
+
50
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
51
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
52
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
53
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
54
+
55
+ root.setDirection(YogaDirection.RTL);
56
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
57
+
58
+ assertEquals(0f, root.getLayoutX(), 0.0f);
59
+ assertEquals(0f, root.getLayoutY(), 0.0f);
60
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
61
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
62
+
63
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
64
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
65
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
66
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
67
+ }
68
+
69
+ @Test
70
+ public void test_align_items_center() {
71
+ YogaConfig config = YogaConfigFactory.create();
72
+
73
+ final YogaNode root = createNode(config);
74
+ root.setPositionType(YogaPositionType.ABSOLUTE);
75
+ root.setWidth(100f);
76
+ root.setHeight(100f);
77
+ root.setAlignItems(YogaAlign.CENTER);
78
+
79
+ final YogaNode root_child0 = createNode(config);
80
+ root_child0.setHeight(10f);
81
+ root_child0.setWidth(10f);
82
+ root.addChildAt(root_child0, 0);
83
+ root.setDirection(YogaDirection.LTR);
84
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
85
+
86
+ assertEquals(0f, root.getLayoutX(), 0.0f);
87
+ assertEquals(0f, root.getLayoutY(), 0.0f);
88
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
89
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
90
+
91
+ assertEquals(45f, root_child0.getLayoutX(), 0.0f);
92
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
93
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
94
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
95
+
96
+ root.setDirection(YogaDirection.RTL);
97
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
98
+
99
+ assertEquals(0f, root.getLayoutX(), 0.0f);
100
+ assertEquals(0f, root.getLayoutY(), 0.0f);
101
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
102
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
103
+
104
+ assertEquals(45f, root_child0.getLayoutX(), 0.0f);
105
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
106
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
107
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
108
+ }
109
+
110
+ @Test
111
+ public void test_align_items_flex_start() {
112
+ YogaConfig config = YogaConfigFactory.create();
113
+
114
+ final YogaNode root = createNode(config);
115
+ root.setPositionType(YogaPositionType.ABSOLUTE);
116
+ root.setWidth(100f);
117
+ root.setHeight(100f);
118
+ root.setAlignItems(YogaAlign.FLEX_START);
119
+
120
+ final YogaNode root_child0 = createNode(config);
121
+ root_child0.setHeight(10f);
122
+ root_child0.setWidth(10f);
123
+ root.addChildAt(root_child0, 0);
124
+ root.setDirection(YogaDirection.LTR);
125
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
126
+
127
+ assertEquals(0f, root.getLayoutX(), 0.0f);
128
+ assertEquals(0f, root.getLayoutY(), 0.0f);
129
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
130
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
131
+
132
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
133
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
134
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
135
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
136
+
137
+ root.setDirection(YogaDirection.RTL);
138
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
139
+
140
+ assertEquals(0f, root.getLayoutX(), 0.0f);
141
+ assertEquals(0f, root.getLayoutY(), 0.0f);
142
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
143
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
144
+
145
+ assertEquals(90f, root_child0.getLayoutX(), 0.0f);
146
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
147
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
148
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
149
+ }
150
+
151
+ @Test
152
+ public void test_align_items_flex_end() {
153
+ YogaConfig config = YogaConfigFactory.create();
154
+
155
+ final YogaNode root = createNode(config);
156
+ root.setPositionType(YogaPositionType.ABSOLUTE);
157
+ root.setWidth(100f);
158
+ root.setHeight(100f);
159
+ root.setAlignItems(YogaAlign.FLEX_END);
160
+
161
+ final YogaNode root_child0 = createNode(config);
162
+ root_child0.setHeight(10f);
163
+ root_child0.setWidth(10f);
164
+ root.addChildAt(root_child0, 0);
165
+ root.setDirection(YogaDirection.LTR);
166
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
167
+
168
+ assertEquals(0f, root.getLayoutX(), 0.0f);
169
+ assertEquals(0f, root.getLayoutY(), 0.0f);
170
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
171
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
172
+
173
+ assertEquals(90f, root_child0.getLayoutX(), 0.0f);
174
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
175
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
176
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
177
+
178
+ root.setDirection(YogaDirection.RTL);
179
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
180
+
181
+ assertEquals(0f, root.getLayoutX(), 0.0f);
182
+ assertEquals(0f, root.getLayoutY(), 0.0f);
183
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
184
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
185
+
186
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
187
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
188
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
189
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
190
+ }
191
+
192
+ @Test
193
+ public void test_align_baseline() {
194
+ YogaConfig config = YogaConfigFactory.create();
195
+
196
+ final YogaNode root = createNode(config);
197
+ root.setPositionType(YogaPositionType.ABSOLUTE);
198
+ root.setWidth(100f);
199
+ root.setHeight(100f);
200
+ root.setFlexDirection(YogaFlexDirection.ROW);
201
+ root.setAlignItems(YogaAlign.BASELINE);
202
+
203
+ final YogaNode root_child0 = createNode(config);
204
+ root_child0.setWidth(50f);
205
+ root_child0.setHeight(50f);
206
+ root.addChildAt(root_child0, 0);
207
+
208
+ final YogaNode root_child1 = createNode(config);
209
+ root_child1.setWidth(50f);
210
+ root_child1.setHeight(20f);
211
+ root.addChildAt(root_child1, 1);
212
+ root.setDirection(YogaDirection.LTR);
213
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
214
+
215
+ assertEquals(0f, root.getLayoutX(), 0.0f);
216
+ assertEquals(0f, root.getLayoutY(), 0.0f);
217
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
218
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
219
+
220
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
221
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
222
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
223
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
224
+
225
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
226
+ assertEquals(30f, root_child1.getLayoutY(), 0.0f);
227
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
228
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
229
+
230
+ root.setDirection(YogaDirection.RTL);
231
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
232
+
233
+ assertEquals(0f, root.getLayoutX(), 0.0f);
234
+ assertEquals(0f, root.getLayoutY(), 0.0f);
235
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
236
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
237
+
238
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
239
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
240
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
241
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
242
+
243
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
244
+ assertEquals(30f, root_child1.getLayoutY(), 0.0f);
245
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
246
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
247
+ }
248
+
249
+ @Test
250
+ public void test_align_baseline_child() {
251
+ YogaConfig config = YogaConfigFactory.create();
252
+
253
+ final YogaNode root = createNode(config);
254
+ root.setPositionType(YogaPositionType.ABSOLUTE);
255
+ root.setWidth(100f);
256
+ root.setHeight(100f);
257
+ root.setFlexDirection(YogaFlexDirection.ROW);
258
+ root.setAlignItems(YogaAlign.BASELINE);
259
+
260
+ final YogaNode root_child0 = createNode(config);
261
+ root_child0.setWidth(50f);
262
+ root_child0.setHeight(50f);
263
+ root.addChildAt(root_child0, 0);
264
+
265
+ final YogaNode root_child1 = createNode(config);
266
+ root_child1.setWidth(50f);
267
+ root_child1.setHeight(20f);
268
+ root.addChildAt(root_child1, 1);
269
+
270
+ final YogaNode root_child1_child0 = createNode(config);
271
+ root_child1_child0.setWidth(50f);
272
+ root_child1_child0.setHeight(10f);
273
+ root_child1.addChildAt(root_child1_child0, 0);
274
+ root.setDirection(YogaDirection.LTR);
275
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
276
+
277
+ assertEquals(0f, root.getLayoutX(), 0.0f);
278
+ assertEquals(0f, root.getLayoutY(), 0.0f);
279
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
280
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
281
+
282
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
283
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
284
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
285
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
286
+
287
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
288
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
289
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
290
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
291
+
292
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
293
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
294
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
295
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
296
+
297
+ root.setDirection(YogaDirection.RTL);
298
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
299
+
300
+ assertEquals(0f, root.getLayoutX(), 0.0f);
301
+ assertEquals(0f, root.getLayoutY(), 0.0f);
302
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
303
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
304
+
305
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
306
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
307
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
308
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
309
+
310
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
311
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
312
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
313
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
314
+
315
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
316
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
317
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
318
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
319
+ }
320
+
321
+ @Test
322
+ public void test_align_baseline_child_multiline() {
323
+ YogaConfig config = YogaConfigFactory.create();
324
+
325
+ final YogaNode root = createNode(config);
326
+ root.setPositionType(YogaPositionType.ABSOLUTE);
327
+ root.setWidth(100f);
328
+ root.setHeight(100f);
329
+ root.setFlexDirection(YogaFlexDirection.ROW);
330
+ root.setAlignItems(YogaAlign.BASELINE);
331
+
332
+ final YogaNode root_child0 = createNode(config);
333
+ root_child0.setWidth(50f);
334
+ root_child0.setHeight(60f);
335
+ root.addChildAt(root_child0, 0);
336
+
337
+ final YogaNode root_child1 = createNode(config);
338
+ root_child1.setWidth(50f);
339
+ root_child1.setHeight(25f);
340
+ root_child1.setWrap(YogaWrap.WRAP);
341
+ root_child1.setFlexDirection(YogaFlexDirection.ROW);
342
+ root.addChildAt(root_child1, 1);
343
+
344
+ final YogaNode root_child1_child0 = createNode(config);
345
+ root_child1_child0.setWidth(25f);
346
+ root_child1_child0.setHeight(20f);
347
+ root_child1.addChildAt(root_child1_child0, 0);
348
+
349
+ final YogaNode root_child1_child1 = createNode(config);
350
+ root_child1_child1.setWidth(25f);
351
+ root_child1_child1.setHeight(10f);
352
+ root_child1.addChildAt(root_child1_child1, 1);
353
+
354
+ final YogaNode root_child1_child2 = createNode(config);
355
+ root_child1_child2.setWidth(25f);
356
+ root_child1_child2.setHeight(20f);
357
+ root_child1.addChildAt(root_child1_child2, 2);
358
+
359
+ final YogaNode root_child1_child3 = createNode(config);
360
+ root_child1_child3.setWidth(25f);
361
+ root_child1_child3.setHeight(10f);
362
+ root_child1.addChildAt(root_child1_child3, 3);
363
+ root.setDirection(YogaDirection.LTR);
364
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
365
+
366
+ assertEquals(0f, root.getLayoutX(), 0.0f);
367
+ assertEquals(0f, root.getLayoutY(), 0.0f);
368
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
369
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
370
+
371
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
372
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
373
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
374
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
375
+
376
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
377
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
378
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
379
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
380
+
381
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
382
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
383
+ assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f);
384
+ assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f);
385
+
386
+ assertEquals(25f, root_child1_child1.getLayoutX(), 0.0f);
387
+ assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
388
+ assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f);
389
+ assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f);
390
+
391
+ assertEquals(0f, root_child1_child2.getLayoutX(), 0.0f);
392
+ assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f);
393
+ assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f);
394
+ assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f);
395
+
396
+ assertEquals(25f, root_child1_child3.getLayoutX(), 0.0f);
397
+ assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f);
398
+ assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f);
399
+ assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f);
400
+
401
+ root.setDirection(YogaDirection.RTL);
402
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
403
+
404
+ assertEquals(0f, root.getLayoutX(), 0.0f);
405
+ assertEquals(0f, root.getLayoutY(), 0.0f);
406
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
407
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
408
+
409
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
410
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
411
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
412
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
413
+
414
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
415
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
416
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
417
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
418
+
419
+ assertEquals(25f, root_child1_child0.getLayoutX(), 0.0f);
420
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
421
+ assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f);
422
+ assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f);
423
+
424
+ assertEquals(0f, root_child1_child1.getLayoutX(), 0.0f);
425
+ assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
426
+ assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f);
427
+ assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f);
428
+
429
+ assertEquals(25f, root_child1_child2.getLayoutX(), 0.0f);
430
+ assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f);
431
+ assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f);
432
+ assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f);
433
+
434
+ assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f);
435
+ assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f);
436
+ assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f);
437
+ assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f);
438
+ }
439
+
440
+ @Test
441
+ public void test_align_baseline_child_multiline_override() {
442
+ YogaConfig config = YogaConfigFactory.create();
443
+
444
+ final YogaNode root = createNode(config);
445
+ root.setPositionType(YogaPositionType.ABSOLUTE);
446
+ root.setWidth(100f);
447
+ root.setHeight(100f);
448
+ root.setFlexDirection(YogaFlexDirection.ROW);
449
+ root.setAlignItems(YogaAlign.BASELINE);
450
+
451
+ final YogaNode root_child0 = createNode(config);
452
+ root_child0.setWidth(50f);
453
+ root_child0.setHeight(60f);
454
+ root.addChildAt(root_child0, 0);
455
+
456
+ final YogaNode root_child1 = createNode(config);
457
+ root_child1.setWidth(50f);
458
+ root_child1.setHeight(25f);
459
+ root_child1.setWrap(YogaWrap.WRAP);
460
+ root_child1.setFlexDirection(YogaFlexDirection.ROW);
461
+ root.addChildAt(root_child1, 1);
462
+
463
+ final YogaNode root_child1_child0 = createNode(config);
464
+ root_child1_child0.setWidth(25f);
465
+ root_child1_child0.setHeight(20f);
466
+ root_child1.addChildAt(root_child1_child0, 0);
467
+
468
+ final YogaNode root_child1_child1 = createNode(config);
469
+ root_child1_child1.setWidth(25f);
470
+ root_child1_child1.setHeight(10f);
471
+ root_child1_child1.setAlignSelf(YogaAlign.BASELINE);
472
+ root_child1.addChildAt(root_child1_child1, 1);
473
+
474
+ final YogaNode root_child1_child2 = createNode(config);
475
+ root_child1_child2.setWidth(25f);
476
+ root_child1_child2.setHeight(20f);
477
+ root_child1.addChildAt(root_child1_child2, 2);
478
+
479
+ final YogaNode root_child1_child3 = createNode(config);
480
+ root_child1_child3.setWidth(25f);
481
+ root_child1_child3.setHeight(10f);
482
+ root_child1_child3.setAlignSelf(YogaAlign.BASELINE);
483
+ root_child1.addChildAt(root_child1_child3, 3);
484
+ root.setDirection(YogaDirection.LTR);
485
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
486
+
487
+ assertEquals(0f, root.getLayoutX(), 0.0f);
488
+ assertEquals(0f, root.getLayoutY(), 0.0f);
489
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
490
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
491
+
492
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
493
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
494
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
495
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
496
+
497
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
498
+ assertEquals(50f, root_child1.getLayoutY(), 0.0f);
499
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
500
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
501
+
502
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
503
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
504
+ assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f);
505
+ assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f);
506
+
507
+ assertEquals(25f, root_child1_child1.getLayoutX(), 0.0f);
508
+ assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
509
+ assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f);
510
+ assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f);
511
+
512
+ assertEquals(0f, root_child1_child2.getLayoutX(), 0.0f);
513
+ assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f);
514
+ assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f);
515
+ assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f);
516
+
517
+ assertEquals(25f, root_child1_child3.getLayoutX(), 0.0f);
518
+ assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f);
519
+ assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f);
520
+ assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f);
521
+
522
+ root.setDirection(YogaDirection.RTL);
523
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
524
+
525
+ assertEquals(0f, root.getLayoutX(), 0.0f);
526
+ assertEquals(0f, root.getLayoutY(), 0.0f);
527
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
528
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
529
+
530
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
531
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
532
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
533
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
534
+
535
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
536
+ assertEquals(50f, root_child1.getLayoutY(), 0.0f);
537
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
538
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
539
+
540
+ assertEquals(25f, root_child1_child0.getLayoutX(), 0.0f);
541
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
542
+ assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f);
543
+ assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f);
544
+
545
+ assertEquals(0f, root_child1_child1.getLayoutX(), 0.0f);
546
+ assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
547
+ assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f);
548
+ assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f);
549
+
550
+ assertEquals(25f, root_child1_child2.getLayoutX(), 0.0f);
551
+ assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f);
552
+ assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f);
553
+ assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f);
554
+
555
+ assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f);
556
+ assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f);
557
+ assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f);
558
+ assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f);
559
+ }
560
+
561
+ @Test
562
+ public void test_align_baseline_child_multiline_no_override_on_secondline() {
563
+ YogaConfig config = YogaConfigFactory.create();
564
+
565
+ final YogaNode root = createNode(config);
566
+ root.setPositionType(YogaPositionType.ABSOLUTE);
567
+ root.setWidth(100f);
568
+ root.setHeight(100f);
569
+ root.setFlexDirection(YogaFlexDirection.ROW);
570
+ root.setAlignItems(YogaAlign.BASELINE);
571
+
572
+ final YogaNode root_child0 = createNode(config);
573
+ root_child0.setWidth(50f);
574
+ root_child0.setHeight(60f);
575
+ root.addChildAt(root_child0, 0);
576
+
577
+ final YogaNode root_child1 = createNode(config);
578
+ root_child1.setWidth(50f);
579
+ root_child1.setHeight(25f);
580
+ root_child1.setWrap(YogaWrap.WRAP);
581
+ root_child1.setFlexDirection(YogaFlexDirection.ROW);
582
+ root.addChildAt(root_child1, 1);
583
+
584
+ final YogaNode root_child1_child0 = createNode(config);
585
+ root_child1_child0.setWidth(25f);
586
+ root_child1_child0.setHeight(20f);
587
+ root_child1.addChildAt(root_child1_child0, 0);
588
+
589
+ final YogaNode root_child1_child1 = createNode(config);
590
+ root_child1_child1.setWidth(25f);
591
+ root_child1_child1.setHeight(10f);
592
+ root_child1.addChildAt(root_child1_child1, 1);
593
+
594
+ final YogaNode root_child1_child2 = createNode(config);
595
+ root_child1_child2.setWidth(25f);
596
+ root_child1_child2.setHeight(20f);
597
+ root_child1.addChildAt(root_child1_child2, 2);
598
+
599
+ final YogaNode root_child1_child3 = createNode(config);
600
+ root_child1_child3.setWidth(25f);
601
+ root_child1_child3.setHeight(10f);
602
+ root_child1_child3.setAlignSelf(YogaAlign.BASELINE);
603
+ root_child1.addChildAt(root_child1_child3, 3);
604
+ root.setDirection(YogaDirection.LTR);
605
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
606
+
607
+ assertEquals(0f, root.getLayoutX(), 0.0f);
608
+ assertEquals(0f, root.getLayoutY(), 0.0f);
609
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
610
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
611
+
612
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
613
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
614
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
615
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
616
+
617
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
618
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
619
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
620
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
621
+
622
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
623
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
624
+ assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f);
625
+ assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f);
626
+
627
+ assertEquals(25f, root_child1_child1.getLayoutX(), 0.0f);
628
+ assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
629
+ assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f);
630
+ assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f);
631
+
632
+ assertEquals(0f, root_child1_child2.getLayoutX(), 0.0f);
633
+ assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f);
634
+ assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f);
635
+ assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f);
636
+
637
+ assertEquals(25f, root_child1_child3.getLayoutX(), 0.0f);
638
+ assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f);
639
+ assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f);
640
+ assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f);
641
+
642
+ root.setDirection(YogaDirection.RTL);
643
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
644
+
645
+ assertEquals(0f, root.getLayoutX(), 0.0f);
646
+ assertEquals(0f, root.getLayoutY(), 0.0f);
647
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
648
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
649
+
650
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
651
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
652
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
653
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
654
+
655
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
656
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
657
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
658
+ assertEquals(25f, root_child1.getLayoutHeight(), 0.0f);
659
+
660
+ assertEquals(25f, root_child1_child0.getLayoutX(), 0.0f);
661
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
662
+ assertEquals(25f, root_child1_child0.getLayoutWidth(), 0.0f);
663
+ assertEquals(20f, root_child1_child0.getLayoutHeight(), 0.0f);
664
+
665
+ assertEquals(0f, root_child1_child1.getLayoutX(), 0.0f);
666
+ assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f);
667
+ assertEquals(25f, root_child1_child1.getLayoutWidth(), 0.0f);
668
+ assertEquals(10f, root_child1_child1.getLayoutHeight(), 0.0f);
669
+
670
+ assertEquals(25f, root_child1_child2.getLayoutX(), 0.0f);
671
+ assertEquals(20f, root_child1_child2.getLayoutY(), 0.0f);
672
+ assertEquals(25f, root_child1_child2.getLayoutWidth(), 0.0f);
673
+ assertEquals(20f, root_child1_child2.getLayoutHeight(), 0.0f);
674
+
675
+ assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f);
676
+ assertEquals(20f, root_child1_child3.getLayoutY(), 0.0f);
677
+ assertEquals(25f, root_child1_child3.getLayoutWidth(), 0.0f);
678
+ assertEquals(10f, root_child1_child3.getLayoutHeight(), 0.0f);
679
+ }
680
+
681
+ @Test
682
+ public void test_align_baseline_child_top() {
683
+ YogaConfig config = YogaConfigFactory.create();
684
+
685
+ final YogaNode root = createNode(config);
686
+ root.setPositionType(YogaPositionType.ABSOLUTE);
687
+ root.setWidth(100f);
688
+ root.setHeight(100f);
689
+ root.setFlexDirection(YogaFlexDirection.ROW);
690
+ root.setAlignItems(YogaAlign.BASELINE);
691
+
692
+ final YogaNode root_child0 = createNode(config);
693
+ root_child0.setWidth(50f);
694
+ root_child0.setHeight(50f);
695
+ root_child0.setPosition(YogaEdge.TOP, 10f);
696
+ root.addChildAt(root_child0, 0);
697
+
698
+ final YogaNode root_child1 = createNode(config);
699
+ root_child1.setWidth(50f);
700
+ root_child1.setHeight(20f);
701
+ root.addChildAt(root_child1, 1);
702
+
703
+ final YogaNode root_child1_child0 = createNode(config);
704
+ root_child1_child0.setWidth(50f);
705
+ root_child1_child0.setHeight(10f);
706
+ root_child1.addChildAt(root_child1_child0, 0);
707
+ root.setDirection(YogaDirection.LTR);
708
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
709
+
710
+ assertEquals(0f, root.getLayoutX(), 0.0f);
711
+ assertEquals(0f, root.getLayoutY(), 0.0f);
712
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
713
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
714
+
715
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
716
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
717
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
718
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
719
+
720
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
721
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
722
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
723
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
724
+
725
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
726
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
727
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
728
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
729
+
730
+ root.setDirection(YogaDirection.RTL);
731
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
732
+
733
+ assertEquals(0f, root.getLayoutX(), 0.0f);
734
+ assertEquals(0f, root.getLayoutY(), 0.0f);
735
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
736
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
737
+
738
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
739
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
740
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
741
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
742
+
743
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
744
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
745
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
746
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
747
+
748
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
749
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
750
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
751
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
752
+ }
753
+
754
+ @Test
755
+ public void test_align_baseline_child_top2() {
756
+ YogaConfig config = YogaConfigFactory.create();
757
+
758
+ final YogaNode root = createNode(config);
759
+ root.setPositionType(YogaPositionType.ABSOLUTE);
760
+ root.setWidth(100f);
761
+ root.setHeight(100f);
762
+ root.setFlexDirection(YogaFlexDirection.ROW);
763
+ root.setAlignItems(YogaAlign.BASELINE);
764
+
765
+ final YogaNode root_child0 = createNode(config);
766
+ root_child0.setWidth(50f);
767
+ root_child0.setHeight(50f);
768
+ root.addChildAt(root_child0, 0);
769
+
770
+ final YogaNode root_child1 = createNode(config);
771
+ root_child1.setWidth(50f);
772
+ root_child1.setHeight(20f);
773
+ root_child1.setPosition(YogaEdge.TOP, 5f);
774
+ root.addChildAt(root_child1, 1);
775
+
776
+ final YogaNode root_child1_child0 = createNode(config);
777
+ root_child1_child0.setWidth(50f);
778
+ root_child1_child0.setHeight(10f);
779
+ root_child1.addChildAt(root_child1_child0, 0);
780
+ root.setDirection(YogaDirection.LTR);
781
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
782
+
783
+ assertEquals(0f, root.getLayoutX(), 0.0f);
784
+ assertEquals(0f, root.getLayoutY(), 0.0f);
785
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
786
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
787
+
788
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
789
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
790
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
791
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
792
+
793
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
794
+ assertEquals(45f, root_child1.getLayoutY(), 0.0f);
795
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
796
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
797
+
798
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
799
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
800
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
801
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
802
+
803
+ root.setDirection(YogaDirection.RTL);
804
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
805
+
806
+ assertEquals(0f, root.getLayoutX(), 0.0f);
807
+ assertEquals(0f, root.getLayoutY(), 0.0f);
808
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
809
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
810
+
811
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
812
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
813
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
814
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
815
+
816
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
817
+ assertEquals(45f, root_child1.getLayoutY(), 0.0f);
818
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
819
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
820
+
821
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
822
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
823
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
824
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
825
+ }
826
+
827
+ @Test
828
+ public void test_align_baseline_double_nested_child() {
829
+ YogaConfig config = YogaConfigFactory.create();
830
+
831
+ final YogaNode root = createNode(config);
832
+ root.setPositionType(YogaPositionType.ABSOLUTE);
833
+ root.setWidth(100f);
834
+ root.setHeight(100f);
835
+ root.setFlexDirection(YogaFlexDirection.ROW);
836
+ root.setAlignItems(YogaAlign.BASELINE);
837
+
838
+ final YogaNode root_child0 = createNode(config);
839
+ root_child0.setWidth(50f);
840
+ root_child0.setHeight(50f);
841
+ root.addChildAt(root_child0, 0);
842
+
843
+ final YogaNode root_child0_child0 = createNode(config);
844
+ root_child0_child0.setWidth(50f);
845
+ root_child0_child0.setHeight(20f);
846
+ root_child0.addChildAt(root_child0_child0, 0);
847
+
848
+ final YogaNode root_child1 = createNode(config);
849
+ root_child1.setWidth(50f);
850
+ root_child1.setHeight(20f);
851
+ root.addChildAt(root_child1, 1);
852
+
853
+ final YogaNode root_child1_child0 = createNode(config);
854
+ root_child1_child0.setWidth(50f);
855
+ root_child1_child0.setHeight(15f);
856
+ root_child1.addChildAt(root_child1_child0, 0);
857
+ root.setDirection(YogaDirection.LTR);
858
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
859
+
860
+ assertEquals(0f, root.getLayoutX(), 0.0f);
861
+ assertEquals(0f, root.getLayoutY(), 0.0f);
862
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
863
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
864
+
865
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
866
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
867
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
868
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
869
+
870
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
871
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
872
+ assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f);
873
+ assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
874
+
875
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
876
+ assertEquals(5f, root_child1.getLayoutY(), 0.0f);
877
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
878
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
879
+
880
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
881
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
882
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
883
+ assertEquals(15f, root_child1_child0.getLayoutHeight(), 0.0f);
884
+
885
+ root.setDirection(YogaDirection.RTL);
886
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
887
+
888
+ assertEquals(0f, root.getLayoutX(), 0.0f);
889
+ assertEquals(0f, root.getLayoutY(), 0.0f);
890
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
891
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
892
+
893
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
894
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
895
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
896
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
897
+
898
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
899
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
900
+ assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f);
901
+ assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
902
+
903
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
904
+ assertEquals(5f, root_child1.getLayoutY(), 0.0f);
905
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
906
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
907
+
908
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
909
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
910
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
911
+ assertEquals(15f, root_child1_child0.getLayoutHeight(), 0.0f);
912
+ }
913
+
914
+ @Test
915
+ public void test_align_baseline_column() {
916
+ YogaConfig config = YogaConfigFactory.create();
917
+
918
+ final YogaNode root = createNode(config);
919
+ root.setPositionType(YogaPositionType.ABSOLUTE);
920
+ root.setWidth(100f);
921
+ root.setHeight(100f);
922
+ root.setAlignItems(YogaAlign.BASELINE);
923
+
924
+ final YogaNode root_child0 = createNode(config);
925
+ root_child0.setWidth(50f);
926
+ root_child0.setHeight(50f);
927
+ root.addChildAt(root_child0, 0);
928
+
929
+ final YogaNode root_child1 = createNode(config);
930
+ root_child1.setWidth(50f);
931
+ root_child1.setHeight(20f);
932
+ root.addChildAt(root_child1, 1);
933
+ root.setDirection(YogaDirection.LTR);
934
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
935
+
936
+ assertEquals(0f, root.getLayoutX(), 0.0f);
937
+ assertEquals(0f, root.getLayoutY(), 0.0f);
938
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
939
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
940
+
941
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
942
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
943
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
944
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
945
+
946
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
947
+ assertEquals(50f, root_child1.getLayoutY(), 0.0f);
948
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
949
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
950
+
951
+ root.setDirection(YogaDirection.RTL);
952
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
953
+
954
+ assertEquals(0f, root.getLayoutX(), 0.0f);
955
+ assertEquals(0f, root.getLayoutY(), 0.0f);
956
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
957
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
958
+
959
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
960
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
961
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
962
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
963
+
964
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
965
+ assertEquals(50f, root_child1.getLayoutY(), 0.0f);
966
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
967
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
968
+ }
969
+
970
+ @Test
971
+ public void test_align_baseline_child_margin() {
972
+ YogaConfig config = YogaConfigFactory.create();
973
+
974
+ final YogaNode root = createNode(config);
975
+ root.setPositionType(YogaPositionType.ABSOLUTE);
976
+ root.setWidth(100f);
977
+ root.setHeight(100f);
978
+ root.setFlexDirection(YogaFlexDirection.ROW);
979
+ root.setAlignItems(YogaAlign.BASELINE);
980
+
981
+ final YogaNode root_child0 = createNode(config);
982
+ root_child0.setWidth(50f);
983
+ root_child0.setHeight(50f);
984
+ root_child0.setMargin(YogaEdge.ALL, 5f);
985
+ root.addChildAt(root_child0, 0);
986
+
987
+ final YogaNode root_child1 = createNode(config);
988
+ root_child1.setWidth(50f);
989
+ root_child1.setHeight(20f);
990
+ root.addChildAt(root_child1, 1);
991
+
992
+ final YogaNode root_child1_child0 = createNode(config);
993
+ root_child1_child0.setWidth(50f);
994
+ root_child1_child0.setHeight(10f);
995
+ root_child1_child0.setMargin(YogaEdge.ALL, 1f);
996
+ root_child1.addChildAt(root_child1_child0, 0);
997
+ root.setDirection(YogaDirection.LTR);
998
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
999
+
1000
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1001
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1002
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1003
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1004
+
1005
+ assertEquals(5f, root_child0.getLayoutX(), 0.0f);
1006
+ assertEquals(5f, root_child0.getLayoutY(), 0.0f);
1007
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1008
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1009
+
1010
+ assertEquals(60f, root_child1.getLayoutX(), 0.0f);
1011
+ assertEquals(44f, root_child1.getLayoutY(), 0.0f);
1012
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1013
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1014
+
1015
+ assertEquals(1f, root_child1_child0.getLayoutX(), 0.0f);
1016
+ assertEquals(1f, root_child1_child0.getLayoutY(), 0.0f);
1017
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
1018
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
1019
+
1020
+ root.setDirection(YogaDirection.RTL);
1021
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1022
+
1023
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1024
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1025
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1026
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1027
+
1028
+ assertEquals(45f, root_child0.getLayoutX(), 0.0f);
1029
+ assertEquals(5f, root_child0.getLayoutY(), 0.0f);
1030
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1031
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1032
+
1033
+ assertEquals(-10f, root_child1.getLayoutX(), 0.0f);
1034
+ assertEquals(44f, root_child1.getLayoutY(), 0.0f);
1035
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1036
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1037
+
1038
+ assertEquals(-1f, root_child1_child0.getLayoutX(), 0.0f);
1039
+ assertEquals(1f, root_child1_child0.getLayoutY(), 0.0f);
1040
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
1041
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
1042
+ }
1043
+
1044
+ @Test
1045
+ public void test_align_baseline_child_padding() {
1046
+ YogaConfig config = YogaConfigFactory.create();
1047
+
1048
+ final YogaNode root = createNode(config);
1049
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1050
+ root.setWidth(100f);
1051
+ root.setHeight(100f);
1052
+ root.setPadding(YogaEdge.ALL, 5);
1053
+ root.setFlexDirection(YogaFlexDirection.ROW);
1054
+ root.setAlignItems(YogaAlign.BASELINE);
1055
+
1056
+ final YogaNode root_child0 = createNode(config);
1057
+ root_child0.setWidth(50f);
1058
+ root_child0.setHeight(50f);
1059
+ root.addChildAt(root_child0, 0);
1060
+
1061
+ final YogaNode root_child1 = createNode(config);
1062
+ root_child1.setWidth(50f);
1063
+ root_child1.setHeight(20f);
1064
+ root_child1.setPadding(YogaEdge.ALL, 5);
1065
+ root.addChildAt(root_child1, 1);
1066
+
1067
+ final YogaNode root_child1_child0 = createNode(config);
1068
+ root_child1_child0.setWidth(50f);
1069
+ root_child1_child0.setHeight(10f);
1070
+ root_child1.addChildAt(root_child1_child0, 0);
1071
+ root.setDirection(YogaDirection.LTR);
1072
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1073
+
1074
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1075
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1076
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1077
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1078
+
1079
+ assertEquals(5f, root_child0.getLayoutX(), 0.0f);
1080
+ assertEquals(5f, root_child0.getLayoutY(), 0.0f);
1081
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1082
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1083
+
1084
+ assertEquals(55f, root_child1.getLayoutX(), 0.0f);
1085
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
1086
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1087
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1088
+
1089
+ assertEquals(5f, root_child1_child0.getLayoutX(), 0.0f);
1090
+ assertEquals(5f, root_child1_child0.getLayoutY(), 0.0f);
1091
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
1092
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
1093
+
1094
+ root.setDirection(YogaDirection.RTL);
1095
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1096
+
1097
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1098
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1099
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1100
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1101
+
1102
+ assertEquals(45f, root_child0.getLayoutX(), 0.0f);
1103
+ assertEquals(5f, root_child0.getLayoutY(), 0.0f);
1104
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1105
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1106
+
1107
+ assertEquals(-5f, root_child1.getLayoutX(), 0.0f);
1108
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
1109
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1110
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1111
+
1112
+ assertEquals(-5f, root_child1_child0.getLayoutX(), 0.0f);
1113
+ assertEquals(5f, root_child1_child0.getLayoutY(), 0.0f);
1114
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
1115
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
1116
+ }
1117
+
1118
+ @Test
1119
+ public void test_align_baseline_multiline() {
1120
+ YogaConfig config = YogaConfigFactory.create();
1121
+
1122
+ final YogaNode root = createNode(config);
1123
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1124
+ root.setWidth(100f);
1125
+ root.setHeight(100f);
1126
+ root.setFlexDirection(YogaFlexDirection.ROW);
1127
+ root.setAlignItems(YogaAlign.BASELINE);
1128
+ root.setWrap(YogaWrap.WRAP);
1129
+
1130
+ final YogaNode root_child0 = createNode(config);
1131
+ root_child0.setWidth(50f);
1132
+ root_child0.setHeight(50f);
1133
+ root.addChildAt(root_child0, 0);
1134
+
1135
+ final YogaNode root_child1 = createNode(config);
1136
+ root_child1.setWidth(50f);
1137
+ root_child1.setHeight(20f);
1138
+ root.addChildAt(root_child1, 1);
1139
+
1140
+ final YogaNode root_child1_child0 = createNode(config);
1141
+ root_child1_child0.setWidth(50f);
1142
+ root_child1_child0.setHeight(10f);
1143
+ root_child1.addChildAt(root_child1_child0, 0);
1144
+
1145
+ final YogaNode root_child2 = createNode(config);
1146
+ root_child2.setWidth(50f);
1147
+ root_child2.setHeight(20f);
1148
+ root.addChildAt(root_child2, 2);
1149
+
1150
+ final YogaNode root_child2_child0 = createNode(config);
1151
+ root_child2_child0.setWidth(50f);
1152
+ root_child2_child0.setHeight(10f);
1153
+ root_child2.addChildAt(root_child2_child0, 0);
1154
+
1155
+ final YogaNode root_child3 = createNode(config);
1156
+ root_child3.setWidth(50f);
1157
+ root_child3.setHeight(50f);
1158
+ root.addChildAt(root_child3, 3);
1159
+ root.setDirection(YogaDirection.LTR);
1160
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1161
+
1162
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1163
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1164
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1165
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1166
+
1167
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1168
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1169
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1170
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1171
+
1172
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
1173
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
1174
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1175
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1176
+
1177
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
1178
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
1179
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
1180
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
1181
+
1182
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
1183
+ assertEquals(100f, root_child2.getLayoutY(), 0.0f);
1184
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
1185
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1186
+
1187
+ assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f);
1188
+ assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f);
1189
+ assertEquals(50f, root_child2_child0.getLayoutWidth(), 0.0f);
1190
+ assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f);
1191
+
1192
+ assertEquals(50f, root_child3.getLayoutX(), 0.0f);
1193
+ assertEquals(60f, root_child3.getLayoutY(), 0.0f);
1194
+ assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
1195
+ assertEquals(50f, root_child3.getLayoutHeight(), 0.0f);
1196
+
1197
+ root.setDirection(YogaDirection.RTL);
1198
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1199
+
1200
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1201
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1202
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1203
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1204
+
1205
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
1206
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1207
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1208
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1209
+
1210
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
1211
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
1212
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1213
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1214
+
1215
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
1216
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
1217
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
1218
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
1219
+
1220
+ assertEquals(50f, root_child2.getLayoutX(), 0.0f);
1221
+ assertEquals(100f, root_child2.getLayoutY(), 0.0f);
1222
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
1223
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1224
+
1225
+ assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f);
1226
+ assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f);
1227
+ assertEquals(50f, root_child2_child0.getLayoutWidth(), 0.0f);
1228
+ assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f);
1229
+
1230
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1231
+ assertEquals(60f, root_child3.getLayoutY(), 0.0f);
1232
+ assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
1233
+ assertEquals(50f, root_child3.getLayoutHeight(), 0.0f);
1234
+ }
1235
+
1236
+ @Test
1237
+ public void test_align_baseline_multiline_row_and_column() {
1238
+ YogaConfig config = YogaConfigFactory.create();
1239
+
1240
+ final YogaNode root = createNode(config);
1241
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1242
+ root.setWidth(100f);
1243
+ root.setHeight(100f);
1244
+ root.setFlexDirection(YogaFlexDirection.ROW);
1245
+ root.setAlignItems(YogaAlign.BASELINE);
1246
+ root.setWrap(YogaWrap.WRAP);
1247
+
1248
+ final YogaNode root_child0 = createNode(config);
1249
+ root_child0.setWidth(50f);
1250
+ root_child0.setHeight(50f);
1251
+ root.addChildAt(root_child0, 0);
1252
+
1253
+ final YogaNode root_child1 = createNode(config);
1254
+ root_child1.setWidth(50f);
1255
+ root_child1.setHeight(50f);
1256
+ root.addChildAt(root_child1, 1);
1257
+
1258
+ final YogaNode root_child1_child0 = createNode(config);
1259
+ root_child1_child0.setWidth(50f);
1260
+ root_child1_child0.setHeight(10f);
1261
+ root_child1.addChildAt(root_child1_child0, 0);
1262
+
1263
+ final YogaNode root_child2 = createNode(config);
1264
+ root_child2.setWidth(50f);
1265
+ root_child2.setHeight(20f);
1266
+ root.addChildAt(root_child2, 2);
1267
+
1268
+ final YogaNode root_child2_child0 = createNode(config);
1269
+ root_child2_child0.setWidth(50f);
1270
+ root_child2_child0.setHeight(10f);
1271
+ root_child2.addChildAt(root_child2_child0, 0);
1272
+
1273
+ final YogaNode root_child3 = createNode(config);
1274
+ root_child3.setWidth(50f);
1275
+ root_child3.setHeight(20f);
1276
+ root.addChildAt(root_child3, 3);
1277
+ root.setDirection(YogaDirection.LTR);
1278
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1279
+
1280
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1281
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1282
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1283
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1284
+
1285
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1286
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1287
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1288
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1289
+
1290
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
1291
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
1292
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1293
+ assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
1294
+
1295
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
1296
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
1297
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
1298
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
1299
+
1300
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
1301
+ assertEquals(100f, root_child2.getLayoutY(), 0.0f);
1302
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
1303
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1304
+
1305
+ assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f);
1306
+ assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f);
1307
+ assertEquals(50f, root_child2_child0.getLayoutWidth(), 0.0f);
1308
+ assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f);
1309
+
1310
+ assertEquals(50f, root_child3.getLayoutX(), 0.0f);
1311
+ assertEquals(90f, root_child3.getLayoutY(), 0.0f);
1312
+ assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
1313
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1314
+
1315
+ root.setDirection(YogaDirection.RTL);
1316
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1317
+
1318
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1319
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1320
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1321
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1322
+
1323
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
1324
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1325
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1326
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1327
+
1328
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
1329
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
1330
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1331
+ assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
1332
+
1333
+ assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
1334
+ assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
1335
+ assertEquals(50f, root_child1_child0.getLayoutWidth(), 0.0f);
1336
+ assertEquals(10f, root_child1_child0.getLayoutHeight(), 0.0f);
1337
+
1338
+ assertEquals(50f, root_child2.getLayoutX(), 0.0f);
1339
+ assertEquals(100f, root_child2.getLayoutY(), 0.0f);
1340
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
1341
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1342
+
1343
+ assertEquals(0f, root_child2_child0.getLayoutX(), 0.0f);
1344
+ assertEquals(0f, root_child2_child0.getLayoutY(), 0.0f);
1345
+ assertEquals(50f, root_child2_child0.getLayoutWidth(), 0.0f);
1346
+ assertEquals(10f, root_child2_child0.getLayoutHeight(), 0.0f);
1347
+
1348
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1349
+ assertEquals(90f, root_child3.getLayoutY(), 0.0f);
1350
+ assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
1351
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1352
+ }
1353
+
1354
+ @Test
1355
+ public void test_align_items_center_child_with_margin_bigger_than_parent() {
1356
+ YogaConfig config = YogaConfigFactory.create();
1357
+
1358
+ final YogaNode root = createNode(config);
1359
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1360
+ root.setHeight(52f);
1361
+ root.setWidth(52f);
1362
+ root.setAlignItems(YogaAlign.CENTER);
1363
+ root.setJustifyContent(YogaJustify.CENTER);
1364
+
1365
+ final YogaNode root_child0 = createNode(config);
1366
+ root_child0.setAlignItems(YogaAlign.CENTER);
1367
+ root.addChildAt(root_child0, 0);
1368
+
1369
+ final YogaNode root_child0_child0 = createNode(config);
1370
+ root_child0_child0.setWidth(52f);
1371
+ root_child0_child0.setHeight(52f);
1372
+ root_child0_child0.setMargin(YogaEdge.LEFT, 10f);
1373
+ root_child0_child0.setMargin(YogaEdge.RIGHT, 10f);
1374
+ root_child0.addChildAt(root_child0_child0, 0);
1375
+ root.setDirection(YogaDirection.LTR);
1376
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1377
+
1378
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1379
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1380
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
1381
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
1382
+
1383
+ assertEquals(-10f, root_child0.getLayoutX(), 0.0f);
1384
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1385
+ assertEquals(72f, root_child0.getLayoutWidth(), 0.0f);
1386
+ assertEquals(52f, root_child0.getLayoutHeight(), 0.0f);
1387
+
1388
+ assertEquals(10f, root_child0_child0.getLayoutX(), 0.0f);
1389
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1390
+ assertEquals(52f, root_child0_child0.getLayoutWidth(), 0.0f);
1391
+ assertEquals(52f, root_child0_child0.getLayoutHeight(), 0.0f);
1392
+
1393
+ root.setDirection(YogaDirection.RTL);
1394
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1395
+
1396
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1397
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1398
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
1399
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
1400
+
1401
+ assertEquals(-10f, root_child0.getLayoutX(), 0.0f);
1402
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1403
+ assertEquals(72f, root_child0.getLayoutWidth(), 0.0f);
1404
+ assertEquals(52f, root_child0.getLayoutHeight(), 0.0f);
1405
+
1406
+ assertEquals(10f, root_child0_child0.getLayoutX(), 0.0f);
1407
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1408
+ assertEquals(52f, root_child0_child0.getLayoutWidth(), 0.0f);
1409
+ assertEquals(52f, root_child0_child0.getLayoutHeight(), 0.0f);
1410
+ }
1411
+
1412
+ @Test
1413
+ public void test_align_items_flex_end_child_with_margin_bigger_than_parent() {
1414
+ YogaConfig config = YogaConfigFactory.create();
1415
+
1416
+ final YogaNode root = createNode(config);
1417
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1418
+ root.setHeight(52f);
1419
+ root.setWidth(52f);
1420
+ root.setAlignItems(YogaAlign.CENTER);
1421
+ root.setJustifyContent(YogaJustify.CENTER);
1422
+
1423
+ final YogaNode root_child0 = createNode(config);
1424
+ root_child0.setAlignItems(YogaAlign.FLEX_END);
1425
+ root.addChildAt(root_child0, 0);
1426
+
1427
+ final YogaNode root_child0_child0 = createNode(config);
1428
+ root_child0_child0.setWidth(52f);
1429
+ root_child0_child0.setHeight(52f);
1430
+ root_child0_child0.setMargin(YogaEdge.LEFT, 10f);
1431
+ root_child0_child0.setMargin(YogaEdge.RIGHT, 10f);
1432
+ root_child0.addChildAt(root_child0_child0, 0);
1433
+ root.setDirection(YogaDirection.LTR);
1434
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1435
+
1436
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1437
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1438
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
1439
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
1440
+
1441
+ assertEquals(-10f, root_child0.getLayoutX(), 0.0f);
1442
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1443
+ assertEquals(72f, root_child0.getLayoutWidth(), 0.0f);
1444
+ assertEquals(52f, root_child0.getLayoutHeight(), 0.0f);
1445
+
1446
+ assertEquals(10f, root_child0_child0.getLayoutX(), 0.0f);
1447
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1448
+ assertEquals(52f, root_child0_child0.getLayoutWidth(), 0.0f);
1449
+ assertEquals(52f, root_child0_child0.getLayoutHeight(), 0.0f);
1450
+
1451
+ root.setDirection(YogaDirection.RTL);
1452
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1453
+
1454
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1455
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1456
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
1457
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
1458
+
1459
+ assertEquals(-10f, root_child0.getLayoutX(), 0.0f);
1460
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1461
+ assertEquals(72f, root_child0.getLayoutWidth(), 0.0f);
1462
+ assertEquals(52f, root_child0.getLayoutHeight(), 0.0f);
1463
+
1464
+ assertEquals(10f, root_child0_child0.getLayoutX(), 0.0f);
1465
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1466
+ assertEquals(52f, root_child0_child0.getLayoutWidth(), 0.0f);
1467
+ assertEquals(52f, root_child0_child0.getLayoutHeight(), 0.0f);
1468
+ }
1469
+
1470
+ @Test
1471
+ public void test_align_items_center_child_without_margin_bigger_than_parent() {
1472
+ YogaConfig config = YogaConfigFactory.create();
1473
+
1474
+ final YogaNode root = createNode(config);
1475
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1476
+ root.setHeight(52f);
1477
+ root.setWidth(52f);
1478
+ root.setAlignItems(YogaAlign.CENTER);
1479
+ root.setJustifyContent(YogaJustify.CENTER);
1480
+
1481
+ final YogaNode root_child0 = createNode(config);
1482
+ root_child0.setAlignItems(YogaAlign.CENTER);
1483
+ root.addChildAt(root_child0, 0);
1484
+
1485
+ final YogaNode root_child0_child0 = createNode(config);
1486
+ root_child0_child0.setWidth(72f);
1487
+ root_child0_child0.setHeight(72f);
1488
+ root_child0.addChildAt(root_child0_child0, 0);
1489
+ root.setDirection(YogaDirection.LTR);
1490
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1491
+
1492
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1493
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1494
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
1495
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
1496
+
1497
+ assertEquals(-10f, root_child0.getLayoutX(), 0.0f);
1498
+ assertEquals(-10f, root_child0.getLayoutY(), 0.0f);
1499
+ assertEquals(72f, root_child0.getLayoutWidth(), 0.0f);
1500
+ assertEquals(72f, root_child0.getLayoutHeight(), 0.0f);
1501
+
1502
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1503
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1504
+ assertEquals(72f, root_child0_child0.getLayoutWidth(), 0.0f);
1505
+ assertEquals(72f, root_child0_child0.getLayoutHeight(), 0.0f);
1506
+
1507
+ root.setDirection(YogaDirection.RTL);
1508
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1509
+
1510
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1511
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1512
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
1513
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
1514
+
1515
+ assertEquals(-10f, root_child0.getLayoutX(), 0.0f);
1516
+ assertEquals(-10f, root_child0.getLayoutY(), 0.0f);
1517
+ assertEquals(72f, root_child0.getLayoutWidth(), 0.0f);
1518
+ assertEquals(72f, root_child0.getLayoutHeight(), 0.0f);
1519
+
1520
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1521
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1522
+ assertEquals(72f, root_child0_child0.getLayoutWidth(), 0.0f);
1523
+ assertEquals(72f, root_child0_child0.getLayoutHeight(), 0.0f);
1524
+ }
1525
+
1526
+ @Test
1527
+ public void test_align_items_flex_end_child_without_margin_bigger_than_parent() {
1528
+ YogaConfig config = YogaConfigFactory.create();
1529
+
1530
+ final YogaNode root = createNode(config);
1531
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1532
+ root.setHeight(52f);
1533
+ root.setWidth(52f);
1534
+ root.setAlignItems(YogaAlign.CENTER);
1535
+ root.setJustifyContent(YogaJustify.CENTER);
1536
+
1537
+ final YogaNode root_child0 = createNode(config);
1538
+ root_child0.setAlignItems(YogaAlign.FLEX_END);
1539
+ root.addChildAt(root_child0, 0);
1540
+
1541
+ final YogaNode root_child0_child0 = createNode(config);
1542
+ root_child0_child0.setWidth(72f);
1543
+ root_child0_child0.setHeight(72f);
1544
+ root_child0.addChildAt(root_child0_child0, 0);
1545
+ root.setDirection(YogaDirection.LTR);
1546
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1547
+
1548
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1549
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1550
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
1551
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
1552
+
1553
+ assertEquals(-10f, root_child0.getLayoutX(), 0.0f);
1554
+ assertEquals(-10f, root_child0.getLayoutY(), 0.0f);
1555
+ assertEquals(72f, root_child0.getLayoutWidth(), 0.0f);
1556
+ assertEquals(72f, root_child0.getLayoutHeight(), 0.0f);
1557
+
1558
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1559
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1560
+ assertEquals(72f, root_child0_child0.getLayoutWidth(), 0.0f);
1561
+ assertEquals(72f, root_child0_child0.getLayoutHeight(), 0.0f);
1562
+
1563
+ root.setDirection(YogaDirection.RTL);
1564
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1565
+
1566
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1567
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1568
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
1569
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
1570
+
1571
+ assertEquals(-10f, root_child0.getLayoutX(), 0.0f);
1572
+ assertEquals(-10f, root_child0.getLayoutY(), 0.0f);
1573
+ assertEquals(72f, root_child0.getLayoutWidth(), 0.0f);
1574
+ assertEquals(72f, root_child0.getLayoutHeight(), 0.0f);
1575
+
1576
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1577
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1578
+ assertEquals(72f, root_child0_child0.getLayoutWidth(), 0.0f);
1579
+ assertEquals(72f, root_child0_child0.getLayoutHeight(), 0.0f);
1580
+ }
1581
+
1582
+ @Test
1583
+ public void test_align_center_should_size_based_on_content() {
1584
+ YogaConfig config = YogaConfigFactory.create();
1585
+
1586
+ final YogaNode root = createNode(config);
1587
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1588
+ root.setWidth(100f);
1589
+ root.setHeight(100f);
1590
+ root.setAlignItems(YogaAlign.CENTER);
1591
+ root.setMargin(YogaEdge.TOP, 20f);
1592
+
1593
+ final YogaNode root_child0 = createNode(config);
1594
+ root_child0.setFlexShrink(1f);
1595
+ root_child0.setJustifyContent(YogaJustify.CENTER);
1596
+ root.addChildAt(root_child0, 0);
1597
+
1598
+ final YogaNode root_child0_child0 = createNode(config);
1599
+ root_child0_child0.setFlexGrow(1f);
1600
+ root_child0_child0.setFlexShrink(1f);
1601
+ root_child0.addChildAt(root_child0_child0, 0);
1602
+
1603
+ final YogaNode root_child0_child0_child0 = createNode(config);
1604
+ root_child0_child0_child0.setWidth(20f);
1605
+ root_child0_child0_child0.setHeight(20f);
1606
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
1607
+ root.setDirection(YogaDirection.LTR);
1608
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1609
+
1610
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1611
+ assertEquals(20f, root.getLayoutY(), 0.0f);
1612
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1613
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1614
+
1615
+ assertEquals(40f, root_child0.getLayoutX(), 0.0f);
1616
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1617
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1618
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1619
+
1620
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1621
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1622
+ assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
1623
+ assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
1624
+
1625
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
1626
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1627
+ assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1628
+ assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1629
+
1630
+ root.setDirection(YogaDirection.RTL);
1631
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1632
+
1633
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1634
+ assertEquals(20f, root.getLayoutY(), 0.0f);
1635
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1636
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1637
+
1638
+ assertEquals(40f, root_child0.getLayoutX(), 0.0f);
1639
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1640
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1641
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1642
+
1643
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1644
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1645
+ assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
1646
+ assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
1647
+
1648
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
1649
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1650
+ assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1651
+ assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1652
+ }
1653
+
1654
+ @Test
1655
+ public void test_align_stretch_should_size_based_on_parent() {
1656
+ YogaConfig config = YogaConfigFactory.create();
1657
+
1658
+ final YogaNode root = createNode(config);
1659
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1660
+ root.setWidth(100f);
1661
+ root.setHeight(100f);
1662
+ root.setMargin(YogaEdge.TOP, 20f);
1663
+
1664
+ final YogaNode root_child0 = createNode(config);
1665
+ root_child0.setFlexShrink(1f);
1666
+ root_child0.setJustifyContent(YogaJustify.CENTER);
1667
+ root.addChildAt(root_child0, 0);
1668
+
1669
+ final YogaNode root_child0_child0 = createNode(config);
1670
+ root_child0_child0.setFlexGrow(1f);
1671
+ root_child0_child0.setFlexShrink(1f);
1672
+ root_child0.addChildAt(root_child0_child0, 0);
1673
+
1674
+ final YogaNode root_child0_child0_child0 = createNode(config);
1675
+ root_child0_child0_child0.setWidth(20f);
1676
+ root_child0_child0_child0.setHeight(20f);
1677
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
1678
+ root.setDirection(YogaDirection.LTR);
1679
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1680
+
1681
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1682
+ assertEquals(20f, root.getLayoutY(), 0.0f);
1683
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1684
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1685
+
1686
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1687
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1688
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
1689
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1690
+
1691
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1692
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1693
+ assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
1694
+ assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
1695
+
1696
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
1697
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1698
+ assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1699
+ assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1700
+
1701
+ root.setDirection(YogaDirection.RTL);
1702
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1703
+
1704
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1705
+ assertEquals(20f, root.getLayoutY(), 0.0f);
1706
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1707
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1708
+
1709
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1710
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1711
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
1712
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1713
+
1714
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1715
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1716
+ assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
1717
+ assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
1718
+
1719
+ assertEquals(80f, root_child0_child0_child0.getLayoutX(), 0.0f);
1720
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1721
+ assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1722
+ assertEquals(20f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1723
+ }
1724
+
1725
+ @Test
1726
+ public void test_align_flex_start_with_shrinking_children() {
1727
+ YogaConfig config = YogaConfigFactory.create();
1728
+
1729
+ final YogaNode root = createNode(config);
1730
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1731
+ root.setHeight(500f);
1732
+ root.setWidth(500f);
1733
+
1734
+ final YogaNode root_child0 = createNode(config);
1735
+ root_child0.setAlignItems(YogaAlign.FLEX_START);
1736
+ root.addChildAt(root_child0, 0);
1737
+
1738
+ final YogaNode root_child0_child0 = createNode(config);
1739
+ root_child0_child0.setFlexGrow(1f);
1740
+ root_child0_child0.setFlexShrink(1f);
1741
+ root_child0.addChildAt(root_child0_child0, 0);
1742
+
1743
+ final YogaNode root_child0_child0_child0 = createNode(config);
1744
+ root_child0_child0_child0.setFlexGrow(1f);
1745
+ root_child0_child0_child0.setFlexShrink(1f);
1746
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
1747
+ root.setDirection(YogaDirection.LTR);
1748
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1749
+
1750
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1751
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1752
+ assertEquals(500f, root.getLayoutWidth(), 0.0f);
1753
+ assertEquals(500f, root.getLayoutHeight(), 0.0f);
1754
+
1755
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1756
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1757
+ assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
1758
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1759
+
1760
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1761
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1762
+ assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
1763
+ assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
1764
+
1765
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
1766
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1767
+ assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1768
+ assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1769
+
1770
+ root.setDirection(YogaDirection.RTL);
1771
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1772
+
1773
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1774
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1775
+ assertEquals(500f, root.getLayoutWidth(), 0.0f);
1776
+ assertEquals(500f, root.getLayoutHeight(), 0.0f);
1777
+
1778
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1779
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1780
+ assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
1781
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1782
+
1783
+ assertEquals(500f, root_child0_child0.getLayoutX(), 0.0f);
1784
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1785
+ assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
1786
+ assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
1787
+
1788
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
1789
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1790
+ assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1791
+ assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1792
+ }
1793
+
1794
+ @Test
1795
+ public void test_align_flex_start_with_stretching_children() {
1796
+ YogaConfig config = YogaConfigFactory.create();
1797
+
1798
+ final YogaNode root = createNode(config);
1799
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1800
+ root.setHeight(500f);
1801
+ root.setWidth(500f);
1802
+
1803
+ final YogaNode root_child0 = createNode(config);
1804
+ root.addChildAt(root_child0, 0);
1805
+
1806
+ final YogaNode root_child0_child0 = createNode(config);
1807
+ root_child0_child0.setFlexGrow(1f);
1808
+ root_child0_child0.setFlexShrink(1f);
1809
+ root_child0.addChildAt(root_child0_child0, 0);
1810
+
1811
+ final YogaNode root_child0_child0_child0 = createNode(config);
1812
+ root_child0_child0_child0.setFlexGrow(1f);
1813
+ root_child0_child0_child0.setFlexShrink(1f);
1814
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
1815
+ root.setDirection(YogaDirection.LTR);
1816
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1817
+
1818
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1819
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1820
+ assertEquals(500f, root.getLayoutWidth(), 0.0f);
1821
+ assertEquals(500f, root.getLayoutHeight(), 0.0f);
1822
+
1823
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1824
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1825
+ assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
1826
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1827
+
1828
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1829
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1830
+ assertEquals(500f, root_child0_child0.getLayoutWidth(), 0.0f);
1831
+ assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
1832
+
1833
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
1834
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1835
+ assertEquals(500f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1836
+ assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1837
+
1838
+ root.setDirection(YogaDirection.RTL);
1839
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1840
+
1841
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1842
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1843
+ assertEquals(500f, root.getLayoutWidth(), 0.0f);
1844
+ assertEquals(500f, root.getLayoutHeight(), 0.0f);
1845
+
1846
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1847
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1848
+ assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
1849
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1850
+
1851
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1852
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1853
+ assertEquals(500f, root_child0_child0.getLayoutWidth(), 0.0f);
1854
+ assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
1855
+
1856
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
1857
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1858
+ assertEquals(500f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1859
+ assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1860
+ }
1861
+
1862
+ @Test
1863
+ public void test_align_flex_start_with_shrinking_children_with_stretch() {
1864
+ YogaConfig config = YogaConfigFactory.create();
1865
+
1866
+ final YogaNode root = createNode(config);
1867
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1868
+ root.setHeight(500f);
1869
+ root.setWidth(500f);
1870
+
1871
+ final YogaNode root_child0 = createNode(config);
1872
+ root_child0.setAlignItems(YogaAlign.FLEX_START);
1873
+ root.addChildAt(root_child0, 0);
1874
+
1875
+ final YogaNode root_child0_child0 = createNode(config);
1876
+ root_child0_child0.setFlexGrow(1f);
1877
+ root_child0_child0.setFlexShrink(1f);
1878
+ root_child0.addChildAt(root_child0_child0, 0);
1879
+
1880
+ final YogaNode root_child0_child0_child0 = createNode(config);
1881
+ root_child0_child0_child0.setFlexGrow(1f);
1882
+ root_child0_child0_child0.setFlexShrink(1f);
1883
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
1884
+ root.setDirection(YogaDirection.LTR);
1885
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1886
+
1887
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1888
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1889
+ assertEquals(500f, root.getLayoutWidth(), 0.0f);
1890
+ assertEquals(500f, root.getLayoutHeight(), 0.0f);
1891
+
1892
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1893
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1894
+ assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
1895
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1896
+
1897
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1898
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1899
+ assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
1900
+ assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
1901
+
1902
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
1903
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1904
+ assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1905
+ assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1906
+
1907
+ root.setDirection(YogaDirection.RTL);
1908
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1909
+
1910
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1911
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1912
+ assertEquals(500f, root.getLayoutWidth(), 0.0f);
1913
+ assertEquals(500f, root.getLayoutHeight(), 0.0f);
1914
+
1915
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1916
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1917
+ assertEquals(500f, root_child0.getLayoutWidth(), 0.0f);
1918
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1919
+
1920
+ assertEquals(500f, root_child0_child0.getLayoutX(), 0.0f);
1921
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1922
+ assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
1923
+ assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
1924
+
1925
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
1926
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
1927
+ assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1928
+ assertEquals(0f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1929
+ }
1930
+
1931
+ @Test
1932
+ public void test_align_flex_end_with_row_reverse() {
1933
+ YogaConfig config = YogaConfigFactory.create();
1934
+
1935
+ final YogaNode root = createNode(config);
1936
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1937
+ root.setWidth(100f);
1938
+ root.setHeight(75f);
1939
+ root.setAlignItems(YogaAlign.FLEX_END);
1940
+ root.setWrap(YogaWrap.WRAP);
1941
+
1942
+ final YogaNode root_child0 = createNode(config);
1943
+ root_child0.setWidth(50f);
1944
+ root_child0.setHeight(50f);
1945
+ root_child0.setMargin(YogaEdge.RIGHT, 5f);
1946
+ root_child0.setMargin(YogaEdge.LEFT, 3f);
1947
+ root.addChildAt(root_child0, 0);
1948
+
1949
+ final YogaNode root_child1 = createNode(config);
1950
+ root_child1.setWidth(50f);
1951
+ root_child1.setHeight(50f);
1952
+ root.addChildAt(root_child1, 1);
1953
+ root.setDirection(YogaDirection.LTR);
1954
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1955
+
1956
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1957
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1958
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1959
+ assertEquals(75f, root.getLayoutHeight(), 0.0f);
1960
+
1961
+ assertEquals(3f, root_child0.getLayoutX(), 0.0f);
1962
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1963
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1964
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1965
+
1966
+ assertEquals(58f, root_child1.getLayoutX(), 0.0f);
1967
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1968
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1969
+ assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
1970
+
1971
+ root.setDirection(YogaDirection.RTL);
1972
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1973
+
1974
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1975
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1976
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1977
+ assertEquals(75f, root.getLayoutHeight(), 0.0f);
1978
+
1979
+ assertEquals(45f, root_child0.getLayoutX(), 0.0f);
1980
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1981
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1982
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1983
+
1984
+ assertEquals(-8f, root_child1.getLayoutX(), 0.0f);
1985
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1986
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
1987
+ assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
1988
+ }
1989
+
1990
+ @Test
1991
+ public void test_align_stretch_with_row_reverse() {
1992
+ YogaConfig config = YogaConfigFactory.create();
1993
+
1994
+ final YogaNode root = createNode(config);
1995
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1996
+ root.setWidth(100f);
1997
+ root.setHeight(75f);
1998
+ root.setWrap(YogaWrap.WRAP);
1999
+
2000
+ final YogaNode root_child0 = createNode(config);
2001
+ root_child0.setWidth(50f);
2002
+ root_child0.setHeight(50f);
2003
+ root_child0.setMargin(YogaEdge.RIGHT, 5f);
2004
+ root_child0.setMargin(YogaEdge.LEFT, 3f);
2005
+ root.addChildAt(root_child0, 0);
2006
+
2007
+ final YogaNode root_child1 = createNode(config);
2008
+ root_child1.setWidth(50f);
2009
+ root_child1.setHeight(50f);
2010
+ root.addChildAt(root_child1, 1);
2011
+ root.setDirection(YogaDirection.LTR);
2012
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2013
+
2014
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2015
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2016
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
2017
+ assertEquals(75f, root.getLayoutHeight(), 0.0f);
2018
+
2019
+ assertEquals(3f, root_child0.getLayoutX(), 0.0f);
2020
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2021
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
2022
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
2023
+
2024
+ assertEquals(58f, root_child1.getLayoutX(), 0.0f);
2025
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2026
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
2027
+ assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
2028
+
2029
+ root.setDirection(YogaDirection.RTL);
2030
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2031
+
2032
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2033
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2034
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
2035
+ assertEquals(75f, root.getLayoutHeight(), 0.0f);
2036
+
2037
+ assertEquals(45f, root_child0.getLayoutX(), 0.0f);
2038
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2039
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
2040
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
2041
+
2042
+ assertEquals(-8f, root_child1.getLayoutX(), 0.0f);
2043
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2044
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
2045
+ assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
2046
+ }
2047
+
2048
+ @Test
2049
+ public void test_align_items_non_stretch_s526008() {
2050
+ YogaConfig config = YogaConfigFactory.create();
2051
+
2052
+ final YogaNode root = createNode(config);
2053
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2054
+ root.setWidth(400f);
2055
+ root.setHeight(400f);
2056
+
2057
+ final YogaNode root_child0 = createNode(config);
2058
+ root_child0.setFlexDirection(YogaFlexDirection.ROW);
2059
+ root.addChildAt(root_child0, 0);
2060
+
2061
+ final YogaNode root_child0_child0 = createNode(config);
2062
+ root_child0_child0.setAlignItems(YogaAlign.FLEX_START);
2063
+ root_child0.addChildAt(root_child0_child0, 0);
2064
+
2065
+ final YogaNode root_child0_child0_child0 = createNode(config);
2066
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
2067
+
2068
+ final YogaNode root_child0_child0_child0_child0 = createNode(config);
2069
+ root_child0_child0_child0_child0.setWidth(0f);
2070
+ root_child0_child0_child0_child0.setHeight(10f);
2071
+ root_child0_child0_child0.addChildAt(root_child0_child0_child0_child0, 0);
2072
+ root.setDirection(YogaDirection.LTR);
2073
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2074
+
2075
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2076
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2077
+ assertEquals(400f, root.getLayoutWidth(), 0.0f);
2078
+ assertEquals(400f, root.getLayoutHeight(), 0.0f);
2079
+
2080
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2081
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2082
+ assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
2083
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
2084
+
2085
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
2086
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
2087
+ assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
2088
+ assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
2089
+
2090
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
2091
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
2092
+ assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
2093
+ assertEquals(10f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
2094
+
2095
+ assertEquals(0f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
2096
+ assertEquals(0f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
2097
+ assertEquals(0f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
2098
+ assertEquals(10f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
2099
+
2100
+ root.setDirection(YogaDirection.RTL);
2101
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2102
+
2103
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2104
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2105
+ assertEquals(400f, root.getLayoutWidth(), 0.0f);
2106
+ assertEquals(400f, root.getLayoutHeight(), 0.0f);
2107
+
2108
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2109
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2110
+ assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
2111
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
2112
+
2113
+ assertEquals(400f, root_child0_child0.getLayoutX(), 0.0f);
2114
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
2115
+ assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
2116
+ assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
2117
+
2118
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
2119
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
2120
+ assertEquals(0f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
2121
+ assertEquals(10f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
2122
+
2123
+ assertEquals(0f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
2124
+ assertEquals(0f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
2125
+ assertEquals(0f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
2126
+ assertEquals(10f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
2127
+ }
2128
+
2129
+ private YogaNode createNode(YogaConfig config) {
2130
+ return mNodeFactory.create(config);
2131
+ }
2132
+ }