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,2988 @@
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<<4c57d5bd9525e709749fd32794bc296c>>
8
+ * generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGGapTest.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 YGGapTest {
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_column_gap_flexible() {
32
+ YogaConfig config = YogaConfigFactory.create();
33
+
34
+ final YogaNode root = createNode(config);
35
+ root.setPositionType(YogaPositionType.ABSOLUTE);
36
+ root.setFlexDirection(YogaFlexDirection.ROW);
37
+ root.setWidth(80f);
38
+ root.setHeight(100f);
39
+ root.setGap(YogaGutter.COLUMN, 10f);
40
+ root.setGap(YogaGutter.ROW, 20f);
41
+
42
+ final YogaNode root_child0 = createNode(config);
43
+ root_child0.setFlexGrow(1f);
44
+ root_child0.setFlexShrink(1f);
45
+ root_child0.setFlexBasisPercent(0f);
46
+ root.addChildAt(root_child0, 0);
47
+
48
+ final YogaNode root_child1 = createNode(config);
49
+ root_child1.setFlexGrow(1f);
50
+ root_child1.setFlexShrink(1f);
51
+ root_child1.setFlexBasisPercent(0f);
52
+ root.addChildAt(root_child1, 1);
53
+
54
+ final YogaNode root_child2 = createNode(config);
55
+ root_child2.setFlexGrow(1f);
56
+ root_child2.setFlexShrink(1f);
57
+ root_child2.setFlexBasisPercent(0f);
58
+ root.addChildAt(root_child2, 2);
59
+ root.setDirection(YogaDirection.LTR);
60
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
61
+
62
+ assertEquals(0f, root.getLayoutX(), 0.0f);
63
+ assertEquals(0f, root.getLayoutY(), 0.0f);
64
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
65
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
66
+
67
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
68
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
69
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
70
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
71
+
72
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
73
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
74
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
75
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
76
+
77
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
78
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
79
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
80
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
81
+
82
+ root.setDirection(YogaDirection.RTL);
83
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
84
+
85
+ assertEquals(0f, root.getLayoutX(), 0.0f);
86
+ assertEquals(0f, root.getLayoutY(), 0.0f);
87
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
88
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
89
+
90
+ assertEquals(60f, root_child0.getLayoutX(), 0.0f);
91
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
92
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
93
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
94
+
95
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
96
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
97
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
98
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
99
+
100
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
101
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
102
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
103
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
104
+ }
105
+
106
+ @Test
107
+ public void test_column_gap_inflexible() {
108
+ YogaConfig config = YogaConfigFactory.create();
109
+
110
+ final YogaNode root = createNode(config);
111
+ root.setPositionType(YogaPositionType.ABSOLUTE);
112
+ root.setFlexDirection(YogaFlexDirection.ROW);
113
+ root.setWidth(80f);
114
+ root.setHeight(100f);
115
+ root.setGap(YogaGutter.COLUMN, 10f);
116
+
117
+ final YogaNode root_child0 = createNode(config);
118
+ root_child0.setWidth(20f);
119
+ root.addChildAt(root_child0, 0);
120
+
121
+ final YogaNode root_child1 = createNode(config);
122
+ root_child1.setWidth(20f);
123
+ root.addChildAt(root_child1, 1);
124
+
125
+ final YogaNode root_child2 = createNode(config);
126
+ root_child2.setWidth(20f);
127
+ root.addChildAt(root_child2, 2);
128
+ root.setDirection(YogaDirection.LTR);
129
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
130
+
131
+ assertEquals(0f, root.getLayoutX(), 0.0f);
132
+ assertEquals(0f, root.getLayoutY(), 0.0f);
133
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
134
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
135
+
136
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
137
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
138
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
139
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
140
+
141
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
142
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
143
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
144
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
145
+
146
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
147
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
148
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
149
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
150
+
151
+ root.setDirection(YogaDirection.RTL);
152
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
153
+
154
+ assertEquals(0f, root.getLayoutX(), 0.0f);
155
+ assertEquals(0f, root.getLayoutY(), 0.0f);
156
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
157
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
158
+
159
+ assertEquals(60f, root_child0.getLayoutX(), 0.0f);
160
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
161
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
162
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
163
+
164
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
165
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
166
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
167
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
168
+
169
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
170
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
171
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
172
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
173
+ }
174
+
175
+ @Test
176
+ public void test_column_gap_mixed_flexible() {
177
+ YogaConfig config = YogaConfigFactory.create();
178
+
179
+ final YogaNode root = createNode(config);
180
+ root.setPositionType(YogaPositionType.ABSOLUTE);
181
+ root.setFlexDirection(YogaFlexDirection.ROW);
182
+ root.setWidth(80f);
183
+ root.setHeight(100f);
184
+ root.setGap(YogaGutter.COLUMN, 10f);
185
+
186
+ final YogaNode root_child0 = createNode(config);
187
+ root_child0.setWidth(20f);
188
+ root.addChildAt(root_child0, 0);
189
+
190
+ final YogaNode root_child1 = createNode(config);
191
+ root_child1.setFlexGrow(1f);
192
+ root_child1.setFlexShrink(1f);
193
+ root_child1.setFlexBasisPercent(0f);
194
+ root.addChildAt(root_child1, 1);
195
+
196
+ final YogaNode root_child2 = createNode(config);
197
+ root_child2.setWidth(20f);
198
+ root.addChildAt(root_child2, 2);
199
+ root.setDirection(YogaDirection.LTR);
200
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
201
+
202
+ assertEquals(0f, root.getLayoutX(), 0.0f);
203
+ assertEquals(0f, root.getLayoutY(), 0.0f);
204
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
205
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
206
+
207
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
208
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
209
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
210
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
211
+
212
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
213
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
214
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
215
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
216
+
217
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
218
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
219
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
220
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
221
+
222
+ root.setDirection(YogaDirection.RTL);
223
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
224
+
225
+ assertEquals(0f, root.getLayoutX(), 0.0f);
226
+ assertEquals(0f, root.getLayoutY(), 0.0f);
227
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
228
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
229
+
230
+ assertEquals(60f, root_child0.getLayoutX(), 0.0f);
231
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
232
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
233
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
234
+
235
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
236
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
237
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
238
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
239
+
240
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
241
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
242
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
243
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
244
+ }
245
+
246
+ @Test
247
+ public void test_column_gap_child_margins() {
248
+ YogaConfig config = YogaConfigFactory.create();
249
+
250
+ final YogaNode root = createNode(config);
251
+ root.setPositionType(YogaPositionType.ABSOLUTE);
252
+ root.setFlexDirection(YogaFlexDirection.ROW);
253
+ root.setWidth(80f);
254
+ root.setHeight(100f);
255
+ root.setGap(YogaGutter.COLUMN, 10f);
256
+
257
+ final YogaNode root_child0 = createNode(config);
258
+ root_child0.setFlexGrow(1f);
259
+ root_child0.setFlexShrink(1f);
260
+ root_child0.setFlexBasisPercent(0f);
261
+ root_child0.setMargin(YogaEdge.HORIZONTAL, 2f);
262
+ root.addChildAt(root_child0, 0);
263
+
264
+ final YogaNode root_child1 = createNode(config);
265
+ root_child1.setFlexGrow(1f);
266
+ root_child1.setFlexShrink(1f);
267
+ root_child1.setFlexBasisPercent(0f);
268
+ root_child1.setMargin(YogaEdge.HORIZONTAL, 10f);
269
+ root.addChildAt(root_child1, 1);
270
+
271
+ final YogaNode root_child2 = createNode(config);
272
+ root_child2.setFlexGrow(1f);
273
+ root_child2.setFlexShrink(1f);
274
+ root_child2.setFlexBasisPercent(0f);
275
+ root_child2.setMargin(YogaEdge.HORIZONTAL, 15f);
276
+ root.addChildAt(root_child2, 2);
277
+ root.setDirection(YogaDirection.LTR);
278
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
279
+
280
+ assertEquals(0f, root.getLayoutX(), 0.0f);
281
+ assertEquals(0f, root.getLayoutY(), 0.0f);
282
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
283
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
284
+
285
+ assertEquals(2f, root_child0.getLayoutX(), 0.0f);
286
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
287
+ assertEquals(2f, root_child0.getLayoutWidth(), 0.0f);
288
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
289
+
290
+ assertEquals(26f, root_child1.getLayoutX(), 0.0f);
291
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
292
+ assertEquals(2f, root_child1.getLayoutWidth(), 0.0f);
293
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
294
+
295
+ assertEquals(63f, root_child2.getLayoutX(), 0.0f);
296
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
297
+ assertEquals(2f, root_child2.getLayoutWidth(), 0.0f);
298
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
299
+
300
+ root.setDirection(YogaDirection.RTL);
301
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
302
+
303
+ assertEquals(0f, root.getLayoutX(), 0.0f);
304
+ assertEquals(0f, root.getLayoutY(), 0.0f);
305
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
306
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
307
+
308
+ assertEquals(76f, root_child0.getLayoutX(), 0.0f);
309
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
310
+ assertEquals(2f, root_child0.getLayoutWidth(), 0.0f);
311
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
312
+
313
+ assertEquals(52f, root_child1.getLayoutX(), 0.0f);
314
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
315
+ assertEquals(2f, root_child1.getLayoutWidth(), 0.0f);
316
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
317
+
318
+ assertEquals(15f, root_child2.getLayoutX(), 0.0f);
319
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
320
+ assertEquals(2f, root_child2.getLayoutWidth(), 0.0f);
321
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
322
+ }
323
+
324
+ @Test
325
+ public void test_column_row_gap_wrapping() {
326
+ YogaConfig config = YogaConfigFactory.create();
327
+
328
+ final YogaNode root = createNode(config);
329
+ root.setPositionType(YogaPositionType.ABSOLUTE);
330
+ root.setFlexDirection(YogaFlexDirection.ROW);
331
+ root.setWrap(YogaWrap.WRAP);
332
+ root.setWidth(80f);
333
+ root.setGap(YogaGutter.COLUMN, 10f);
334
+ root.setGap(YogaGutter.ROW, 20f);
335
+
336
+ final YogaNode root_child0 = createNode(config);
337
+ root_child0.setWidth(20f);
338
+ root_child0.setHeight(20f);
339
+ root.addChildAt(root_child0, 0);
340
+
341
+ final YogaNode root_child1 = createNode(config);
342
+ root_child1.setWidth(20f);
343
+ root_child1.setHeight(20f);
344
+ root.addChildAt(root_child1, 1);
345
+
346
+ final YogaNode root_child2 = createNode(config);
347
+ root_child2.setWidth(20f);
348
+ root_child2.setHeight(20f);
349
+ root.addChildAt(root_child2, 2);
350
+
351
+ final YogaNode root_child3 = createNode(config);
352
+ root_child3.setWidth(20f);
353
+ root_child3.setHeight(20f);
354
+ root.addChildAt(root_child3, 3);
355
+
356
+ final YogaNode root_child4 = createNode(config);
357
+ root_child4.setWidth(20f);
358
+ root_child4.setHeight(20f);
359
+ root.addChildAt(root_child4, 4);
360
+
361
+ final YogaNode root_child5 = createNode(config);
362
+ root_child5.setWidth(20f);
363
+ root_child5.setHeight(20f);
364
+ root.addChildAt(root_child5, 5);
365
+
366
+ final YogaNode root_child6 = createNode(config);
367
+ root_child6.setWidth(20f);
368
+ root_child6.setHeight(20f);
369
+ root.addChildAt(root_child6, 6);
370
+
371
+ final YogaNode root_child7 = createNode(config);
372
+ root_child7.setWidth(20f);
373
+ root_child7.setHeight(20f);
374
+ root.addChildAt(root_child7, 7);
375
+
376
+ final YogaNode root_child8 = createNode(config);
377
+ root_child8.setWidth(20f);
378
+ root_child8.setHeight(20f);
379
+ root.addChildAt(root_child8, 8);
380
+ root.setDirection(YogaDirection.LTR);
381
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
382
+
383
+ assertEquals(0f, root.getLayoutX(), 0.0f);
384
+ assertEquals(0f, root.getLayoutY(), 0.0f);
385
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
386
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
387
+
388
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
389
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
390
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
391
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
392
+
393
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
394
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
395
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
396
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
397
+
398
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
399
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
400
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
401
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
402
+
403
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
404
+ assertEquals(40f, root_child3.getLayoutY(), 0.0f);
405
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
406
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
407
+
408
+ assertEquals(30f, root_child4.getLayoutX(), 0.0f);
409
+ assertEquals(40f, root_child4.getLayoutY(), 0.0f);
410
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
411
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
412
+
413
+ assertEquals(60f, root_child5.getLayoutX(), 0.0f);
414
+ assertEquals(40f, root_child5.getLayoutY(), 0.0f);
415
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
416
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
417
+
418
+ assertEquals(0f, root_child6.getLayoutX(), 0.0f);
419
+ assertEquals(80f, root_child6.getLayoutY(), 0.0f);
420
+ assertEquals(20f, root_child6.getLayoutWidth(), 0.0f);
421
+ assertEquals(20f, root_child6.getLayoutHeight(), 0.0f);
422
+
423
+ assertEquals(30f, root_child7.getLayoutX(), 0.0f);
424
+ assertEquals(80f, root_child7.getLayoutY(), 0.0f);
425
+ assertEquals(20f, root_child7.getLayoutWidth(), 0.0f);
426
+ assertEquals(20f, root_child7.getLayoutHeight(), 0.0f);
427
+
428
+ assertEquals(60f, root_child8.getLayoutX(), 0.0f);
429
+ assertEquals(80f, root_child8.getLayoutY(), 0.0f);
430
+ assertEquals(20f, root_child8.getLayoutWidth(), 0.0f);
431
+ assertEquals(20f, root_child8.getLayoutHeight(), 0.0f);
432
+
433
+ root.setDirection(YogaDirection.RTL);
434
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
435
+
436
+ assertEquals(0f, root.getLayoutX(), 0.0f);
437
+ assertEquals(0f, root.getLayoutY(), 0.0f);
438
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
439
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
440
+
441
+ assertEquals(60f, root_child0.getLayoutX(), 0.0f);
442
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
443
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
444
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
445
+
446
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
447
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
448
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
449
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
450
+
451
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
452
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
453
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
454
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
455
+
456
+ assertEquals(60f, root_child3.getLayoutX(), 0.0f);
457
+ assertEquals(40f, root_child3.getLayoutY(), 0.0f);
458
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
459
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
460
+
461
+ assertEquals(30f, root_child4.getLayoutX(), 0.0f);
462
+ assertEquals(40f, root_child4.getLayoutY(), 0.0f);
463
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
464
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
465
+
466
+ assertEquals(0f, root_child5.getLayoutX(), 0.0f);
467
+ assertEquals(40f, root_child5.getLayoutY(), 0.0f);
468
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
469
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
470
+
471
+ assertEquals(60f, root_child6.getLayoutX(), 0.0f);
472
+ assertEquals(80f, root_child6.getLayoutY(), 0.0f);
473
+ assertEquals(20f, root_child6.getLayoutWidth(), 0.0f);
474
+ assertEquals(20f, root_child6.getLayoutHeight(), 0.0f);
475
+
476
+ assertEquals(30f, root_child7.getLayoutX(), 0.0f);
477
+ assertEquals(80f, root_child7.getLayoutY(), 0.0f);
478
+ assertEquals(20f, root_child7.getLayoutWidth(), 0.0f);
479
+ assertEquals(20f, root_child7.getLayoutHeight(), 0.0f);
480
+
481
+ assertEquals(0f, root_child8.getLayoutX(), 0.0f);
482
+ assertEquals(80f, root_child8.getLayoutY(), 0.0f);
483
+ assertEquals(20f, root_child8.getLayoutWidth(), 0.0f);
484
+ assertEquals(20f, root_child8.getLayoutHeight(), 0.0f);
485
+ }
486
+
487
+ @Test
488
+ public void test_column_gap_start_index() {
489
+ YogaConfig config = YogaConfigFactory.create();
490
+
491
+ final YogaNode root = createNode(config);
492
+ root.setPositionType(YogaPositionType.ABSOLUTE);
493
+ root.setFlexDirection(YogaFlexDirection.ROW);
494
+ root.setWrap(YogaWrap.WRAP);
495
+ root.setWidth(80f);
496
+ root.setGap(YogaGutter.COLUMN, 10f);
497
+ root.setGap(YogaGutter.ROW, 20f);
498
+
499
+ final YogaNode root_child0 = createNode(config);
500
+ root_child0.setWidth(20f);
501
+ root_child0.setHeight(20f);
502
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
503
+ root.addChildAt(root_child0, 0);
504
+
505
+ final YogaNode root_child1 = createNode(config);
506
+ root_child1.setWidth(20f);
507
+ root_child1.setHeight(20f);
508
+ root.addChildAt(root_child1, 1);
509
+
510
+ final YogaNode root_child2 = createNode(config);
511
+ root_child2.setWidth(20f);
512
+ root_child2.setHeight(20f);
513
+ root.addChildAt(root_child2, 2);
514
+
515
+ final YogaNode root_child3 = createNode(config);
516
+ root_child3.setWidth(20f);
517
+ root_child3.setHeight(20f);
518
+ root.addChildAt(root_child3, 3);
519
+ root.setDirection(YogaDirection.LTR);
520
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
521
+
522
+ assertEquals(0f, root.getLayoutX(), 0.0f);
523
+ assertEquals(0f, root.getLayoutY(), 0.0f);
524
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
525
+ assertEquals(20f, root.getLayoutHeight(), 0.0f);
526
+
527
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
528
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
529
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
530
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
531
+
532
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
533
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
534
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
535
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
536
+
537
+ assertEquals(30f, root_child2.getLayoutX(), 0.0f);
538
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
539
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
540
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
541
+
542
+ assertEquals(60f, root_child3.getLayoutX(), 0.0f);
543
+ assertEquals(0f, root_child3.getLayoutY(), 0.0f);
544
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
545
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
546
+
547
+ root.setDirection(YogaDirection.RTL);
548
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
549
+
550
+ assertEquals(0f, root.getLayoutX(), 0.0f);
551
+ assertEquals(0f, root.getLayoutY(), 0.0f);
552
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
553
+ assertEquals(20f, root.getLayoutHeight(), 0.0f);
554
+
555
+ assertEquals(60f, root_child0.getLayoutX(), 0.0f);
556
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
557
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
558
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
559
+
560
+ assertEquals(60f, root_child1.getLayoutX(), 0.0f);
561
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
562
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
563
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
564
+
565
+ assertEquals(30f, root_child2.getLayoutX(), 0.0f);
566
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
567
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
568
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
569
+
570
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
571
+ assertEquals(0f, root_child3.getLayoutY(), 0.0f);
572
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
573
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
574
+ }
575
+
576
+ @Test
577
+ public void test_column_gap_justify_flex_start() {
578
+ YogaConfig config = YogaConfigFactory.create();
579
+
580
+ final YogaNode root = createNode(config);
581
+ root.setPositionType(YogaPositionType.ABSOLUTE);
582
+ root.setFlexDirection(YogaFlexDirection.ROW);
583
+ root.setWidth(100f);
584
+ root.setHeight(100f);
585
+ root.setGap(YogaGutter.COLUMN, 10f);
586
+
587
+ final YogaNode root_child0 = createNode(config);
588
+ root_child0.setWidth(20f);
589
+ root.addChildAt(root_child0, 0);
590
+
591
+ final YogaNode root_child1 = createNode(config);
592
+ root_child1.setWidth(20f);
593
+ root.addChildAt(root_child1, 1);
594
+
595
+ final YogaNode root_child2 = createNode(config);
596
+ root_child2.setWidth(20f);
597
+ root.addChildAt(root_child2, 2);
598
+ root.setDirection(YogaDirection.LTR);
599
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
600
+
601
+ assertEquals(0f, root.getLayoutX(), 0.0f);
602
+ assertEquals(0f, root.getLayoutY(), 0.0f);
603
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
604
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
605
+
606
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
607
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
608
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
609
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
610
+
611
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
612
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
613
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
614
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
615
+
616
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
617
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
618
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
619
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
620
+
621
+ root.setDirection(YogaDirection.RTL);
622
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
623
+
624
+ assertEquals(0f, root.getLayoutX(), 0.0f);
625
+ assertEquals(0f, root.getLayoutY(), 0.0f);
626
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
627
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
628
+
629
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
630
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
631
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
632
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
633
+
634
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
635
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
636
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
637
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
638
+
639
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
640
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
641
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
642
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
643
+ }
644
+
645
+ @Test
646
+ public void test_column_gap_justify_center() {
647
+ YogaConfig config = YogaConfigFactory.create();
648
+
649
+ final YogaNode root = createNode(config);
650
+ root.setPositionType(YogaPositionType.ABSOLUTE);
651
+ root.setFlexDirection(YogaFlexDirection.ROW);
652
+ root.setJustifyContent(YogaJustify.CENTER);
653
+ root.setWidth(100f);
654
+ root.setHeight(100f);
655
+ root.setGap(YogaGutter.COLUMN, 10f);
656
+
657
+ final YogaNode root_child0 = createNode(config);
658
+ root_child0.setWidth(20f);
659
+ root.addChildAt(root_child0, 0);
660
+
661
+ final YogaNode root_child1 = createNode(config);
662
+ root_child1.setWidth(20f);
663
+ root.addChildAt(root_child1, 1);
664
+
665
+ final YogaNode root_child2 = createNode(config);
666
+ root_child2.setWidth(20f);
667
+ root.addChildAt(root_child2, 2);
668
+ root.setDirection(YogaDirection.LTR);
669
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
670
+
671
+ assertEquals(0f, root.getLayoutX(), 0.0f);
672
+ assertEquals(0f, root.getLayoutY(), 0.0f);
673
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
674
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
675
+
676
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
677
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
678
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
679
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
680
+
681
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
682
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
683
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
684
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
685
+
686
+ assertEquals(70f, root_child2.getLayoutX(), 0.0f);
687
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
688
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
689
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
690
+
691
+ root.setDirection(YogaDirection.RTL);
692
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
693
+
694
+ assertEquals(0f, root.getLayoutX(), 0.0f);
695
+ assertEquals(0f, root.getLayoutY(), 0.0f);
696
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
697
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
698
+
699
+ assertEquals(70f, root_child0.getLayoutX(), 0.0f);
700
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
701
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
702
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
703
+
704
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
705
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
706
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
707
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
708
+
709
+ assertEquals(10f, root_child2.getLayoutX(), 0.0f);
710
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
711
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
712
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
713
+ }
714
+
715
+ @Test
716
+ public void test_column_gap_justify_flex_end() {
717
+ YogaConfig config = YogaConfigFactory.create();
718
+
719
+ final YogaNode root = createNode(config);
720
+ root.setPositionType(YogaPositionType.ABSOLUTE);
721
+ root.setFlexDirection(YogaFlexDirection.ROW);
722
+ root.setJustifyContent(YogaJustify.FLEX_END);
723
+ root.setWidth(100f);
724
+ root.setHeight(100f);
725
+ root.setGap(YogaGutter.COLUMN, 10f);
726
+
727
+ final YogaNode root_child0 = createNode(config);
728
+ root_child0.setWidth(20f);
729
+ root.addChildAt(root_child0, 0);
730
+
731
+ final YogaNode root_child1 = createNode(config);
732
+ root_child1.setWidth(20f);
733
+ root.addChildAt(root_child1, 1);
734
+
735
+ final YogaNode root_child2 = createNode(config);
736
+ root_child2.setWidth(20f);
737
+ root.addChildAt(root_child2, 2);
738
+ root.setDirection(YogaDirection.LTR);
739
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
740
+
741
+ assertEquals(0f, root.getLayoutX(), 0.0f);
742
+ assertEquals(0f, root.getLayoutY(), 0.0f);
743
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
744
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
745
+
746
+ assertEquals(20f, root_child0.getLayoutX(), 0.0f);
747
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
748
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
749
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
750
+
751
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
752
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
753
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
754
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
755
+
756
+ assertEquals(80f, root_child2.getLayoutX(), 0.0f);
757
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
758
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
759
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
760
+
761
+ root.setDirection(YogaDirection.RTL);
762
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
763
+
764
+ assertEquals(0f, root.getLayoutX(), 0.0f);
765
+ assertEquals(0f, root.getLayoutY(), 0.0f);
766
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
767
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
768
+
769
+ assertEquals(60f, root_child0.getLayoutX(), 0.0f);
770
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
771
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
772
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
773
+
774
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
775
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
776
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
777
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
778
+
779
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
780
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
781
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
782
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
783
+ }
784
+
785
+ @Test
786
+ public void test_column_gap_justify_space_between() {
787
+ YogaConfig config = YogaConfigFactory.create();
788
+
789
+ final YogaNode root = createNode(config);
790
+ root.setPositionType(YogaPositionType.ABSOLUTE);
791
+ root.setFlexDirection(YogaFlexDirection.ROW);
792
+ root.setJustifyContent(YogaJustify.SPACE_BETWEEN);
793
+ root.setWidth(100f);
794
+ root.setHeight(100f);
795
+ root.setGap(YogaGutter.COLUMN, 10f);
796
+
797
+ final YogaNode root_child0 = createNode(config);
798
+ root_child0.setWidth(20f);
799
+ root.addChildAt(root_child0, 0);
800
+
801
+ final YogaNode root_child1 = createNode(config);
802
+ root_child1.setWidth(20f);
803
+ root.addChildAt(root_child1, 1);
804
+
805
+ final YogaNode root_child2 = createNode(config);
806
+ root_child2.setWidth(20f);
807
+ root.addChildAt(root_child2, 2);
808
+ root.setDirection(YogaDirection.LTR);
809
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
810
+
811
+ assertEquals(0f, root.getLayoutX(), 0.0f);
812
+ assertEquals(0f, root.getLayoutY(), 0.0f);
813
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
814
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
815
+
816
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
817
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
818
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
819
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
820
+
821
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
822
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
823
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
824
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
825
+
826
+ assertEquals(80f, root_child2.getLayoutX(), 0.0f);
827
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
828
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
829
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
830
+
831
+ root.setDirection(YogaDirection.RTL);
832
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
833
+
834
+ assertEquals(0f, root.getLayoutX(), 0.0f);
835
+ assertEquals(0f, root.getLayoutY(), 0.0f);
836
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
837
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
838
+
839
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
840
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
841
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
842
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
843
+
844
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
845
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
846
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
847
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
848
+
849
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
850
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
851
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
852
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
853
+ }
854
+
855
+ @Test
856
+ public void test_column_gap_justify_space_around() {
857
+ YogaConfig config = YogaConfigFactory.create();
858
+
859
+ final YogaNode root = createNode(config);
860
+ root.setPositionType(YogaPositionType.ABSOLUTE);
861
+ root.setFlexDirection(YogaFlexDirection.ROW);
862
+ root.setJustifyContent(YogaJustify.SPACE_AROUND);
863
+ root.setWidth(100f);
864
+ root.setHeight(100f);
865
+ root.setGap(YogaGutter.COLUMN, 10f);
866
+
867
+ final YogaNode root_child0 = createNode(config);
868
+ root_child0.setWidth(20f);
869
+ root.addChildAt(root_child0, 0);
870
+
871
+ final YogaNode root_child1 = createNode(config);
872
+ root_child1.setWidth(20f);
873
+ root.addChildAt(root_child1, 1);
874
+
875
+ final YogaNode root_child2 = createNode(config);
876
+ root_child2.setWidth(20f);
877
+ root.addChildAt(root_child2, 2);
878
+ root.setDirection(YogaDirection.LTR);
879
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
880
+
881
+ assertEquals(0f, root.getLayoutX(), 0.0f);
882
+ assertEquals(0f, root.getLayoutY(), 0.0f);
883
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
884
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
885
+
886
+ assertEquals(3f, root_child0.getLayoutX(), 0.0f);
887
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
888
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
889
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
890
+
891
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
892
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
893
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
894
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
895
+
896
+ assertEquals(77f, root_child2.getLayoutX(), 0.0f);
897
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
898
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
899
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
900
+
901
+ root.setDirection(YogaDirection.RTL);
902
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
903
+
904
+ assertEquals(0f, root.getLayoutX(), 0.0f);
905
+ assertEquals(0f, root.getLayoutY(), 0.0f);
906
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
907
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
908
+
909
+ assertEquals(77f, root_child0.getLayoutX(), 0.0f);
910
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
911
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
912
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
913
+
914
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
915
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
916
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
917
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
918
+
919
+ assertEquals(3f, root_child2.getLayoutX(), 0.0f);
920
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
921
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
922
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
923
+ }
924
+
925
+ @Test
926
+ public void test_column_gap_justify_space_evenly() {
927
+ YogaConfig config = YogaConfigFactory.create();
928
+
929
+ final YogaNode root = createNode(config);
930
+ root.setPositionType(YogaPositionType.ABSOLUTE);
931
+ root.setFlexDirection(YogaFlexDirection.ROW);
932
+ root.setJustifyContent(YogaJustify.SPACE_EVENLY);
933
+ root.setWidth(100f);
934
+ root.setHeight(100f);
935
+ root.setGap(YogaGutter.COLUMN, 10f);
936
+
937
+ final YogaNode root_child0 = createNode(config);
938
+ root_child0.setWidth(20f);
939
+ root.addChildAt(root_child0, 0);
940
+
941
+ final YogaNode root_child1 = createNode(config);
942
+ root_child1.setWidth(20f);
943
+ root.addChildAt(root_child1, 1);
944
+
945
+ final YogaNode root_child2 = createNode(config);
946
+ root_child2.setWidth(20f);
947
+ root.addChildAt(root_child2, 2);
948
+ root.setDirection(YogaDirection.LTR);
949
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
950
+
951
+ assertEquals(0f, root.getLayoutX(), 0.0f);
952
+ assertEquals(0f, root.getLayoutY(), 0.0f);
953
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
954
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
955
+
956
+ assertEquals(5f, root_child0.getLayoutX(), 0.0f);
957
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
958
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
959
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
960
+
961
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
962
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
963
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
964
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
965
+
966
+ assertEquals(75f, root_child2.getLayoutX(), 0.0f);
967
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
968
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
969
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
970
+
971
+ root.setDirection(YogaDirection.RTL);
972
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
973
+
974
+ assertEquals(0f, root.getLayoutX(), 0.0f);
975
+ assertEquals(0f, root.getLayoutY(), 0.0f);
976
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
977
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
978
+
979
+ assertEquals(75f, root_child0.getLayoutX(), 0.0f);
980
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
981
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
982
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
983
+
984
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
985
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
986
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
987
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
988
+
989
+ assertEquals(5f, root_child2.getLayoutX(), 0.0f);
990
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
991
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
992
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
993
+ }
994
+
995
+ @Test
996
+ public void test_column_gap_wrap_align_flex_start() {
997
+ YogaConfig config = YogaConfigFactory.create();
998
+
999
+ final YogaNode root = createNode(config);
1000
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1001
+ root.setFlexDirection(YogaFlexDirection.ROW);
1002
+ root.setWrap(YogaWrap.WRAP);
1003
+ root.setWidth(100f);
1004
+ root.setHeight(100f);
1005
+ root.setGap(YogaGutter.COLUMN, 10f);
1006
+ root.setGap(YogaGutter.ROW, 20f);
1007
+
1008
+ final YogaNode root_child0 = createNode(config);
1009
+ root_child0.setWidth(20f);
1010
+ root_child0.setHeight(20f);
1011
+ root.addChildAt(root_child0, 0);
1012
+
1013
+ final YogaNode root_child1 = createNode(config);
1014
+ root_child1.setWidth(20f);
1015
+ root_child1.setHeight(20f);
1016
+ root.addChildAt(root_child1, 1);
1017
+
1018
+ final YogaNode root_child2 = createNode(config);
1019
+ root_child2.setWidth(20f);
1020
+ root_child2.setHeight(20f);
1021
+ root.addChildAt(root_child2, 2);
1022
+
1023
+ final YogaNode root_child3 = createNode(config);
1024
+ root_child3.setWidth(20f);
1025
+ root_child3.setHeight(20f);
1026
+ root.addChildAt(root_child3, 3);
1027
+
1028
+ final YogaNode root_child4 = createNode(config);
1029
+ root_child4.setWidth(20f);
1030
+ root_child4.setHeight(20f);
1031
+ root.addChildAt(root_child4, 4);
1032
+
1033
+ final YogaNode root_child5 = createNode(config);
1034
+ root_child5.setWidth(20f);
1035
+ root_child5.setHeight(20f);
1036
+ root.addChildAt(root_child5, 5);
1037
+ root.setDirection(YogaDirection.LTR);
1038
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1039
+
1040
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1041
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1042
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1043
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1044
+
1045
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1046
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1047
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1048
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1049
+
1050
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
1051
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1052
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1053
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1054
+
1055
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
1056
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1057
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1058
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1059
+
1060
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1061
+ assertEquals(40f, root_child3.getLayoutY(), 0.0f);
1062
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1063
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1064
+
1065
+ assertEquals(30f, root_child4.getLayoutX(), 0.0f);
1066
+ assertEquals(40f, root_child4.getLayoutY(), 0.0f);
1067
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1068
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1069
+
1070
+ assertEquals(60f, root_child5.getLayoutX(), 0.0f);
1071
+ assertEquals(40f, root_child5.getLayoutY(), 0.0f);
1072
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1073
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
1074
+
1075
+ root.setDirection(YogaDirection.RTL);
1076
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1077
+
1078
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1079
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1080
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1081
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1082
+
1083
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1084
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1085
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1086
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1087
+
1088
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
1089
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1090
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1091
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1092
+
1093
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
1094
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1095
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1096
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1097
+
1098
+ assertEquals(80f, root_child3.getLayoutX(), 0.0f);
1099
+ assertEquals(40f, root_child3.getLayoutY(), 0.0f);
1100
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1101
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1102
+
1103
+ assertEquals(50f, root_child4.getLayoutX(), 0.0f);
1104
+ assertEquals(40f, root_child4.getLayoutY(), 0.0f);
1105
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1106
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1107
+
1108
+ assertEquals(20f, root_child5.getLayoutX(), 0.0f);
1109
+ assertEquals(40f, root_child5.getLayoutY(), 0.0f);
1110
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1111
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
1112
+ }
1113
+
1114
+ @Test
1115
+ public void test_column_gap_wrap_align_center() {
1116
+ YogaConfig config = YogaConfigFactory.create();
1117
+
1118
+ final YogaNode root = createNode(config);
1119
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1120
+ root.setFlexDirection(YogaFlexDirection.ROW);
1121
+ root.setWrap(YogaWrap.WRAP);
1122
+ root.setAlignContent(YogaAlign.CENTER);
1123
+ root.setWidth(100f);
1124
+ root.setHeight(100f);
1125
+ root.setGap(YogaGutter.COLUMN, 10f);
1126
+ root.setGap(YogaGutter.ROW, 20f);
1127
+
1128
+ final YogaNode root_child0 = createNode(config);
1129
+ root_child0.setWidth(20f);
1130
+ root_child0.setHeight(20f);
1131
+ root.addChildAt(root_child0, 0);
1132
+
1133
+ final YogaNode root_child1 = createNode(config);
1134
+ root_child1.setWidth(20f);
1135
+ root_child1.setHeight(20f);
1136
+ root.addChildAt(root_child1, 1);
1137
+
1138
+ final YogaNode root_child2 = createNode(config);
1139
+ root_child2.setWidth(20f);
1140
+ root_child2.setHeight(20f);
1141
+ root.addChildAt(root_child2, 2);
1142
+
1143
+ final YogaNode root_child3 = createNode(config);
1144
+ root_child3.setWidth(20f);
1145
+ root_child3.setHeight(20f);
1146
+ root.addChildAt(root_child3, 3);
1147
+
1148
+ final YogaNode root_child4 = createNode(config);
1149
+ root_child4.setWidth(20f);
1150
+ root_child4.setHeight(20f);
1151
+ root.addChildAt(root_child4, 4);
1152
+
1153
+ final YogaNode root_child5 = createNode(config);
1154
+ root_child5.setWidth(20f);
1155
+ root_child5.setHeight(20f);
1156
+ root.addChildAt(root_child5, 5);
1157
+ root.setDirection(YogaDirection.LTR);
1158
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1159
+
1160
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1161
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1162
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1163
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1164
+
1165
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1166
+ assertEquals(20f, root_child0.getLayoutY(), 0.0f);
1167
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1168
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1169
+
1170
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
1171
+ assertEquals(20f, root_child1.getLayoutY(), 0.0f);
1172
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1173
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1174
+
1175
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
1176
+ assertEquals(20f, root_child2.getLayoutY(), 0.0f);
1177
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1178
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1179
+
1180
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1181
+ assertEquals(60f, root_child3.getLayoutY(), 0.0f);
1182
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1183
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1184
+
1185
+ assertEquals(30f, root_child4.getLayoutX(), 0.0f);
1186
+ assertEquals(60f, root_child4.getLayoutY(), 0.0f);
1187
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1188
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1189
+
1190
+ assertEquals(60f, root_child5.getLayoutX(), 0.0f);
1191
+ assertEquals(60f, root_child5.getLayoutY(), 0.0f);
1192
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1193
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
1194
+
1195
+ root.setDirection(YogaDirection.RTL);
1196
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1197
+
1198
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1199
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1200
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1201
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1202
+
1203
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1204
+ assertEquals(20f, root_child0.getLayoutY(), 0.0f);
1205
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1206
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1207
+
1208
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
1209
+ assertEquals(20f, root_child1.getLayoutY(), 0.0f);
1210
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1211
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1212
+
1213
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
1214
+ assertEquals(20f, root_child2.getLayoutY(), 0.0f);
1215
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1216
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1217
+
1218
+ assertEquals(80f, root_child3.getLayoutX(), 0.0f);
1219
+ assertEquals(60f, root_child3.getLayoutY(), 0.0f);
1220
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1221
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1222
+
1223
+ assertEquals(50f, root_child4.getLayoutX(), 0.0f);
1224
+ assertEquals(60f, root_child4.getLayoutY(), 0.0f);
1225
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1226
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1227
+
1228
+ assertEquals(20f, root_child5.getLayoutX(), 0.0f);
1229
+ assertEquals(60f, root_child5.getLayoutY(), 0.0f);
1230
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1231
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
1232
+ }
1233
+
1234
+ @Test
1235
+ public void test_column_gap_wrap_align_flex_end() {
1236
+ YogaConfig config = YogaConfigFactory.create();
1237
+
1238
+ final YogaNode root = createNode(config);
1239
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1240
+ root.setFlexDirection(YogaFlexDirection.ROW);
1241
+ root.setWrap(YogaWrap.WRAP);
1242
+ root.setAlignContent(YogaAlign.FLEX_END);
1243
+ root.setWidth(100f);
1244
+ root.setHeight(100f);
1245
+ root.setGap(YogaGutter.COLUMN, 10f);
1246
+ root.setGap(YogaGutter.ROW, 20f);
1247
+
1248
+ final YogaNode root_child0 = createNode(config);
1249
+ root_child0.setWidth(20f);
1250
+ root_child0.setHeight(20f);
1251
+ root.addChildAt(root_child0, 0);
1252
+
1253
+ final YogaNode root_child1 = createNode(config);
1254
+ root_child1.setWidth(20f);
1255
+ root_child1.setHeight(20f);
1256
+ root.addChildAt(root_child1, 1);
1257
+
1258
+ final YogaNode root_child2 = createNode(config);
1259
+ root_child2.setWidth(20f);
1260
+ root_child2.setHeight(20f);
1261
+ root.addChildAt(root_child2, 2);
1262
+
1263
+ final YogaNode root_child3 = createNode(config);
1264
+ root_child3.setWidth(20f);
1265
+ root_child3.setHeight(20f);
1266
+ root.addChildAt(root_child3, 3);
1267
+
1268
+ final YogaNode root_child4 = createNode(config);
1269
+ root_child4.setWidth(20f);
1270
+ root_child4.setHeight(20f);
1271
+ root.addChildAt(root_child4, 4);
1272
+
1273
+ final YogaNode root_child5 = createNode(config);
1274
+ root_child5.setWidth(20f);
1275
+ root_child5.setHeight(20f);
1276
+ root.addChildAt(root_child5, 5);
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(40f, root_child0.getLayoutY(), 0.0f);
1287
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1288
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1289
+
1290
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
1291
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
1292
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1293
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1294
+
1295
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
1296
+ assertEquals(40f, root_child2.getLayoutY(), 0.0f);
1297
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1298
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1299
+
1300
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1301
+ assertEquals(80f, root_child3.getLayoutY(), 0.0f);
1302
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1303
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1304
+
1305
+ assertEquals(30f, root_child4.getLayoutX(), 0.0f);
1306
+ assertEquals(80f, root_child4.getLayoutY(), 0.0f);
1307
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1308
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1309
+
1310
+ assertEquals(60f, root_child5.getLayoutX(), 0.0f);
1311
+ assertEquals(80f, root_child5.getLayoutY(), 0.0f);
1312
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1313
+ assertEquals(20f, root_child5.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(80f, root_child0.getLayoutX(), 0.0f);
1324
+ assertEquals(40f, root_child0.getLayoutY(), 0.0f);
1325
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1326
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1327
+
1328
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
1329
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
1330
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1331
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1332
+
1333
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
1334
+ assertEquals(40f, root_child2.getLayoutY(), 0.0f);
1335
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1336
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1337
+
1338
+ assertEquals(80f, root_child3.getLayoutX(), 0.0f);
1339
+ assertEquals(80f, root_child3.getLayoutY(), 0.0f);
1340
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1341
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1342
+
1343
+ assertEquals(50f, root_child4.getLayoutX(), 0.0f);
1344
+ assertEquals(80f, root_child4.getLayoutY(), 0.0f);
1345
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1346
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1347
+
1348
+ assertEquals(20f, root_child5.getLayoutX(), 0.0f);
1349
+ assertEquals(80f, root_child5.getLayoutY(), 0.0f);
1350
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1351
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
1352
+ }
1353
+
1354
+ @Test
1355
+ public void test_column_gap_wrap_align_space_between() {
1356
+ YogaConfig config = YogaConfigFactory.create();
1357
+
1358
+ final YogaNode root = createNode(config);
1359
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1360
+ root.setFlexDirection(YogaFlexDirection.ROW);
1361
+ root.setWrap(YogaWrap.WRAP);
1362
+ root.setAlignContent(YogaAlign.SPACE_BETWEEN);
1363
+ root.setWidth(100f);
1364
+ root.setHeight(100f);
1365
+ root.setGap(YogaGutter.COLUMN, 10f);
1366
+ root.setGap(YogaGutter.ROW, 20f);
1367
+
1368
+ final YogaNode root_child0 = createNode(config);
1369
+ root_child0.setWidth(20f);
1370
+ root_child0.setHeight(20f);
1371
+ root.addChildAt(root_child0, 0);
1372
+
1373
+ final YogaNode root_child1 = createNode(config);
1374
+ root_child1.setWidth(20f);
1375
+ root_child1.setHeight(20f);
1376
+ root.addChildAt(root_child1, 1);
1377
+
1378
+ final YogaNode root_child2 = createNode(config);
1379
+ root_child2.setWidth(20f);
1380
+ root_child2.setHeight(20f);
1381
+ root.addChildAt(root_child2, 2);
1382
+
1383
+ final YogaNode root_child3 = createNode(config);
1384
+ root_child3.setWidth(20f);
1385
+ root_child3.setHeight(20f);
1386
+ root.addChildAt(root_child3, 3);
1387
+
1388
+ final YogaNode root_child4 = createNode(config);
1389
+ root_child4.setWidth(20f);
1390
+ root_child4.setHeight(20f);
1391
+ root.addChildAt(root_child4, 4);
1392
+
1393
+ final YogaNode root_child5 = createNode(config);
1394
+ root_child5.setWidth(20f);
1395
+ root_child5.setHeight(20f);
1396
+ root.addChildAt(root_child5, 5);
1397
+ root.setDirection(YogaDirection.LTR);
1398
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1399
+
1400
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1401
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1402
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1403
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1404
+
1405
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1406
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1407
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1408
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1409
+
1410
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
1411
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1412
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1413
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1414
+
1415
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
1416
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1417
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1418
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1419
+
1420
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1421
+ assertEquals(80f, root_child3.getLayoutY(), 0.0f);
1422
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1423
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1424
+
1425
+ assertEquals(30f, root_child4.getLayoutX(), 0.0f);
1426
+ assertEquals(80f, root_child4.getLayoutY(), 0.0f);
1427
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1428
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1429
+
1430
+ assertEquals(60f, root_child5.getLayoutX(), 0.0f);
1431
+ assertEquals(80f, root_child5.getLayoutY(), 0.0f);
1432
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1433
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
1434
+
1435
+ root.setDirection(YogaDirection.RTL);
1436
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1437
+
1438
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1439
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1440
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1441
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1442
+
1443
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1444
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1445
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1446
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1447
+
1448
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
1449
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1450
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1451
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1452
+
1453
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
1454
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1455
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1456
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1457
+
1458
+ assertEquals(80f, root_child3.getLayoutX(), 0.0f);
1459
+ assertEquals(80f, root_child3.getLayoutY(), 0.0f);
1460
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1461
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1462
+
1463
+ assertEquals(50f, root_child4.getLayoutX(), 0.0f);
1464
+ assertEquals(80f, root_child4.getLayoutY(), 0.0f);
1465
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1466
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1467
+
1468
+ assertEquals(20f, root_child5.getLayoutX(), 0.0f);
1469
+ assertEquals(80f, root_child5.getLayoutY(), 0.0f);
1470
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1471
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
1472
+ }
1473
+
1474
+ @Test
1475
+ public void test_column_gap_wrap_align_space_around() {
1476
+ YogaConfig config = YogaConfigFactory.create();
1477
+
1478
+ final YogaNode root = createNode(config);
1479
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1480
+ root.setFlexDirection(YogaFlexDirection.ROW);
1481
+ root.setWrap(YogaWrap.WRAP);
1482
+ root.setAlignContent(YogaAlign.SPACE_AROUND);
1483
+ root.setWidth(100f);
1484
+ root.setHeight(100f);
1485
+ root.setGap(YogaGutter.COLUMN, 10f);
1486
+ root.setGap(YogaGutter.ROW, 20f);
1487
+
1488
+ final YogaNode root_child0 = createNode(config);
1489
+ root_child0.setWidth(20f);
1490
+ root_child0.setHeight(20f);
1491
+ root.addChildAt(root_child0, 0);
1492
+
1493
+ final YogaNode root_child1 = createNode(config);
1494
+ root_child1.setWidth(20f);
1495
+ root_child1.setHeight(20f);
1496
+ root.addChildAt(root_child1, 1);
1497
+
1498
+ final YogaNode root_child2 = createNode(config);
1499
+ root_child2.setWidth(20f);
1500
+ root_child2.setHeight(20f);
1501
+ root.addChildAt(root_child2, 2);
1502
+
1503
+ final YogaNode root_child3 = createNode(config);
1504
+ root_child3.setWidth(20f);
1505
+ root_child3.setHeight(20f);
1506
+ root.addChildAt(root_child3, 3);
1507
+
1508
+ final YogaNode root_child4 = createNode(config);
1509
+ root_child4.setWidth(20f);
1510
+ root_child4.setHeight(20f);
1511
+ root.addChildAt(root_child4, 4);
1512
+
1513
+ final YogaNode root_child5 = createNode(config);
1514
+ root_child5.setWidth(20f);
1515
+ root_child5.setHeight(20f);
1516
+ root.addChildAt(root_child5, 5);
1517
+ root.setDirection(YogaDirection.LTR);
1518
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1519
+
1520
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1521
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1522
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1523
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1524
+
1525
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1526
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
1527
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1528
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1529
+
1530
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
1531
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
1532
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1533
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1534
+
1535
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
1536
+ assertEquals(10f, root_child2.getLayoutY(), 0.0f);
1537
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1538
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1539
+
1540
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1541
+ assertEquals(70f, root_child3.getLayoutY(), 0.0f);
1542
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1543
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1544
+
1545
+ assertEquals(30f, root_child4.getLayoutX(), 0.0f);
1546
+ assertEquals(70f, root_child4.getLayoutY(), 0.0f);
1547
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1548
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1549
+
1550
+ assertEquals(60f, root_child5.getLayoutX(), 0.0f);
1551
+ assertEquals(70f, root_child5.getLayoutY(), 0.0f);
1552
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1553
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
1554
+
1555
+ root.setDirection(YogaDirection.RTL);
1556
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1557
+
1558
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1559
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1560
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1561
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1562
+
1563
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1564
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
1565
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1566
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1567
+
1568
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
1569
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
1570
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1571
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
1572
+
1573
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
1574
+ assertEquals(10f, root_child2.getLayoutY(), 0.0f);
1575
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1576
+ assertEquals(20f, root_child2.getLayoutHeight(), 0.0f);
1577
+
1578
+ assertEquals(80f, root_child3.getLayoutX(), 0.0f);
1579
+ assertEquals(70f, root_child3.getLayoutY(), 0.0f);
1580
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1581
+ assertEquals(20f, root_child3.getLayoutHeight(), 0.0f);
1582
+
1583
+ assertEquals(50f, root_child4.getLayoutX(), 0.0f);
1584
+ assertEquals(70f, root_child4.getLayoutY(), 0.0f);
1585
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1586
+ assertEquals(20f, root_child4.getLayoutHeight(), 0.0f);
1587
+
1588
+ assertEquals(20f, root_child5.getLayoutX(), 0.0f);
1589
+ assertEquals(70f, root_child5.getLayoutY(), 0.0f);
1590
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1591
+ assertEquals(20f, root_child5.getLayoutHeight(), 0.0f);
1592
+ }
1593
+
1594
+ @Test
1595
+ public void test_column_gap_wrap_align_stretch() {
1596
+ YogaConfig config = YogaConfigFactory.create();
1597
+
1598
+ final YogaNode root = createNode(config);
1599
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1600
+ root.setFlexDirection(YogaFlexDirection.ROW);
1601
+ root.setWrap(YogaWrap.WRAP);
1602
+ root.setWidth(300f);
1603
+ root.setHeight(300f);
1604
+ root.setGap(YogaGutter.COLUMN, 5f);
1605
+ root.setAlignContent(YogaAlign.STRETCH);
1606
+
1607
+ final YogaNode root_child0 = createNode(config);
1608
+ root_child0.setMinWidth(60f);
1609
+ root_child0.setFlexGrow(1f);
1610
+ root.addChildAt(root_child0, 0);
1611
+
1612
+ final YogaNode root_child1 = createNode(config);
1613
+ root_child1.setMinWidth(60f);
1614
+ root_child1.setFlexGrow(1f);
1615
+ root.addChildAt(root_child1, 1);
1616
+
1617
+ final YogaNode root_child2 = createNode(config);
1618
+ root_child2.setMinWidth(60f);
1619
+ root_child2.setFlexGrow(1f);
1620
+ root.addChildAt(root_child2, 2);
1621
+
1622
+ final YogaNode root_child3 = createNode(config);
1623
+ root_child3.setMinWidth(60f);
1624
+ root_child3.setFlexGrow(1f);
1625
+ root.addChildAt(root_child3, 3);
1626
+
1627
+ final YogaNode root_child4 = createNode(config);
1628
+ root_child4.setMinWidth(60f);
1629
+ root_child4.setFlexGrow(1f);
1630
+ root.addChildAt(root_child4, 4);
1631
+ root.setDirection(YogaDirection.LTR);
1632
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1633
+
1634
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1635
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1636
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
1637
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
1638
+
1639
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1640
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1641
+ assertEquals(71f, root_child0.getLayoutWidth(), 0.0f);
1642
+ assertEquals(150f, root_child0.getLayoutHeight(), 0.0f);
1643
+
1644
+ assertEquals(76f, root_child1.getLayoutX(), 0.0f);
1645
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1646
+ assertEquals(72f, root_child1.getLayoutWidth(), 0.0f);
1647
+ assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
1648
+
1649
+ assertEquals(153f, root_child2.getLayoutX(), 0.0f);
1650
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1651
+ assertEquals(71f, root_child2.getLayoutWidth(), 0.0f);
1652
+ assertEquals(150f, root_child2.getLayoutHeight(), 0.0f);
1653
+
1654
+ assertEquals(229f, root_child3.getLayoutX(), 0.0f);
1655
+ assertEquals(0f, root_child3.getLayoutY(), 0.0f);
1656
+ assertEquals(71f, root_child3.getLayoutWidth(), 0.0f);
1657
+ assertEquals(150f, root_child3.getLayoutHeight(), 0.0f);
1658
+
1659
+ assertEquals(0f, root_child4.getLayoutX(), 0.0f);
1660
+ assertEquals(150f, root_child4.getLayoutY(), 0.0f);
1661
+ assertEquals(300f, root_child4.getLayoutWidth(), 0.0f);
1662
+ assertEquals(150f, root_child4.getLayoutHeight(), 0.0f);
1663
+
1664
+ root.setDirection(YogaDirection.RTL);
1665
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1666
+
1667
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1668
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1669
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
1670
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
1671
+
1672
+ assertEquals(229f, root_child0.getLayoutX(), 0.0f);
1673
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1674
+ assertEquals(71f, root_child0.getLayoutWidth(), 0.0f);
1675
+ assertEquals(150f, root_child0.getLayoutHeight(), 0.0f);
1676
+
1677
+ assertEquals(153f, root_child1.getLayoutX(), 0.0f);
1678
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1679
+ assertEquals(71f, root_child1.getLayoutWidth(), 0.0f);
1680
+ assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
1681
+
1682
+ assertEquals(76f, root_child2.getLayoutX(), 0.0f);
1683
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1684
+ assertEquals(72f, root_child2.getLayoutWidth(), 0.0f);
1685
+ assertEquals(150f, root_child2.getLayoutHeight(), 0.0f);
1686
+
1687
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1688
+ assertEquals(0f, root_child3.getLayoutY(), 0.0f);
1689
+ assertEquals(71f, root_child3.getLayoutWidth(), 0.0f);
1690
+ assertEquals(150f, root_child3.getLayoutHeight(), 0.0f);
1691
+
1692
+ assertEquals(0f, root_child4.getLayoutX(), 0.0f);
1693
+ assertEquals(150f, root_child4.getLayoutY(), 0.0f);
1694
+ assertEquals(300f, root_child4.getLayoutWidth(), 0.0f);
1695
+ assertEquals(150f, root_child4.getLayoutHeight(), 0.0f);
1696
+ }
1697
+
1698
+ @Test
1699
+ public void test_column_gap_determines_parent_width() {
1700
+ YogaConfig config = YogaConfigFactory.create();
1701
+
1702
+ final YogaNode root = createNode(config);
1703
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1704
+ root.setFlexDirection(YogaFlexDirection.ROW);
1705
+ root.setHeight(100f);
1706
+ root.setGap(YogaGutter.COLUMN, 10f);
1707
+
1708
+ final YogaNode root_child0 = createNode(config);
1709
+ root_child0.setWidth(10f);
1710
+ root.addChildAt(root_child0, 0);
1711
+
1712
+ final YogaNode root_child1 = createNode(config);
1713
+ root_child1.setWidth(20f);
1714
+ root.addChildAt(root_child1, 1);
1715
+
1716
+ final YogaNode root_child2 = createNode(config);
1717
+ root_child2.setWidth(30f);
1718
+ root.addChildAt(root_child2, 2);
1719
+ root.setDirection(YogaDirection.LTR);
1720
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1721
+
1722
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1723
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1724
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
1725
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1726
+
1727
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1728
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1729
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
1730
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
1731
+
1732
+ assertEquals(20f, root_child1.getLayoutX(), 0.0f);
1733
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1734
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1735
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
1736
+
1737
+ assertEquals(50f, root_child2.getLayoutX(), 0.0f);
1738
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1739
+ assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
1740
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
1741
+
1742
+ root.setDirection(YogaDirection.RTL);
1743
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1744
+
1745
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1746
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1747
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
1748
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1749
+
1750
+ assertEquals(70f, root_child0.getLayoutX(), 0.0f);
1751
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1752
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
1753
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
1754
+
1755
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
1756
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1757
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1758
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
1759
+
1760
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
1761
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1762
+ assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
1763
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
1764
+ }
1765
+
1766
+ @Test
1767
+ public void test_row_gap_align_items_stretch() {
1768
+ YogaConfig config = YogaConfigFactory.create();
1769
+
1770
+ final YogaNode root = createNode(config);
1771
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1772
+ root.setFlexDirection(YogaFlexDirection.ROW);
1773
+ root.setWrap(YogaWrap.WRAP);
1774
+ root.setWidth(100f);
1775
+ root.setHeight(200f);
1776
+ root.setGap(YogaGutter.COLUMN, 10f);
1777
+ root.setGap(YogaGutter.ROW, 20f);
1778
+ root.setAlignContent(YogaAlign.STRETCH);
1779
+
1780
+ final YogaNode root_child0 = createNode(config);
1781
+ root_child0.setWidth(20f);
1782
+ root.addChildAt(root_child0, 0);
1783
+
1784
+ final YogaNode root_child1 = createNode(config);
1785
+ root_child1.setWidth(20f);
1786
+ root.addChildAt(root_child1, 1);
1787
+
1788
+ final YogaNode root_child2 = createNode(config);
1789
+ root_child2.setWidth(20f);
1790
+ root.addChildAt(root_child2, 2);
1791
+
1792
+ final YogaNode root_child3 = createNode(config);
1793
+ root_child3.setWidth(20f);
1794
+ root.addChildAt(root_child3, 3);
1795
+
1796
+ final YogaNode root_child4 = createNode(config);
1797
+ root_child4.setWidth(20f);
1798
+ root.addChildAt(root_child4, 4);
1799
+
1800
+ final YogaNode root_child5 = createNode(config);
1801
+ root_child5.setWidth(20f);
1802
+ root.addChildAt(root_child5, 5);
1803
+ root.setDirection(YogaDirection.LTR);
1804
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1805
+
1806
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1807
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1808
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1809
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1810
+
1811
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1812
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1813
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1814
+ assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
1815
+
1816
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
1817
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1818
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1819
+ assertEquals(90f, root_child1.getLayoutHeight(), 0.0f);
1820
+
1821
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
1822
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1823
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1824
+ assertEquals(90f, root_child2.getLayoutHeight(), 0.0f);
1825
+
1826
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1827
+ assertEquals(110f, root_child3.getLayoutY(), 0.0f);
1828
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1829
+ assertEquals(90f, root_child3.getLayoutHeight(), 0.0f);
1830
+
1831
+ assertEquals(30f, root_child4.getLayoutX(), 0.0f);
1832
+ assertEquals(110f, root_child4.getLayoutY(), 0.0f);
1833
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1834
+ assertEquals(90f, root_child4.getLayoutHeight(), 0.0f);
1835
+
1836
+ assertEquals(60f, root_child5.getLayoutX(), 0.0f);
1837
+ assertEquals(110f, root_child5.getLayoutY(), 0.0f);
1838
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1839
+ assertEquals(90f, root_child5.getLayoutHeight(), 0.0f);
1840
+
1841
+ root.setDirection(YogaDirection.RTL);
1842
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1843
+
1844
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1845
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1846
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1847
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1848
+
1849
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1850
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1851
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1852
+ assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
1853
+
1854
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
1855
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1856
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1857
+ assertEquals(90f, root_child1.getLayoutHeight(), 0.0f);
1858
+
1859
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
1860
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1861
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1862
+ assertEquals(90f, root_child2.getLayoutHeight(), 0.0f);
1863
+
1864
+ assertEquals(80f, root_child3.getLayoutX(), 0.0f);
1865
+ assertEquals(110f, root_child3.getLayoutY(), 0.0f);
1866
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1867
+ assertEquals(90f, root_child3.getLayoutHeight(), 0.0f);
1868
+
1869
+ assertEquals(50f, root_child4.getLayoutX(), 0.0f);
1870
+ assertEquals(110f, root_child4.getLayoutY(), 0.0f);
1871
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1872
+ assertEquals(90f, root_child4.getLayoutHeight(), 0.0f);
1873
+
1874
+ assertEquals(20f, root_child5.getLayoutX(), 0.0f);
1875
+ assertEquals(110f, root_child5.getLayoutY(), 0.0f);
1876
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1877
+ assertEquals(90f, root_child5.getLayoutHeight(), 0.0f);
1878
+ }
1879
+
1880
+ @Test
1881
+ public void test_row_gap_align_items_end() {
1882
+ YogaConfig config = YogaConfigFactory.create();
1883
+
1884
+ final YogaNode root = createNode(config);
1885
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1886
+ root.setFlexDirection(YogaFlexDirection.ROW);
1887
+ root.setWrap(YogaWrap.WRAP);
1888
+ root.setWidth(100f);
1889
+ root.setHeight(200f);
1890
+ root.setGap(YogaGutter.COLUMN, 10f);
1891
+ root.setGap(YogaGutter.ROW, 20f);
1892
+ root.setAlignItems(YogaAlign.FLEX_END);
1893
+
1894
+ final YogaNode root_child0 = createNode(config);
1895
+ root_child0.setWidth(20f);
1896
+ root.addChildAt(root_child0, 0);
1897
+
1898
+ final YogaNode root_child1 = createNode(config);
1899
+ root_child1.setWidth(20f);
1900
+ root.addChildAt(root_child1, 1);
1901
+
1902
+ final YogaNode root_child2 = createNode(config);
1903
+ root_child2.setWidth(20f);
1904
+ root.addChildAt(root_child2, 2);
1905
+
1906
+ final YogaNode root_child3 = createNode(config);
1907
+ root_child3.setWidth(20f);
1908
+ root.addChildAt(root_child3, 3);
1909
+
1910
+ final YogaNode root_child4 = createNode(config);
1911
+ root_child4.setWidth(20f);
1912
+ root.addChildAt(root_child4, 4);
1913
+
1914
+ final YogaNode root_child5 = createNode(config);
1915
+ root_child5.setWidth(20f);
1916
+ root.addChildAt(root_child5, 5);
1917
+ root.setDirection(YogaDirection.LTR);
1918
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1919
+
1920
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1921
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1922
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1923
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1924
+
1925
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1926
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1927
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1928
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1929
+
1930
+ assertEquals(30f, root_child1.getLayoutX(), 0.0f);
1931
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1932
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1933
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
1934
+
1935
+ assertEquals(60f, root_child2.getLayoutX(), 0.0f);
1936
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1937
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1938
+ assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
1939
+
1940
+ assertEquals(0f, root_child3.getLayoutX(), 0.0f);
1941
+ assertEquals(20f, root_child3.getLayoutY(), 0.0f);
1942
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1943
+ assertEquals(0f, root_child3.getLayoutHeight(), 0.0f);
1944
+
1945
+ assertEquals(30f, root_child4.getLayoutX(), 0.0f);
1946
+ assertEquals(20f, root_child4.getLayoutY(), 0.0f);
1947
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1948
+ assertEquals(0f, root_child4.getLayoutHeight(), 0.0f);
1949
+
1950
+ assertEquals(60f, root_child5.getLayoutX(), 0.0f);
1951
+ assertEquals(20f, root_child5.getLayoutY(), 0.0f);
1952
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1953
+ assertEquals(0f, root_child5.getLayoutHeight(), 0.0f);
1954
+
1955
+ root.setDirection(YogaDirection.RTL);
1956
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1957
+
1958
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1959
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1960
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1961
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1962
+
1963
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1964
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1965
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1966
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1967
+
1968
+ assertEquals(50f, root_child1.getLayoutX(), 0.0f);
1969
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1970
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
1971
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
1972
+
1973
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
1974
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1975
+ assertEquals(20f, root_child2.getLayoutWidth(), 0.0f);
1976
+ assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
1977
+
1978
+ assertEquals(80f, root_child3.getLayoutX(), 0.0f);
1979
+ assertEquals(20f, root_child3.getLayoutY(), 0.0f);
1980
+ assertEquals(20f, root_child3.getLayoutWidth(), 0.0f);
1981
+ assertEquals(0f, root_child3.getLayoutHeight(), 0.0f);
1982
+
1983
+ assertEquals(50f, root_child4.getLayoutX(), 0.0f);
1984
+ assertEquals(20f, root_child4.getLayoutY(), 0.0f);
1985
+ assertEquals(20f, root_child4.getLayoutWidth(), 0.0f);
1986
+ assertEquals(0f, root_child4.getLayoutHeight(), 0.0f);
1987
+
1988
+ assertEquals(20f, root_child5.getLayoutX(), 0.0f);
1989
+ assertEquals(20f, root_child5.getLayoutY(), 0.0f);
1990
+ assertEquals(20f, root_child5.getLayoutWidth(), 0.0f);
1991
+ assertEquals(0f, root_child5.getLayoutHeight(), 0.0f);
1992
+ }
1993
+
1994
+ @Test
1995
+ public void test_row_gap_column_child_margins() {
1996
+ YogaConfig config = YogaConfigFactory.create();
1997
+
1998
+ final YogaNode root = createNode(config);
1999
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2000
+ root.setWidth(100f);
2001
+ root.setHeight(200f);
2002
+ root.setGap(YogaGutter.ROW, 10f);
2003
+
2004
+ final YogaNode root_child0 = createNode(config);
2005
+ root_child0.setFlexGrow(1f);
2006
+ root_child0.setFlexShrink(1f);
2007
+ root_child0.setFlexBasisPercent(0f);
2008
+ root_child0.setMargin(YogaEdge.VERTICAL, 2f);
2009
+ root.addChildAt(root_child0, 0);
2010
+
2011
+ final YogaNode root_child1 = createNode(config);
2012
+ root_child1.setFlexGrow(1f);
2013
+ root_child1.setFlexShrink(1f);
2014
+ root_child1.setFlexBasisPercent(0f);
2015
+ root_child1.setMargin(YogaEdge.VERTICAL, 10f);
2016
+ root.addChildAt(root_child1, 1);
2017
+
2018
+ final YogaNode root_child2 = createNode(config);
2019
+ root_child2.setFlexGrow(1f);
2020
+ root_child2.setFlexShrink(1f);
2021
+ root_child2.setFlexBasisPercent(0f);
2022
+ root_child2.setMargin(YogaEdge.VERTICAL, 15f);
2023
+ root.addChildAt(root_child2, 2);
2024
+ root.setDirection(YogaDirection.LTR);
2025
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2026
+
2027
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2028
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2029
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
2030
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
2031
+
2032
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2033
+ assertEquals(2f, root_child0.getLayoutY(), 0.0f);
2034
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2035
+ assertEquals(42f, root_child0.getLayoutHeight(), 0.0f);
2036
+
2037
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
2038
+ assertEquals(66f, root_child1.getLayoutY(), 0.0f);
2039
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2040
+ assertEquals(42f, root_child1.getLayoutHeight(), 0.0f);
2041
+
2042
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
2043
+ assertEquals(143f, root_child2.getLayoutY(), 0.0f);
2044
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2045
+ assertEquals(42f, root_child2.getLayoutHeight(), 0.0f);
2046
+
2047
+ root.setDirection(YogaDirection.RTL);
2048
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2049
+
2050
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2051
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2052
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
2053
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
2054
+
2055
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2056
+ assertEquals(2f, root_child0.getLayoutY(), 0.0f);
2057
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2058
+ assertEquals(42f, root_child0.getLayoutHeight(), 0.0f);
2059
+
2060
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
2061
+ assertEquals(66f, root_child1.getLayoutY(), 0.0f);
2062
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2063
+ assertEquals(42f, root_child1.getLayoutHeight(), 0.0f);
2064
+
2065
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
2066
+ assertEquals(143f, root_child2.getLayoutY(), 0.0f);
2067
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2068
+ assertEquals(42f, root_child2.getLayoutHeight(), 0.0f);
2069
+ }
2070
+
2071
+ @Test
2072
+ public void test_row_gap_row_wrap_child_margins() {
2073
+ YogaConfig config = YogaConfigFactory.create();
2074
+
2075
+ final YogaNode root = createNode(config);
2076
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2077
+ root.setFlexDirection(YogaFlexDirection.ROW);
2078
+ root.setWrap(YogaWrap.WRAP);
2079
+ root.setWidth(100f);
2080
+ root.setHeight(200f);
2081
+ root.setGap(YogaGutter.ROW, 10f);
2082
+
2083
+ final YogaNode root_child0 = createNode(config);
2084
+ root_child0.setWidth(60f);
2085
+ root_child0.setMargin(YogaEdge.VERTICAL, 2f);
2086
+ root.addChildAt(root_child0, 0);
2087
+
2088
+ final YogaNode root_child1 = createNode(config);
2089
+ root_child1.setWidth(60f);
2090
+ root_child1.setMargin(YogaEdge.VERTICAL, 10f);
2091
+ root.addChildAt(root_child1, 1);
2092
+
2093
+ final YogaNode root_child2 = createNode(config);
2094
+ root_child2.setWidth(60f);
2095
+ root_child2.setMargin(YogaEdge.VERTICAL, 15f);
2096
+ root.addChildAt(root_child2, 2);
2097
+ root.setDirection(YogaDirection.LTR);
2098
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2099
+
2100
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2101
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2102
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
2103
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
2104
+
2105
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2106
+ assertEquals(2f, root_child0.getLayoutY(), 0.0f);
2107
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
2108
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
2109
+
2110
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
2111
+ assertEquals(24f, root_child1.getLayoutY(), 0.0f);
2112
+ assertEquals(60f, root_child1.getLayoutWidth(), 0.0f);
2113
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
2114
+
2115
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
2116
+ assertEquals(59f, root_child2.getLayoutY(), 0.0f);
2117
+ assertEquals(60f, root_child2.getLayoutWidth(), 0.0f);
2118
+ assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
2119
+
2120
+ root.setDirection(YogaDirection.RTL);
2121
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2122
+
2123
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2124
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2125
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
2126
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
2127
+
2128
+ assertEquals(40f, root_child0.getLayoutX(), 0.0f);
2129
+ assertEquals(2f, root_child0.getLayoutY(), 0.0f);
2130
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
2131
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
2132
+
2133
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
2134
+ assertEquals(24f, root_child1.getLayoutY(), 0.0f);
2135
+ assertEquals(60f, root_child1.getLayoutWidth(), 0.0f);
2136
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
2137
+
2138
+ assertEquals(40f, root_child2.getLayoutX(), 0.0f);
2139
+ assertEquals(59f, root_child2.getLayoutY(), 0.0f);
2140
+ assertEquals(60f, root_child2.getLayoutWidth(), 0.0f);
2141
+ assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
2142
+ }
2143
+
2144
+ @Test
2145
+ public void test_row_gap_determines_parent_height() {
2146
+ YogaConfig config = YogaConfigFactory.create();
2147
+
2148
+ final YogaNode root = createNode(config);
2149
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2150
+ root.setWidth(100f);
2151
+ root.setGap(YogaGutter.ROW, 10f);
2152
+
2153
+ final YogaNode root_child0 = createNode(config);
2154
+ root_child0.setHeight(10f);
2155
+ root.addChildAt(root_child0, 0);
2156
+
2157
+ final YogaNode root_child1 = createNode(config);
2158
+ root_child1.setHeight(20f);
2159
+ root.addChildAt(root_child1, 1);
2160
+
2161
+ final YogaNode root_child2 = createNode(config);
2162
+ root_child2.setHeight(30f);
2163
+ root.addChildAt(root_child2, 2);
2164
+ root.setDirection(YogaDirection.LTR);
2165
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2166
+
2167
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2168
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2169
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
2170
+ assertEquals(80f, root.getLayoutHeight(), 0.0f);
2171
+
2172
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2173
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2174
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2175
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
2176
+
2177
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
2178
+ assertEquals(20f, root_child1.getLayoutY(), 0.0f);
2179
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2180
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
2181
+
2182
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
2183
+ assertEquals(50f, root_child2.getLayoutY(), 0.0f);
2184
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2185
+ assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
2186
+
2187
+ root.setDirection(YogaDirection.RTL);
2188
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2189
+
2190
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2191
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2192
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
2193
+ assertEquals(80f, root.getLayoutHeight(), 0.0f);
2194
+
2195
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2196
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2197
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2198
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
2199
+
2200
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
2201
+ assertEquals(20f, root_child1.getLayoutY(), 0.0f);
2202
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2203
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
2204
+
2205
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
2206
+ assertEquals(50f, root_child2.getLayoutY(), 0.0f);
2207
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2208
+ assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
2209
+ }
2210
+
2211
+ @Test
2212
+ public void test_row_gap_percent_wrapping() {
2213
+ YogaConfig config = YogaConfigFactory.create();
2214
+
2215
+ final YogaNode root = createNode(config);
2216
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2217
+ root.setFlexDirection(YogaFlexDirection.ROW);
2218
+ root.setWidth(300f);
2219
+ root.setHeight(700f);
2220
+ root.setPadding(YogaEdge.ALL, 10);
2221
+ root.setGapPercent(YogaGutter.ALL, 10f);
2222
+ root.setWrap(YogaWrap.WRAP);
2223
+
2224
+ final YogaNode root_child0 = createNode(config);
2225
+ root_child0.setWidth(100f);
2226
+ root_child0.setHeight(100f);
2227
+ root.addChildAt(root_child0, 0);
2228
+
2229
+ final YogaNode root_child1 = createNode(config);
2230
+ root_child1.setWidth(100f);
2231
+ root_child1.setHeight(100f);
2232
+ root.addChildAt(root_child1, 1);
2233
+
2234
+ final YogaNode root_child2 = createNode(config);
2235
+ root_child2.setWidth(100f);
2236
+ root_child2.setHeight(100f);
2237
+ root.addChildAt(root_child2, 2);
2238
+
2239
+ final YogaNode root_child3 = createNode(config);
2240
+ root_child3.setWidth(100f);
2241
+ root_child3.setHeight(100f);
2242
+ root.addChildAt(root_child3, 3);
2243
+
2244
+ final YogaNode root_child4 = createNode(config);
2245
+ root_child4.setWidth(100f);
2246
+ root_child4.setHeight(100f);
2247
+ root.addChildAt(root_child4, 4);
2248
+ root.setDirection(YogaDirection.LTR);
2249
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2250
+
2251
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2252
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2253
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2254
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2255
+
2256
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
2257
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
2258
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2259
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2260
+
2261
+ assertEquals(138f, root_child1.getLayoutX(), 0.0f);
2262
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
2263
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2264
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2265
+
2266
+ assertEquals(10f, root_child2.getLayoutX(), 0.0f);
2267
+ assertEquals(178f, root_child2.getLayoutY(), 0.0f);
2268
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2269
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2270
+
2271
+ assertEquals(138f, root_child3.getLayoutX(), 0.0f);
2272
+ assertEquals(178f, root_child3.getLayoutY(), 0.0f);
2273
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2274
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2275
+
2276
+ assertEquals(10f, root_child4.getLayoutX(), 0.0f);
2277
+ assertEquals(346f, root_child4.getLayoutY(), 0.0f);
2278
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2279
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2280
+
2281
+ root.setDirection(YogaDirection.RTL);
2282
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2283
+
2284
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2285
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2286
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2287
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2288
+
2289
+ assertEquals(190f, root_child0.getLayoutX(), 0.0f);
2290
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
2291
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2292
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2293
+
2294
+ assertEquals(62f, root_child1.getLayoutX(), 0.0f);
2295
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
2296
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2297
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2298
+
2299
+ assertEquals(190f, root_child2.getLayoutX(), 0.0f);
2300
+ assertEquals(178f, root_child2.getLayoutY(), 0.0f);
2301
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2302
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2303
+
2304
+ assertEquals(62f, root_child3.getLayoutX(), 0.0f);
2305
+ assertEquals(178f, root_child3.getLayoutY(), 0.0f);
2306
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2307
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2308
+
2309
+ assertEquals(190f, root_child4.getLayoutX(), 0.0f);
2310
+ assertEquals(346f, root_child4.getLayoutY(), 0.0f);
2311
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2312
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2313
+ }
2314
+
2315
+ @Test
2316
+ public void test_row_gap_percent_determines_parent_height() {
2317
+ YogaConfig config = YogaConfigFactory.create();
2318
+
2319
+ final YogaNode root = createNode(config);
2320
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2321
+ root.setFlexDirection(YogaFlexDirection.ROW);
2322
+ root.setWidth(300f);
2323
+ root.setGapPercent(YogaGutter.ALL, 10f);
2324
+ root.setWrap(YogaWrap.WRAP);
2325
+
2326
+ final YogaNode root_child0 = createNode(config);
2327
+ root_child0.setWidth(100f);
2328
+ root_child0.setHeight(100f);
2329
+ root.addChildAt(root_child0, 0);
2330
+
2331
+ final YogaNode root_child1 = createNode(config);
2332
+ root_child1.setWidth(100f);
2333
+ root_child1.setHeight(100f);
2334
+ root.addChildAt(root_child1, 1);
2335
+
2336
+ final YogaNode root_child2 = createNode(config);
2337
+ root_child2.setWidth(100f);
2338
+ root_child2.setHeight(100f);
2339
+ root.addChildAt(root_child2, 2);
2340
+
2341
+ final YogaNode root_child3 = createNode(config);
2342
+ root_child3.setWidth(100f);
2343
+ root_child3.setHeight(100f);
2344
+ root.addChildAt(root_child3, 3);
2345
+
2346
+ final YogaNode root_child4 = createNode(config);
2347
+ root_child4.setWidth(100f);
2348
+ root_child4.setHeight(100f);
2349
+ root.addChildAt(root_child4, 4);
2350
+ root.setDirection(YogaDirection.LTR);
2351
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2352
+
2353
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2354
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2355
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2356
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
2357
+
2358
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2359
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2360
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2361
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2362
+
2363
+ assertEquals(130f, root_child1.getLayoutX(), 0.0f);
2364
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2365
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2366
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2367
+
2368
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
2369
+ assertEquals(100f, root_child2.getLayoutY(), 0.0f);
2370
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2371
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2372
+
2373
+ assertEquals(130f, root_child3.getLayoutX(), 0.0f);
2374
+ assertEquals(100f, root_child3.getLayoutY(), 0.0f);
2375
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2376
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2377
+
2378
+ assertEquals(0f, root_child4.getLayoutX(), 0.0f);
2379
+ assertEquals(200f, root_child4.getLayoutY(), 0.0f);
2380
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2381
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2382
+
2383
+ root.setDirection(YogaDirection.RTL);
2384
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2385
+
2386
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2387
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2388
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2389
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
2390
+
2391
+ assertEquals(200f, root_child0.getLayoutX(), 0.0f);
2392
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2393
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2394
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2395
+
2396
+ assertEquals(70f, root_child1.getLayoutX(), 0.0f);
2397
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2398
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2399
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2400
+
2401
+ assertEquals(200f, root_child2.getLayoutX(), 0.0f);
2402
+ assertEquals(100f, root_child2.getLayoutY(), 0.0f);
2403
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2404
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2405
+
2406
+ assertEquals(70f, root_child3.getLayoutX(), 0.0f);
2407
+ assertEquals(100f, root_child3.getLayoutY(), 0.0f);
2408
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2409
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2410
+
2411
+ assertEquals(200f, root_child4.getLayoutX(), 0.0f);
2412
+ assertEquals(200f, root_child4.getLayoutY(), 0.0f);
2413
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2414
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2415
+ }
2416
+
2417
+ @Test
2418
+ public void test_row_gap_percent_wrapping_with_both_content_padding_and_item_padding() {
2419
+ YogaConfig config = YogaConfigFactory.create();
2420
+
2421
+ final YogaNode root = createNode(config);
2422
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2423
+ root.setFlexDirection(YogaFlexDirection.ROW);
2424
+ root.setWidth(300f);
2425
+ root.setHeight(700f);
2426
+ root.setPadding(YogaEdge.ALL, 10);
2427
+ root.setGapPercent(YogaGutter.ALL, 10f);
2428
+ root.setWrap(YogaWrap.WRAP);
2429
+
2430
+ final YogaNode root_child0 = createNode(config);
2431
+ root_child0.setWidth(100f);
2432
+ root_child0.setHeight(100f);
2433
+ root_child0.setPadding(YogaEdge.ALL, 10);
2434
+ root.addChildAt(root_child0, 0);
2435
+
2436
+ final YogaNode root_child1 = createNode(config);
2437
+ root_child1.setWidth(100f);
2438
+ root_child1.setHeight(100f);
2439
+ root_child1.setPadding(YogaEdge.ALL, 10);
2440
+ root.addChildAt(root_child1, 1);
2441
+
2442
+ final YogaNode root_child2 = createNode(config);
2443
+ root_child2.setWidth(100f);
2444
+ root_child2.setHeight(100f);
2445
+ root_child2.setPadding(YogaEdge.ALL, 10);
2446
+ root.addChildAt(root_child2, 2);
2447
+
2448
+ final YogaNode root_child3 = createNode(config);
2449
+ root_child3.setWidth(100f);
2450
+ root_child3.setHeight(100f);
2451
+ root_child3.setPadding(YogaEdge.ALL, 10);
2452
+ root.addChildAt(root_child3, 3);
2453
+
2454
+ final YogaNode root_child4 = createNode(config);
2455
+ root_child4.setWidth(100f);
2456
+ root_child4.setHeight(100f);
2457
+ root_child4.setPadding(YogaEdge.ALL, 10);
2458
+ root.addChildAt(root_child4, 4);
2459
+ root.setDirection(YogaDirection.LTR);
2460
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2461
+
2462
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2463
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2464
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2465
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2466
+
2467
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
2468
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
2469
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2470
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2471
+
2472
+ assertEquals(138f, root_child1.getLayoutX(), 0.0f);
2473
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
2474
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2475
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2476
+
2477
+ assertEquals(10f, root_child2.getLayoutX(), 0.0f);
2478
+ assertEquals(178f, root_child2.getLayoutY(), 0.0f);
2479
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2480
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2481
+
2482
+ assertEquals(138f, root_child3.getLayoutX(), 0.0f);
2483
+ assertEquals(178f, root_child3.getLayoutY(), 0.0f);
2484
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2485
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2486
+
2487
+ assertEquals(10f, root_child4.getLayoutX(), 0.0f);
2488
+ assertEquals(346f, root_child4.getLayoutY(), 0.0f);
2489
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2490
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2491
+
2492
+ root.setDirection(YogaDirection.RTL);
2493
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2494
+
2495
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2496
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2497
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2498
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2499
+
2500
+ assertEquals(190f, root_child0.getLayoutX(), 0.0f);
2501
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
2502
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2503
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2504
+
2505
+ assertEquals(62f, root_child1.getLayoutX(), 0.0f);
2506
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
2507
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2508
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2509
+
2510
+ assertEquals(190f, root_child2.getLayoutX(), 0.0f);
2511
+ assertEquals(178f, root_child2.getLayoutY(), 0.0f);
2512
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2513
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2514
+
2515
+ assertEquals(62f, root_child3.getLayoutX(), 0.0f);
2516
+ assertEquals(178f, root_child3.getLayoutY(), 0.0f);
2517
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2518
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2519
+
2520
+ assertEquals(190f, root_child4.getLayoutX(), 0.0f);
2521
+ assertEquals(346f, root_child4.getLayoutY(), 0.0f);
2522
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2523
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2524
+ }
2525
+
2526
+ @Test
2527
+ public void test_row_gap_percent_wrapping_with_both_content_padding() {
2528
+ YogaConfig config = YogaConfigFactory.create();
2529
+
2530
+ final YogaNode root = createNode(config);
2531
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2532
+ root.setFlexDirection(YogaFlexDirection.ROW);
2533
+ root.setWidth(300f);
2534
+ root.setHeight(700f);
2535
+ root.setPadding(YogaEdge.ALL, 10);
2536
+ root.setGapPercent(YogaGutter.ALL, 10f);
2537
+ root.setWrap(YogaWrap.WRAP);
2538
+
2539
+ final YogaNode root_child0 = createNode(config);
2540
+ root_child0.setWidth(100f);
2541
+ root_child0.setHeight(100f);
2542
+ root.addChildAt(root_child0, 0);
2543
+
2544
+ final YogaNode root_child1 = createNode(config);
2545
+ root_child1.setWidth(100f);
2546
+ root_child1.setHeight(100f);
2547
+ root.addChildAt(root_child1, 1);
2548
+
2549
+ final YogaNode root_child2 = createNode(config);
2550
+ root_child2.setWidth(100f);
2551
+ root_child2.setHeight(100f);
2552
+ root.addChildAt(root_child2, 2);
2553
+
2554
+ final YogaNode root_child3 = createNode(config);
2555
+ root_child3.setWidth(100f);
2556
+ root_child3.setHeight(100f);
2557
+ root.addChildAt(root_child3, 3);
2558
+
2559
+ final YogaNode root_child4 = createNode(config);
2560
+ root_child4.setWidth(100f);
2561
+ root_child4.setHeight(100f);
2562
+ root.addChildAt(root_child4, 4);
2563
+ root.setDirection(YogaDirection.LTR);
2564
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2565
+
2566
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2567
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2568
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2569
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2570
+
2571
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
2572
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
2573
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2574
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2575
+
2576
+ assertEquals(138f, root_child1.getLayoutX(), 0.0f);
2577
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
2578
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2579
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2580
+
2581
+ assertEquals(10f, root_child2.getLayoutX(), 0.0f);
2582
+ assertEquals(178f, root_child2.getLayoutY(), 0.0f);
2583
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2584
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2585
+
2586
+ assertEquals(138f, root_child3.getLayoutX(), 0.0f);
2587
+ assertEquals(178f, root_child3.getLayoutY(), 0.0f);
2588
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2589
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2590
+
2591
+ assertEquals(10f, root_child4.getLayoutX(), 0.0f);
2592
+ assertEquals(346f, root_child4.getLayoutY(), 0.0f);
2593
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2594
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2595
+
2596
+ root.setDirection(YogaDirection.RTL);
2597
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2598
+
2599
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2600
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2601
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2602
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2603
+
2604
+ assertEquals(190f, root_child0.getLayoutX(), 0.0f);
2605
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
2606
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2607
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2608
+
2609
+ assertEquals(62f, root_child1.getLayoutX(), 0.0f);
2610
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
2611
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2612
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2613
+
2614
+ assertEquals(190f, root_child2.getLayoutX(), 0.0f);
2615
+ assertEquals(178f, root_child2.getLayoutY(), 0.0f);
2616
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2617
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2618
+
2619
+ assertEquals(62f, root_child3.getLayoutX(), 0.0f);
2620
+ assertEquals(178f, root_child3.getLayoutY(), 0.0f);
2621
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2622
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2623
+
2624
+ assertEquals(190f, root_child4.getLayoutX(), 0.0f);
2625
+ assertEquals(346f, root_child4.getLayoutY(), 0.0f);
2626
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2627
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2628
+ }
2629
+
2630
+ @Test
2631
+ public void test_row_gap_percent_wrapping_with_content_margin() {
2632
+ YogaConfig config = YogaConfigFactory.create();
2633
+
2634
+ final YogaNode root = createNode(config);
2635
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2636
+ root.setFlexDirection(YogaFlexDirection.ROW);
2637
+ root.setWidth(300f);
2638
+ root.setHeight(700f);
2639
+ root.setMargin(YogaEdge.ALL, 10f);
2640
+ root.setGapPercent(YogaGutter.ALL, 10f);
2641
+ root.setWrap(YogaWrap.WRAP);
2642
+
2643
+ final YogaNode root_child0 = createNode(config);
2644
+ root_child0.setWidth(100f);
2645
+ root_child0.setHeight(100f);
2646
+ root.addChildAt(root_child0, 0);
2647
+
2648
+ final YogaNode root_child1 = createNode(config);
2649
+ root_child1.setWidth(100f);
2650
+ root_child1.setHeight(100f);
2651
+ root.addChildAt(root_child1, 1);
2652
+
2653
+ final YogaNode root_child2 = createNode(config);
2654
+ root_child2.setWidth(100f);
2655
+ root_child2.setHeight(100f);
2656
+ root.addChildAt(root_child2, 2);
2657
+
2658
+ final YogaNode root_child3 = createNode(config);
2659
+ root_child3.setWidth(100f);
2660
+ root_child3.setHeight(100f);
2661
+ root.addChildAt(root_child3, 3);
2662
+
2663
+ final YogaNode root_child4 = createNode(config);
2664
+ root_child4.setWidth(100f);
2665
+ root_child4.setHeight(100f);
2666
+ root.addChildAt(root_child4, 4);
2667
+ root.setDirection(YogaDirection.LTR);
2668
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2669
+
2670
+ assertEquals(10f, root.getLayoutX(), 0.0f);
2671
+ assertEquals(10f, root.getLayoutY(), 0.0f);
2672
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2673
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2674
+
2675
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2676
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2677
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2678
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2679
+
2680
+ assertEquals(130f, root_child1.getLayoutX(), 0.0f);
2681
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2682
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2683
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2684
+
2685
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
2686
+ assertEquals(170f, root_child2.getLayoutY(), 0.0f);
2687
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2688
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2689
+
2690
+ assertEquals(130f, root_child3.getLayoutX(), 0.0f);
2691
+ assertEquals(170f, root_child3.getLayoutY(), 0.0f);
2692
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2693
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2694
+
2695
+ assertEquals(0f, root_child4.getLayoutX(), 0.0f);
2696
+ assertEquals(340f, root_child4.getLayoutY(), 0.0f);
2697
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2698
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2699
+
2700
+ root.setDirection(YogaDirection.RTL);
2701
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2702
+
2703
+ assertEquals(10f, root.getLayoutX(), 0.0f);
2704
+ assertEquals(10f, root.getLayoutY(), 0.0f);
2705
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2706
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2707
+
2708
+ assertEquals(200f, root_child0.getLayoutX(), 0.0f);
2709
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2710
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2711
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2712
+
2713
+ assertEquals(70f, root_child1.getLayoutX(), 0.0f);
2714
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2715
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2716
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2717
+
2718
+ assertEquals(200f, root_child2.getLayoutX(), 0.0f);
2719
+ assertEquals(170f, root_child2.getLayoutY(), 0.0f);
2720
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2721
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2722
+
2723
+ assertEquals(70f, root_child3.getLayoutX(), 0.0f);
2724
+ assertEquals(170f, root_child3.getLayoutY(), 0.0f);
2725
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2726
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2727
+
2728
+ assertEquals(200f, root_child4.getLayoutX(), 0.0f);
2729
+ assertEquals(340f, root_child4.getLayoutY(), 0.0f);
2730
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2731
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2732
+ }
2733
+
2734
+ @Test
2735
+ public void test_row_gap_percent_wrapping_with_content_margin_and_padding() {
2736
+ YogaConfig config = YogaConfigFactory.create();
2737
+
2738
+ final YogaNode root = createNode(config);
2739
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2740
+ root.setFlexDirection(YogaFlexDirection.ROW);
2741
+ root.setWidth(300f);
2742
+ root.setHeight(700f);
2743
+ root.setMargin(YogaEdge.ALL, 10f);
2744
+ root.setPadding(YogaEdge.ALL, 10);
2745
+ root.setGapPercent(YogaGutter.ALL, 10f);
2746
+ root.setWrap(YogaWrap.WRAP);
2747
+
2748
+ final YogaNode root_child0 = createNode(config);
2749
+ root_child0.setWidth(100f);
2750
+ root_child0.setHeight(100f);
2751
+ root.addChildAt(root_child0, 0);
2752
+
2753
+ final YogaNode root_child1 = createNode(config);
2754
+ root_child1.setWidth(100f);
2755
+ root_child1.setHeight(100f);
2756
+ root.addChildAt(root_child1, 1);
2757
+
2758
+ final YogaNode root_child2 = createNode(config);
2759
+ root_child2.setWidth(100f);
2760
+ root_child2.setHeight(100f);
2761
+ root.addChildAt(root_child2, 2);
2762
+
2763
+ final YogaNode root_child3 = createNode(config);
2764
+ root_child3.setWidth(100f);
2765
+ root_child3.setHeight(100f);
2766
+ root.addChildAt(root_child3, 3);
2767
+
2768
+ final YogaNode root_child4 = createNode(config);
2769
+ root_child4.setWidth(100f);
2770
+ root_child4.setHeight(100f);
2771
+ root.addChildAt(root_child4, 4);
2772
+ root.setDirection(YogaDirection.LTR);
2773
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2774
+
2775
+ assertEquals(10f, root.getLayoutX(), 0.0f);
2776
+ assertEquals(10f, root.getLayoutY(), 0.0f);
2777
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2778
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2779
+
2780
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
2781
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
2782
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2783
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2784
+
2785
+ assertEquals(138f, root_child1.getLayoutX(), 0.0f);
2786
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
2787
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2788
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2789
+
2790
+ assertEquals(10f, root_child2.getLayoutX(), 0.0f);
2791
+ assertEquals(178f, root_child2.getLayoutY(), 0.0f);
2792
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2793
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2794
+
2795
+ assertEquals(138f, root_child3.getLayoutX(), 0.0f);
2796
+ assertEquals(178f, root_child3.getLayoutY(), 0.0f);
2797
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2798
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2799
+
2800
+ assertEquals(10f, root_child4.getLayoutX(), 0.0f);
2801
+ assertEquals(346f, root_child4.getLayoutY(), 0.0f);
2802
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2803
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2804
+
2805
+ root.setDirection(YogaDirection.RTL);
2806
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2807
+
2808
+ assertEquals(10f, root.getLayoutX(), 0.0f);
2809
+ assertEquals(10f, root.getLayoutY(), 0.0f);
2810
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2811
+ assertEquals(700f, root.getLayoutHeight(), 0.0f);
2812
+
2813
+ assertEquals(190f, root_child0.getLayoutX(), 0.0f);
2814
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
2815
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
2816
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
2817
+
2818
+ assertEquals(62f, root_child1.getLayoutX(), 0.0f);
2819
+ assertEquals(10f, root_child1.getLayoutY(), 0.0f);
2820
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
2821
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
2822
+
2823
+ assertEquals(190f, root_child2.getLayoutX(), 0.0f);
2824
+ assertEquals(178f, root_child2.getLayoutY(), 0.0f);
2825
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
2826
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
2827
+
2828
+ assertEquals(62f, root_child3.getLayoutX(), 0.0f);
2829
+ assertEquals(178f, root_child3.getLayoutY(), 0.0f);
2830
+ assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
2831
+ assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
2832
+
2833
+ assertEquals(190f, root_child4.getLayoutX(), 0.0f);
2834
+ assertEquals(346f, root_child4.getLayoutY(), 0.0f);
2835
+ assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
2836
+ assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
2837
+ }
2838
+
2839
+ @Test
2840
+ public void test_row_gap_percent_wrapping_with_flexible_content() {
2841
+ YogaConfig config = YogaConfigFactory.create();
2842
+
2843
+ final YogaNode root = createNode(config);
2844
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2845
+ root.setFlexDirection(YogaFlexDirection.ROW);
2846
+ root.setWidth(300f);
2847
+ root.setHeight(300f);
2848
+ root.setGapPercent(YogaGutter.ALL, 10f);
2849
+
2850
+ final YogaNode root_child0 = createNode(config);
2851
+ root_child0.setFlexGrow(1f);
2852
+ root_child0.setFlexShrink(1f);
2853
+ root_child0.setFlexBasisPercent(0f);
2854
+ root.addChildAt(root_child0, 0);
2855
+
2856
+ final YogaNode root_child1 = createNode(config);
2857
+ root_child1.setFlexGrow(1f);
2858
+ root_child1.setFlexShrink(1f);
2859
+ root_child1.setFlexBasisPercent(0f);
2860
+ root.addChildAt(root_child1, 1);
2861
+
2862
+ final YogaNode root_child2 = createNode(config);
2863
+ root_child2.setFlexGrow(1f);
2864
+ root_child2.setFlexShrink(1f);
2865
+ root_child2.setFlexBasisPercent(0f);
2866
+ root.addChildAt(root_child2, 2);
2867
+ root.setDirection(YogaDirection.LTR);
2868
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2869
+
2870
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2871
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2872
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2873
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
2874
+
2875
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2876
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2877
+ assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
2878
+ assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
2879
+
2880
+ assertEquals(110f, root_child1.getLayoutX(), 0.0f);
2881
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2882
+ assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
2883
+ assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
2884
+
2885
+ assertEquals(220f, root_child2.getLayoutX(), 0.0f);
2886
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
2887
+ assertEquals(80f, root_child2.getLayoutWidth(), 0.0f);
2888
+ assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
2889
+
2890
+ root.setDirection(YogaDirection.RTL);
2891
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2892
+
2893
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2894
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2895
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2896
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
2897
+
2898
+ assertEquals(220f, root_child0.getLayoutX(), 0.0f);
2899
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2900
+ assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
2901
+ assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
2902
+
2903
+ assertEquals(110f, root_child1.getLayoutX(), 0.0f);
2904
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2905
+ assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
2906
+ assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
2907
+
2908
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
2909
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
2910
+ assertEquals(80f, root_child2.getLayoutWidth(), 0.0f);
2911
+ assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
2912
+ }
2913
+
2914
+ @Test
2915
+ public void test_row_gap_percent_wrapping_with_mixed_flexible_content() {
2916
+ YogaConfig config = YogaConfigFactory.create();
2917
+
2918
+ final YogaNode root = createNode(config);
2919
+ root.setPositionType(YogaPositionType.ABSOLUTE);
2920
+ root.setFlexDirection(YogaFlexDirection.ROW);
2921
+ root.setWidth(300f);
2922
+ root.setHeight(300f);
2923
+ root.setGapPercent(YogaGutter.ALL, 10f);
2924
+
2925
+ final YogaNode root_child0 = createNode(config);
2926
+ root_child0.setWidth(10f);
2927
+ root.addChildAt(root_child0, 0);
2928
+
2929
+ final YogaNode root_child1 = createNode(config);
2930
+ root_child1.setFlexGrow(1f);
2931
+ root_child1.setFlexShrink(1f);
2932
+ root_child1.setFlexBasisPercent(0f);
2933
+ root.addChildAt(root_child1, 1);
2934
+
2935
+ final YogaNode root_child2 = createNode(config);
2936
+ root_child2.setWidthPercent(10f);
2937
+ root.addChildAt(root_child2, 2);
2938
+ root.setDirection(YogaDirection.LTR);
2939
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2940
+
2941
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2942
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2943
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2944
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
2945
+
2946
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
2947
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2948
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
2949
+ assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
2950
+
2951
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
2952
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2953
+ assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
2954
+ assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
2955
+
2956
+ assertEquals(270f, root_child2.getLayoutX(), 0.0f);
2957
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
2958
+ assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
2959
+ assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
2960
+
2961
+ root.setDirection(YogaDirection.RTL);
2962
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
2963
+
2964
+ assertEquals(0f, root.getLayoutX(), 0.0f);
2965
+ assertEquals(0f, root.getLayoutY(), 0.0f);
2966
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
2967
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
2968
+
2969
+ assertEquals(290f, root_child0.getLayoutX(), 0.0f);
2970
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
2971
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
2972
+ assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
2973
+
2974
+ assertEquals(60f, root_child1.getLayoutX(), 0.0f);
2975
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
2976
+ assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
2977
+ assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
2978
+
2979
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
2980
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
2981
+ assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
2982
+ assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
2983
+ }
2984
+
2985
+ private YogaNode createNode(YogaConfig config) {
2986
+ return mNodeFactory.create(config);
2987
+ }
2988
+ }