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,1670 @@
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<<bb931eec168913945a41786c6d25f337>>
8
+ * generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGAbsolutePositionTest.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 YGAbsolutePositionTest {
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_absolute_layout_width_height_start_top() {
32
+ YogaConfig config = YogaConfigFactory.create();
33
+
34
+ final YogaNode root = createNode(config);
35
+ root.setPositionType(YogaPositionType.ABSOLUTE);
36
+ root.setWidth(100f);
37
+ root.setHeight(100f);
38
+
39
+ final YogaNode root_child0 = createNode(config);
40
+ root_child0.setWidth(10f);
41
+ root_child0.setHeight(10f);
42
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
43
+ root_child0.setPosition(YogaEdge.START, 10f);
44
+ root_child0.setPosition(YogaEdge.TOP, 10f);
45
+ root.addChildAt(root_child0, 0);
46
+ root.setDirection(YogaDirection.LTR);
47
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
48
+
49
+ assertEquals(0f, root.getLayoutX(), 0.0f);
50
+ assertEquals(0f, root.getLayoutY(), 0.0f);
51
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
52
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
53
+
54
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
55
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
56
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
57
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
58
+
59
+ root.setDirection(YogaDirection.RTL);
60
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
61
+
62
+ assertEquals(0f, root.getLayoutX(), 0.0f);
63
+ assertEquals(0f, root.getLayoutY(), 0.0f);
64
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
65
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
66
+
67
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
68
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
69
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
70
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
71
+ }
72
+
73
+ @Test
74
+ public void test_absolute_layout_width_height_left_auto_right() {
75
+ YogaConfig config = YogaConfigFactory.create();
76
+
77
+ final YogaNode root = createNode(config);
78
+ root.setPositionType(YogaPositionType.ABSOLUTE);
79
+ root.setWidth(100f);
80
+ root.setHeight(100f);
81
+
82
+ final YogaNode root_child0 = createNode(config);
83
+ root_child0.setWidth(10f);
84
+ root_child0.setHeight(10f);
85
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
86
+ root_child0.setPositionAuto(YogaEdge.LEFT);
87
+ root_child0.setPosition(YogaEdge.RIGHT, 10f);
88
+ root.addChildAt(root_child0, 0);
89
+ root.setDirection(YogaDirection.LTR);
90
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
91
+
92
+ assertEquals(0f, root.getLayoutX(), 0.0f);
93
+ assertEquals(0f, root.getLayoutY(), 0.0f);
94
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
95
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
96
+
97
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
98
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
99
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
100
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
101
+
102
+ root.setDirection(YogaDirection.RTL);
103
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
104
+
105
+ assertEquals(0f, root.getLayoutX(), 0.0f);
106
+ assertEquals(0f, root.getLayoutY(), 0.0f);
107
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
108
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
109
+
110
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
111
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
112
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
113
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
114
+ }
115
+
116
+ @Test
117
+ public void test_absolute_layout_width_height_left_right_auto() {
118
+ YogaConfig config = YogaConfigFactory.create();
119
+
120
+ final YogaNode root = createNode(config);
121
+ root.setPositionType(YogaPositionType.ABSOLUTE);
122
+ root.setWidth(100f);
123
+ root.setHeight(100f);
124
+
125
+ final YogaNode root_child0 = createNode(config);
126
+ root_child0.setWidth(10f);
127
+ root_child0.setHeight(10f);
128
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
129
+ root_child0.setPosition(YogaEdge.LEFT, 10f);
130
+ root_child0.setPositionAuto(YogaEdge.RIGHT);
131
+ root.addChildAt(root_child0, 0);
132
+ root.setDirection(YogaDirection.LTR);
133
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
134
+
135
+ assertEquals(0f, root.getLayoutX(), 0.0f);
136
+ assertEquals(0f, root.getLayoutY(), 0.0f);
137
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
138
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
139
+
140
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
141
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
142
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
143
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
144
+
145
+ root.setDirection(YogaDirection.RTL);
146
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
147
+
148
+ assertEquals(0f, root.getLayoutX(), 0.0f);
149
+ assertEquals(0f, root.getLayoutY(), 0.0f);
150
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
151
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
152
+
153
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
154
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
155
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
156
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
157
+ }
158
+
159
+ @Test
160
+ public void test_absolute_layout_width_height_left_auto_right_auto() {
161
+ YogaConfig config = YogaConfigFactory.create();
162
+
163
+ final YogaNode root = createNode(config);
164
+ root.setPositionType(YogaPositionType.ABSOLUTE);
165
+ root.setWidth(100f);
166
+ root.setHeight(100f);
167
+
168
+ final YogaNode root_child0 = createNode(config);
169
+ root_child0.setWidth(10f);
170
+ root_child0.setHeight(10f);
171
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
172
+ root_child0.setPositionAuto(YogaEdge.LEFT);
173
+ root_child0.setPositionAuto(YogaEdge.RIGHT);
174
+ root.addChildAt(root_child0, 0);
175
+ root.setDirection(YogaDirection.LTR);
176
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
177
+
178
+ assertEquals(0f, root.getLayoutX(), 0.0f);
179
+ assertEquals(0f, root.getLayoutY(), 0.0f);
180
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
181
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
182
+
183
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
184
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
185
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
186
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
187
+
188
+ root.setDirection(YogaDirection.RTL);
189
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
190
+
191
+ assertEquals(0f, root.getLayoutX(), 0.0f);
192
+ assertEquals(0f, root.getLayoutY(), 0.0f);
193
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
194
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
195
+
196
+ assertEquals(90f, root_child0.getLayoutX(), 0.0f);
197
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
198
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
199
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
200
+ }
201
+
202
+ @Test
203
+ public void test_absolute_layout_width_height_end_bottom() {
204
+ YogaConfig config = YogaConfigFactory.create();
205
+
206
+ final YogaNode root = createNode(config);
207
+ root.setPositionType(YogaPositionType.ABSOLUTE);
208
+ root.setWidth(100f);
209
+ root.setHeight(100f);
210
+
211
+ final YogaNode root_child0 = createNode(config);
212
+ root_child0.setWidth(10f);
213
+ root_child0.setHeight(10f);
214
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
215
+ root_child0.setPosition(YogaEdge.END, 10f);
216
+ root_child0.setPosition(YogaEdge.BOTTOM, 10f);
217
+ root.addChildAt(root_child0, 0);
218
+ root.setDirection(YogaDirection.LTR);
219
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
220
+
221
+ assertEquals(0f, root.getLayoutX(), 0.0f);
222
+ assertEquals(0f, root.getLayoutY(), 0.0f);
223
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
224
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
225
+
226
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
227
+ assertEquals(80f, root_child0.getLayoutY(), 0.0f);
228
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
229
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
230
+
231
+ root.setDirection(YogaDirection.RTL);
232
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
233
+
234
+ assertEquals(0f, root.getLayoutX(), 0.0f);
235
+ assertEquals(0f, root.getLayoutY(), 0.0f);
236
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
237
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
238
+
239
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
240
+ assertEquals(80f, root_child0.getLayoutY(), 0.0f);
241
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
242
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
243
+ }
244
+
245
+ @Test
246
+ public void test_absolute_layout_start_top_end_bottom() {
247
+ YogaConfig config = YogaConfigFactory.create();
248
+
249
+ final YogaNode root = createNode(config);
250
+ root.setPositionType(YogaPositionType.ABSOLUTE);
251
+ root.setWidth(100f);
252
+ root.setHeight(100f);
253
+
254
+ final YogaNode root_child0 = createNode(config);
255
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
256
+ root_child0.setPosition(YogaEdge.START, 10f);
257
+ root_child0.setPosition(YogaEdge.TOP, 10f);
258
+ root_child0.setPosition(YogaEdge.END, 10f);
259
+ root_child0.setPosition(YogaEdge.BOTTOM, 10f);
260
+ root.addChildAt(root_child0, 0);
261
+ root.setDirection(YogaDirection.LTR);
262
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
263
+
264
+ assertEquals(0f, root.getLayoutX(), 0.0f);
265
+ assertEquals(0f, root.getLayoutY(), 0.0f);
266
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
267
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
268
+
269
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
270
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
271
+ assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
272
+ assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
273
+
274
+ root.setDirection(YogaDirection.RTL);
275
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
276
+
277
+ assertEquals(0f, root.getLayoutX(), 0.0f);
278
+ assertEquals(0f, root.getLayoutY(), 0.0f);
279
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
280
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
281
+
282
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
283
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
284
+ assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
285
+ assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
286
+ }
287
+
288
+ @Test
289
+ public void test_absolute_layout_width_height_start_top_end_bottom() {
290
+ YogaConfig config = YogaConfigFactory.create();
291
+
292
+ final YogaNode root = createNode(config);
293
+ root.setPositionType(YogaPositionType.ABSOLUTE);
294
+ root.setWidth(100f);
295
+ root.setHeight(100f);
296
+
297
+ final YogaNode root_child0 = createNode(config);
298
+ root_child0.setWidth(10f);
299
+ root_child0.setHeight(10f);
300
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
301
+ root_child0.setPosition(YogaEdge.START, 10f);
302
+ root_child0.setPosition(YogaEdge.TOP, 10f);
303
+ root_child0.setPosition(YogaEdge.END, 10f);
304
+ root_child0.setPosition(YogaEdge.BOTTOM, 10f);
305
+ root.addChildAt(root_child0, 0);
306
+ root.setDirection(YogaDirection.LTR);
307
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
308
+
309
+ assertEquals(0f, root.getLayoutX(), 0.0f);
310
+ assertEquals(0f, root.getLayoutY(), 0.0f);
311
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
312
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
313
+
314
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
315
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
316
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
317
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
318
+
319
+ root.setDirection(YogaDirection.RTL);
320
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
321
+
322
+ assertEquals(0f, root.getLayoutX(), 0.0f);
323
+ assertEquals(0f, root.getLayoutY(), 0.0f);
324
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
325
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
326
+
327
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
328
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
329
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
330
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
331
+ }
332
+
333
+ @Test
334
+ public void test_do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent() {
335
+ YogaConfig config = YogaConfigFactory.create();
336
+
337
+ final YogaNode root = createNode(config);
338
+ root.setPositionType(YogaPositionType.ABSOLUTE);
339
+ root.setHeight(50f);
340
+ root.setWidth(50f);
341
+ root.setOverflow(YogaOverflow.HIDDEN);
342
+ root.setFlexDirection(YogaFlexDirection.ROW);
343
+
344
+ final YogaNode root_child0 = createNode(config);
345
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
346
+ root_child0.setPosition(YogaEdge.START, 0f);
347
+ root_child0.setPosition(YogaEdge.TOP, 0f);
348
+ root.addChildAt(root_child0, 0);
349
+
350
+ final YogaNode root_child0_child0 = createNode(config);
351
+ root_child0_child0.setWidth(100f);
352
+ root_child0_child0.setHeight(100f);
353
+ root_child0.addChildAt(root_child0_child0, 0);
354
+ root.setDirection(YogaDirection.LTR);
355
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
356
+
357
+ assertEquals(0f, root.getLayoutX(), 0.0f);
358
+ assertEquals(0f, root.getLayoutY(), 0.0f);
359
+ assertEquals(50f, root.getLayoutWidth(), 0.0f);
360
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
361
+
362
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
363
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
364
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
365
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
366
+
367
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
368
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
369
+ assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
370
+ assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
371
+
372
+ root.setDirection(YogaDirection.RTL);
373
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
374
+
375
+ assertEquals(0f, root.getLayoutX(), 0.0f);
376
+ assertEquals(0f, root.getLayoutY(), 0.0f);
377
+ assertEquals(50f, root.getLayoutWidth(), 0.0f);
378
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
379
+
380
+ assertEquals(-50f, root_child0.getLayoutX(), 0.0f);
381
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
382
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
383
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
384
+
385
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
386
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
387
+ assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
388
+ assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
389
+ }
390
+
391
+ @Test
392
+ public void test_absolute_layout_within_border() {
393
+ YogaConfig config = YogaConfigFactory.create();
394
+
395
+ final YogaNode root = createNode(config);
396
+ root.setPositionType(YogaPositionType.ABSOLUTE);
397
+ root.setHeight(100f);
398
+ root.setWidth(100f);
399
+ root.setBorder(YogaEdge.ALL, 10f);
400
+ root.setMargin(YogaEdge.ALL, 10f);
401
+ root.setPadding(YogaEdge.ALL, 10);
402
+
403
+ final YogaNode root_child0 = createNode(config);
404
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
405
+ root_child0.setWidth(50f);
406
+ root_child0.setHeight(50f);
407
+ root_child0.setPosition(YogaEdge.LEFT, 0f);
408
+ root_child0.setPosition(YogaEdge.TOP, 0f);
409
+ root.addChildAt(root_child0, 0);
410
+
411
+ final YogaNode root_child1 = createNode(config);
412
+ root_child1.setPositionType(YogaPositionType.ABSOLUTE);
413
+ root_child1.setWidth(50f);
414
+ root_child1.setHeight(50f);
415
+ root_child1.setPosition(YogaEdge.RIGHT, 0f);
416
+ root_child1.setPosition(YogaEdge.BOTTOM, 0f);
417
+ root.addChildAt(root_child1, 1);
418
+
419
+ final YogaNode root_child2 = createNode(config);
420
+ root_child2.setPositionType(YogaPositionType.ABSOLUTE);
421
+ root_child2.setWidth(50f);
422
+ root_child2.setHeight(50f);
423
+ root_child2.setPosition(YogaEdge.LEFT, 0f);
424
+ root_child2.setPosition(YogaEdge.TOP, 0f);
425
+ root_child2.setMargin(YogaEdge.ALL, 10f);
426
+ root.addChildAt(root_child2, 2);
427
+
428
+ final YogaNode root_child3 = createNode(config);
429
+ root_child3.setPositionType(YogaPositionType.ABSOLUTE);
430
+ root_child3.setWidth(50f);
431
+ root_child3.setHeight(50f);
432
+ root_child3.setPosition(YogaEdge.RIGHT, 0f);
433
+ root_child3.setPosition(YogaEdge.BOTTOM, 0f);
434
+ root_child3.setMargin(YogaEdge.ALL, 10f);
435
+ root.addChildAt(root_child3, 3);
436
+ root.setDirection(YogaDirection.LTR);
437
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
438
+
439
+ assertEquals(10f, root.getLayoutX(), 0.0f);
440
+ assertEquals(10f, root.getLayoutY(), 0.0f);
441
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
442
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
443
+
444
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
445
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
446
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
447
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
448
+
449
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
450
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
451
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
452
+ assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
453
+
454
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
455
+ assertEquals(20f, root_child2.getLayoutY(), 0.0f);
456
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
457
+ assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
458
+
459
+ assertEquals(30f, root_child3.getLayoutX(), 0.0f);
460
+ assertEquals(30f, root_child3.getLayoutY(), 0.0f);
461
+ assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
462
+ assertEquals(50f, root_child3.getLayoutHeight(), 0.0f);
463
+
464
+ root.setDirection(YogaDirection.RTL);
465
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
466
+
467
+ assertEquals(10f, root.getLayoutX(), 0.0f);
468
+ assertEquals(10f, root.getLayoutY(), 0.0f);
469
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
470
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
471
+
472
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
473
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
474
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
475
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
476
+
477
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
478
+ assertEquals(40f, root_child1.getLayoutY(), 0.0f);
479
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
480
+ assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
481
+
482
+ assertEquals(20f, root_child2.getLayoutX(), 0.0f);
483
+ assertEquals(20f, root_child2.getLayoutY(), 0.0f);
484
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
485
+ assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
486
+
487
+ assertEquals(30f, root_child3.getLayoutX(), 0.0f);
488
+ assertEquals(30f, root_child3.getLayoutY(), 0.0f);
489
+ assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
490
+ assertEquals(50f, root_child3.getLayoutHeight(), 0.0f);
491
+ }
492
+
493
+ @Test
494
+ public void test_absolute_layout_align_items_and_justify_content_center() {
495
+ YogaConfig config = YogaConfigFactory.create();
496
+
497
+ final YogaNode root = createNode(config);
498
+ root.setPositionType(YogaPositionType.ABSOLUTE);
499
+ root.setHeight(100f);
500
+ root.setWidth(110f);
501
+ root.setFlexGrow(1f);
502
+ root.setAlignItems(YogaAlign.CENTER);
503
+ root.setJustifyContent(YogaJustify.CENTER);
504
+
505
+ final YogaNode root_child0 = createNode(config);
506
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
507
+ root_child0.setWidth(60f);
508
+ root_child0.setHeight(40f);
509
+ root.addChildAt(root_child0, 0);
510
+ root.setDirection(YogaDirection.LTR);
511
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
512
+
513
+ assertEquals(0f, root.getLayoutX(), 0.0f);
514
+ assertEquals(0f, root.getLayoutY(), 0.0f);
515
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
516
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
517
+
518
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
519
+ assertEquals(30f, root_child0.getLayoutY(), 0.0f);
520
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
521
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
522
+
523
+ root.setDirection(YogaDirection.RTL);
524
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
525
+
526
+ assertEquals(0f, root.getLayoutX(), 0.0f);
527
+ assertEquals(0f, root.getLayoutY(), 0.0f);
528
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
529
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
530
+
531
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
532
+ assertEquals(30f, root_child0.getLayoutY(), 0.0f);
533
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
534
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
535
+ }
536
+
537
+ @Test
538
+ public void test_absolute_layout_align_items_and_justify_content_flex_end() {
539
+ YogaConfig config = YogaConfigFactory.create();
540
+
541
+ final YogaNode root = createNode(config);
542
+ root.setPositionType(YogaPositionType.ABSOLUTE);
543
+ root.setHeight(100f);
544
+ root.setWidth(110f);
545
+ root.setFlexGrow(1f);
546
+ root.setAlignItems(YogaAlign.FLEX_END);
547
+ root.setJustifyContent(YogaJustify.FLEX_END);
548
+
549
+ final YogaNode root_child0 = createNode(config);
550
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
551
+ root_child0.setWidth(60f);
552
+ root_child0.setHeight(40f);
553
+ root.addChildAt(root_child0, 0);
554
+ root.setDirection(YogaDirection.LTR);
555
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
556
+
557
+ assertEquals(0f, root.getLayoutX(), 0.0f);
558
+ assertEquals(0f, root.getLayoutY(), 0.0f);
559
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
560
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
561
+
562
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
563
+ assertEquals(60f, root_child0.getLayoutY(), 0.0f);
564
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
565
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
566
+
567
+ root.setDirection(YogaDirection.RTL);
568
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
569
+
570
+ assertEquals(0f, root.getLayoutX(), 0.0f);
571
+ assertEquals(0f, root.getLayoutY(), 0.0f);
572
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
573
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
574
+
575
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
576
+ assertEquals(60f, root_child0.getLayoutY(), 0.0f);
577
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
578
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
579
+ }
580
+
581
+ @Test
582
+ public void test_absolute_layout_justify_content_center() {
583
+ YogaConfig config = YogaConfigFactory.create();
584
+
585
+ final YogaNode root = createNode(config);
586
+ root.setPositionType(YogaPositionType.ABSOLUTE);
587
+ root.setHeight(100f);
588
+ root.setWidth(110f);
589
+ root.setFlexGrow(1f);
590
+ root.setJustifyContent(YogaJustify.CENTER);
591
+
592
+ final YogaNode root_child0 = createNode(config);
593
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
594
+ root_child0.setWidth(60f);
595
+ root_child0.setHeight(40f);
596
+ root.addChildAt(root_child0, 0);
597
+ root.setDirection(YogaDirection.LTR);
598
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
599
+
600
+ assertEquals(0f, root.getLayoutX(), 0.0f);
601
+ assertEquals(0f, root.getLayoutY(), 0.0f);
602
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
603
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
604
+
605
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
606
+ assertEquals(30f, root_child0.getLayoutY(), 0.0f);
607
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
608
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
609
+
610
+ root.setDirection(YogaDirection.RTL);
611
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
612
+
613
+ assertEquals(0f, root.getLayoutX(), 0.0f);
614
+ assertEquals(0f, root.getLayoutY(), 0.0f);
615
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
616
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
617
+
618
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
619
+ assertEquals(30f, root_child0.getLayoutY(), 0.0f);
620
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
621
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
622
+ }
623
+
624
+ @Test
625
+ public void test_absolute_layout_align_items_center() {
626
+ YogaConfig config = YogaConfigFactory.create();
627
+
628
+ final YogaNode root = createNode(config);
629
+ root.setPositionType(YogaPositionType.ABSOLUTE);
630
+ root.setHeight(100f);
631
+ root.setWidth(110f);
632
+ root.setFlexGrow(1f);
633
+ root.setAlignItems(YogaAlign.CENTER);
634
+
635
+ final YogaNode root_child0 = createNode(config);
636
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
637
+ root_child0.setWidth(60f);
638
+ root_child0.setHeight(40f);
639
+ root.addChildAt(root_child0, 0);
640
+ root.setDirection(YogaDirection.LTR);
641
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
642
+
643
+ assertEquals(0f, root.getLayoutX(), 0.0f);
644
+ assertEquals(0f, root.getLayoutY(), 0.0f);
645
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
646
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
647
+
648
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
649
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
650
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
651
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
652
+
653
+ root.setDirection(YogaDirection.RTL);
654
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
655
+
656
+ assertEquals(0f, root.getLayoutX(), 0.0f);
657
+ assertEquals(0f, root.getLayoutY(), 0.0f);
658
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
659
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
660
+
661
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
662
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
663
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
664
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
665
+ }
666
+
667
+ @Test
668
+ public void test_absolute_layout_align_items_center_on_child_only() {
669
+ YogaConfig config = YogaConfigFactory.create();
670
+
671
+ final YogaNode root = createNode(config);
672
+ root.setPositionType(YogaPositionType.ABSOLUTE);
673
+ root.setHeight(100f);
674
+ root.setWidth(110f);
675
+ root.setFlexGrow(1f);
676
+
677
+ final YogaNode root_child0 = createNode(config);
678
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
679
+ root_child0.setWidth(60f);
680
+ root_child0.setHeight(40f);
681
+ root_child0.setAlignSelf(YogaAlign.CENTER);
682
+ root.addChildAt(root_child0, 0);
683
+ root.setDirection(YogaDirection.LTR);
684
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
685
+
686
+ assertEquals(0f, root.getLayoutX(), 0.0f);
687
+ assertEquals(0f, root.getLayoutY(), 0.0f);
688
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
689
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
690
+
691
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
692
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
693
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
694
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
695
+
696
+ root.setDirection(YogaDirection.RTL);
697
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
698
+
699
+ assertEquals(0f, root.getLayoutX(), 0.0f);
700
+ assertEquals(0f, root.getLayoutY(), 0.0f);
701
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
702
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
703
+
704
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
705
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
706
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
707
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
708
+ }
709
+
710
+ @Test
711
+ public void test_absolute_layout_align_items_and_justify_content_center_and_top_position() {
712
+ YogaConfig config = YogaConfigFactory.create();
713
+
714
+ final YogaNode root = createNode(config);
715
+ root.setPositionType(YogaPositionType.ABSOLUTE);
716
+ root.setHeight(100f);
717
+ root.setWidth(110f);
718
+ root.setFlexGrow(1f);
719
+ root.setAlignItems(YogaAlign.CENTER);
720
+ root.setJustifyContent(YogaJustify.CENTER);
721
+
722
+ final YogaNode root_child0 = createNode(config);
723
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
724
+ root_child0.setWidth(60f);
725
+ root_child0.setHeight(40f);
726
+ root_child0.setPosition(YogaEdge.TOP, 10f);
727
+ root.addChildAt(root_child0, 0);
728
+ root.setDirection(YogaDirection.LTR);
729
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
730
+
731
+ assertEquals(0f, root.getLayoutX(), 0.0f);
732
+ assertEquals(0f, root.getLayoutY(), 0.0f);
733
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
734
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
735
+
736
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
737
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
738
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
739
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
740
+
741
+ root.setDirection(YogaDirection.RTL);
742
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
743
+
744
+ assertEquals(0f, root.getLayoutX(), 0.0f);
745
+ assertEquals(0f, root.getLayoutY(), 0.0f);
746
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
747
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
748
+
749
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
750
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
751
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
752
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
753
+ }
754
+
755
+ @Test
756
+ public void test_absolute_layout_align_items_and_justify_content_center_and_bottom_position() {
757
+ YogaConfig config = YogaConfigFactory.create();
758
+
759
+ final YogaNode root = createNode(config);
760
+ root.setPositionType(YogaPositionType.ABSOLUTE);
761
+ root.setHeight(100f);
762
+ root.setWidth(110f);
763
+ root.setFlexGrow(1f);
764
+ root.setAlignItems(YogaAlign.CENTER);
765
+ root.setJustifyContent(YogaJustify.CENTER);
766
+
767
+ final YogaNode root_child0 = createNode(config);
768
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
769
+ root_child0.setWidth(60f);
770
+ root_child0.setHeight(40f);
771
+ root_child0.setPosition(YogaEdge.BOTTOM, 10f);
772
+ root.addChildAt(root_child0, 0);
773
+ root.setDirection(YogaDirection.LTR);
774
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
775
+
776
+ assertEquals(0f, root.getLayoutX(), 0.0f);
777
+ assertEquals(0f, root.getLayoutY(), 0.0f);
778
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
779
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
780
+
781
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
782
+ assertEquals(50f, root_child0.getLayoutY(), 0.0f);
783
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
784
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
785
+
786
+ root.setDirection(YogaDirection.RTL);
787
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
788
+
789
+ assertEquals(0f, root.getLayoutX(), 0.0f);
790
+ assertEquals(0f, root.getLayoutY(), 0.0f);
791
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
792
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
793
+
794
+ assertEquals(25f, root_child0.getLayoutX(), 0.0f);
795
+ assertEquals(50f, root_child0.getLayoutY(), 0.0f);
796
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
797
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
798
+ }
799
+
800
+ @Test
801
+ public void test_absolute_layout_align_items_and_justify_content_center_and_left_position() {
802
+ YogaConfig config = YogaConfigFactory.create();
803
+
804
+ final YogaNode root = createNode(config);
805
+ root.setPositionType(YogaPositionType.ABSOLUTE);
806
+ root.setHeight(100f);
807
+ root.setWidth(110f);
808
+ root.setFlexGrow(1f);
809
+ root.setAlignItems(YogaAlign.CENTER);
810
+ root.setJustifyContent(YogaJustify.CENTER);
811
+
812
+ final YogaNode root_child0 = createNode(config);
813
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
814
+ root_child0.setWidth(60f);
815
+ root_child0.setHeight(40f);
816
+ root_child0.setPosition(YogaEdge.LEFT, 5f);
817
+ root.addChildAt(root_child0, 0);
818
+ root.setDirection(YogaDirection.LTR);
819
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
820
+
821
+ assertEquals(0f, root.getLayoutX(), 0.0f);
822
+ assertEquals(0f, root.getLayoutY(), 0.0f);
823
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
824
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
825
+
826
+ assertEquals(5f, root_child0.getLayoutX(), 0.0f);
827
+ assertEquals(30f, root_child0.getLayoutY(), 0.0f);
828
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
829
+ assertEquals(40f, root_child0.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(110f, root.getLayoutWidth(), 0.0f);
837
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
838
+
839
+ assertEquals(5f, root_child0.getLayoutX(), 0.0f);
840
+ assertEquals(30f, root_child0.getLayoutY(), 0.0f);
841
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
842
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
843
+ }
844
+
845
+ @Test
846
+ public void test_absolute_layout_align_items_and_justify_content_center_and_right_position() {
847
+ YogaConfig config = YogaConfigFactory.create();
848
+
849
+ final YogaNode root = createNode(config);
850
+ root.setPositionType(YogaPositionType.ABSOLUTE);
851
+ root.setHeight(100f);
852
+ root.setWidth(110f);
853
+ root.setFlexGrow(1f);
854
+ root.setAlignItems(YogaAlign.CENTER);
855
+ root.setJustifyContent(YogaJustify.CENTER);
856
+
857
+ final YogaNode root_child0 = createNode(config);
858
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
859
+ root_child0.setWidth(60f);
860
+ root_child0.setHeight(40f);
861
+ root_child0.setPosition(YogaEdge.RIGHT, 5f);
862
+ root.addChildAt(root_child0, 0);
863
+ root.setDirection(YogaDirection.LTR);
864
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
865
+
866
+ assertEquals(0f, root.getLayoutX(), 0.0f);
867
+ assertEquals(0f, root.getLayoutY(), 0.0f);
868
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
869
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
870
+
871
+ assertEquals(45f, root_child0.getLayoutX(), 0.0f);
872
+ assertEquals(30f, root_child0.getLayoutY(), 0.0f);
873
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
874
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
875
+
876
+ root.setDirection(YogaDirection.RTL);
877
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
878
+
879
+ assertEquals(0f, root.getLayoutX(), 0.0f);
880
+ assertEquals(0f, root.getLayoutY(), 0.0f);
881
+ assertEquals(110f, root.getLayoutWidth(), 0.0f);
882
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
883
+
884
+ assertEquals(45f, root_child0.getLayoutX(), 0.0f);
885
+ assertEquals(30f, root_child0.getLayoutY(), 0.0f);
886
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
887
+ assertEquals(40f, root_child0.getLayoutHeight(), 0.0f);
888
+ }
889
+
890
+ @Test
891
+ public void test_position_root_with_rtl_should_position_withoutdirection() {
892
+ YogaConfig config = YogaConfigFactory.create();
893
+
894
+ final YogaNode root = createNode(config);
895
+ root.setPositionType(YogaPositionType.ABSOLUTE);
896
+ root.setHeight(52f);
897
+ root.setWidth(52f);
898
+ root.setPosition(YogaEdge.LEFT, 72f);
899
+ root.setDirection(YogaDirection.LTR);
900
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
901
+
902
+ assertEquals(72f, root.getLayoutX(), 0.0f);
903
+ assertEquals(0f, root.getLayoutY(), 0.0f);
904
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
905
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
906
+
907
+ root.setDirection(YogaDirection.RTL);
908
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
909
+
910
+ assertEquals(72f, root.getLayoutX(), 0.0f);
911
+ assertEquals(0f, root.getLayoutY(), 0.0f);
912
+ assertEquals(52f, root.getLayoutWidth(), 0.0f);
913
+ assertEquals(52f, root.getLayoutHeight(), 0.0f);
914
+ }
915
+
916
+ @Test
917
+ public void test_absolute_layout_percentage_bottom_based_on_parent_height() {
918
+ YogaConfig config = YogaConfigFactory.create();
919
+
920
+ final YogaNode root = createNode(config);
921
+ root.setPositionType(YogaPositionType.ABSOLUTE);
922
+ root.setWidth(100f);
923
+ root.setHeight(200f);
924
+
925
+ final YogaNode root_child0 = createNode(config);
926
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
927
+ root_child0.setPositionPercent(YogaEdge.TOP, 50f);
928
+ root_child0.setWidth(10f);
929
+ root_child0.setHeight(10f);
930
+ root.addChildAt(root_child0, 0);
931
+
932
+ final YogaNode root_child1 = createNode(config);
933
+ root_child1.setPositionType(YogaPositionType.ABSOLUTE);
934
+ root_child1.setPositionPercent(YogaEdge.BOTTOM, 50f);
935
+ root_child1.setWidth(10f);
936
+ root_child1.setHeight(10f);
937
+ root.addChildAt(root_child1, 1);
938
+
939
+ final YogaNode root_child2 = createNode(config);
940
+ root_child2.setPositionType(YogaPositionType.ABSOLUTE);
941
+ root_child2.setPositionPercent(YogaEdge.TOP, 10f);
942
+ root_child2.setWidth(10f);
943
+ root_child2.setPositionPercent(YogaEdge.BOTTOM, 10f);
944
+ root.addChildAt(root_child2, 2);
945
+ root.setDirection(YogaDirection.LTR);
946
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
947
+
948
+ assertEquals(0f, root.getLayoutX(), 0.0f);
949
+ assertEquals(0f, root.getLayoutY(), 0.0f);
950
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
951
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
952
+
953
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
954
+ assertEquals(100f, root_child0.getLayoutY(), 0.0f);
955
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
956
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
957
+
958
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
959
+ assertEquals(90f, root_child1.getLayoutY(), 0.0f);
960
+ assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
961
+ assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
962
+
963
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
964
+ assertEquals(20f, root_child2.getLayoutY(), 0.0f);
965
+ assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
966
+ assertEquals(160f, root_child2.getLayoutHeight(), 0.0f);
967
+
968
+ root.setDirection(YogaDirection.RTL);
969
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
970
+
971
+ assertEquals(0f, root.getLayoutX(), 0.0f);
972
+ assertEquals(0f, root.getLayoutY(), 0.0f);
973
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
974
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
975
+
976
+ assertEquals(90f, root_child0.getLayoutX(), 0.0f);
977
+ assertEquals(100f, root_child0.getLayoutY(), 0.0f);
978
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
979
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
980
+
981
+ assertEquals(90f, root_child1.getLayoutX(), 0.0f);
982
+ assertEquals(90f, root_child1.getLayoutY(), 0.0f);
983
+ assertEquals(10f, root_child1.getLayoutWidth(), 0.0f);
984
+ assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
985
+
986
+ assertEquals(90f, root_child2.getLayoutX(), 0.0f);
987
+ assertEquals(20f, root_child2.getLayoutY(), 0.0f);
988
+ assertEquals(10f, root_child2.getLayoutWidth(), 0.0f);
989
+ assertEquals(160f, root_child2.getLayoutHeight(), 0.0f);
990
+ }
991
+
992
+ @Test
993
+ public void test_absolute_layout_in_wrap_reverse_column_container() {
994
+ YogaConfig config = YogaConfigFactory.create();
995
+
996
+ final YogaNode root = createNode(config);
997
+ root.setPositionType(YogaPositionType.ABSOLUTE);
998
+ root.setWidth(100f);
999
+ root.setHeight(100f);
1000
+ root.setWrap(YogaWrap.WRAP_REVERSE);
1001
+
1002
+ final YogaNode root_child0 = createNode(config);
1003
+ root_child0.setWidth(20f);
1004
+ root_child0.setHeight(20f);
1005
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1006
+ root.addChildAt(root_child0, 0);
1007
+ root.setDirection(YogaDirection.LTR);
1008
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1009
+
1010
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1011
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1012
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1013
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1014
+
1015
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1016
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1017
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1018
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1019
+
1020
+ root.setDirection(YogaDirection.RTL);
1021
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1022
+
1023
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1024
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1025
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1026
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1027
+
1028
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1029
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1030
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1031
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1032
+ }
1033
+
1034
+ @Test
1035
+ public void test_absolute_layout_in_wrap_reverse_row_container() {
1036
+ YogaConfig config = YogaConfigFactory.create();
1037
+
1038
+ final YogaNode root = createNode(config);
1039
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1040
+ root.setFlexDirection(YogaFlexDirection.ROW);
1041
+ root.setWidth(100f);
1042
+ root.setHeight(100f);
1043
+ root.setWrap(YogaWrap.WRAP_REVERSE);
1044
+
1045
+ final YogaNode root_child0 = createNode(config);
1046
+ root_child0.setWidth(20f);
1047
+ root_child0.setHeight(20f);
1048
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1049
+ root.addChildAt(root_child0, 0);
1050
+ root.setDirection(YogaDirection.LTR);
1051
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1052
+
1053
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1054
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1055
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1056
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1057
+
1058
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1059
+ assertEquals(80f, root_child0.getLayoutY(), 0.0f);
1060
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1061
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1062
+
1063
+ root.setDirection(YogaDirection.RTL);
1064
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1065
+
1066
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1067
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1068
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1069
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1070
+
1071
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1072
+ assertEquals(80f, root_child0.getLayoutY(), 0.0f);
1073
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1074
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1075
+ }
1076
+
1077
+ @Test
1078
+ public void test_absolute_layout_in_wrap_reverse_column_container_flex_end() {
1079
+ YogaConfig config = YogaConfigFactory.create();
1080
+
1081
+ final YogaNode root = createNode(config);
1082
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1083
+ root.setWidth(100f);
1084
+ root.setHeight(100f);
1085
+ root.setWrap(YogaWrap.WRAP_REVERSE);
1086
+
1087
+ final YogaNode root_child0 = createNode(config);
1088
+ root_child0.setWidth(20f);
1089
+ root_child0.setHeight(20f);
1090
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1091
+ root_child0.setAlignSelf(YogaAlign.FLEX_END);
1092
+ root.addChildAt(root_child0, 0);
1093
+ root.setDirection(YogaDirection.LTR);
1094
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1095
+
1096
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1097
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1098
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1099
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1100
+
1101
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1102
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1103
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1104
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1105
+
1106
+ root.setDirection(YogaDirection.RTL);
1107
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1108
+
1109
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1110
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1111
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1112
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1113
+
1114
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1115
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1116
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1117
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1118
+ }
1119
+
1120
+ @Test
1121
+ public void test_absolute_layout_in_wrap_reverse_row_container_flex_end() {
1122
+ YogaConfig config = YogaConfigFactory.create();
1123
+
1124
+ final YogaNode root = createNode(config);
1125
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1126
+ root.setFlexDirection(YogaFlexDirection.ROW);
1127
+ root.setWidth(100f);
1128
+ root.setHeight(100f);
1129
+ root.setWrap(YogaWrap.WRAP_REVERSE);
1130
+
1131
+ final YogaNode root_child0 = createNode(config);
1132
+ root_child0.setWidth(20f);
1133
+ root_child0.setHeight(20f);
1134
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1135
+ root_child0.setAlignSelf(YogaAlign.FLEX_END);
1136
+ root.addChildAt(root_child0, 0);
1137
+ root.setDirection(YogaDirection.LTR);
1138
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1139
+
1140
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1141
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1142
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1143
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1144
+
1145
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1146
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1147
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1148
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1149
+
1150
+ root.setDirection(YogaDirection.RTL);
1151
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1152
+
1153
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1154
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1155
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1156
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1157
+
1158
+ assertEquals(80f, root_child0.getLayoutX(), 0.0f);
1159
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1160
+ assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
1161
+ assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
1162
+ }
1163
+
1164
+ @Test
1165
+ public void test_percent_absolute_position_infinite_height() {
1166
+ YogaConfig config = YogaConfigFactory.create();
1167
+
1168
+ final YogaNode root = createNode(config);
1169
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1170
+ root.setWidth(300f);
1171
+
1172
+ final YogaNode root_child0 = createNode(config);
1173
+ root_child0.setWidth(300f);
1174
+ root.addChildAt(root_child0, 0);
1175
+
1176
+ final YogaNode root_child1 = createNode(config);
1177
+ root_child1.setWidthPercent(20f);
1178
+ root_child1.setHeightPercent(20f);
1179
+ root_child1.setPositionPercent(YogaEdge.LEFT, 20f);
1180
+ root_child1.setPositionPercent(YogaEdge.TOP, 20f);
1181
+ root_child1.setPositionType(YogaPositionType.ABSOLUTE);
1182
+ root.addChildAt(root_child1, 1);
1183
+ root.setDirection(YogaDirection.LTR);
1184
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1185
+
1186
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1187
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1188
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
1189
+ assertEquals(0f, root.getLayoutHeight(), 0.0f);
1190
+
1191
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1192
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1193
+ assertEquals(300f, root_child0.getLayoutWidth(), 0.0f);
1194
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1195
+
1196
+ assertEquals(60f, root_child1.getLayoutX(), 0.0f);
1197
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1198
+ assertEquals(60f, root_child1.getLayoutWidth(), 0.0f);
1199
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
1200
+
1201
+ root.setDirection(YogaDirection.RTL);
1202
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1203
+
1204
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1205
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1206
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
1207
+ assertEquals(0f, root.getLayoutHeight(), 0.0f);
1208
+
1209
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1210
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1211
+ assertEquals(300f, root_child0.getLayoutWidth(), 0.0f);
1212
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
1213
+
1214
+ assertEquals(60f, root_child1.getLayoutX(), 0.0f);
1215
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1216
+ assertEquals(60f, root_child1.getLayoutWidth(), 0.0f);
1217
+ assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
1218
+ }
1219
+
1220
+ @Test
1221
+ public void test_absolute_layout_percentage_height_based_on_padded_parent() {
1222
+ YogaConfig config = YogaConfigFactory.create();
1223
+
1224
+ final YogaNode root = createNode(config);
1225
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1226
+ root.setWidth(100f);
1227
+ root.setHeight(100f);
1228
+ root.setPadding(YogaEdge.TOP, 10);
1229
+ root.setBorder(YogaEdge.TOP, 10f);
1230
+
1231
+ final YogaNode root_child0 = createNode(config);
1232
+ root_child0.setWidth(100f);
1233
+ root_child0.setHeightPercent(50f);
1234
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1235
+ root.addChildAt(root_child0, 0);
1236
+ root.setDirection(YogaDirection.LTR);
1237
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1238
+
1239
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1240
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1241
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1242
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1243
+
1244
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1245
+ assertEquals(20f, root_child0.getLayoutY(), 0.0f);
1246
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
1247
+ assertEquals(45f, root_child0.getLayoutHeight(), 0.0f);
1248
+
1249
+ root.setDirection(YogaDirection.RTL);
1250
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1251
+
1252
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1253
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1254
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1255
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1256
+
1257
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1258
+ assertEquals(20f, root_child0.getLayoutY(), 0.0f);
1259
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
1260
+ assertEquals(45f, root_child0.getLayoutHeight(), 0.0f);
1261
+ }
1262
+
1263
+ @Test
1264
+ public void test_absolute_layout_percentage_height_based_on_padded_parent_and_align_items_center() {
1265
+ YogaConfig config = YogaConfigFactory.create();
1266
+
1267
+ final YogaNode root = createNode(config);
1268
+ root.setAlignItems(YogaAlign.CENTER);
1269
+ root.setJustifyContent(YogaJustify.CENTER);
1270
+ root.setWidth(100f);
1271
+ root.setHeight(100f);
1272
+ root.setPadding(YogaEdge.TOP, 20);
1273
+ root.setPadding(YogaEdge.BOTTOM, 20);
1274
+
1275
+ final YogaNode root_child0 = createNode(config);
1276
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1277
+ root_child0.setWidth(100f);
1278
+ root_child0.setHeightPercent(50f);
1279
+ root.addChildAt(root_child0, 0);
1280
+ root.setDirection(YogaDirection.LTR);
1281
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1282
+
1283
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1284
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1285
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1286
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1287
+
1288
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1289
+ assertEquals(25f, root_child0.getLayoutY(), 0.0f);
1290
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
1291
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1292
+
1293
+ root.setDirection(YogaDirection.RTL);
1294
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1295
+
1296
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1297
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1298
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
1299
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
1300
+
1301
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1302
+ assertEquals(25f, root_child0.getLayoutY(), 0.0f);
1303
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
1304
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1305
+ }
1306
+
1307
+ @Test
1308
+ public void test_absolute_layout_padding_left() {
1309
+ YogaConfig config = YogaConfigFactory.create();
1310
+
1311
+ final YogaNode root = createNode(config);
1312
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1313
+ root.setWidth(200f);
1314
+ root.setHeight(200f);
1315
+ root.setPadding(YogaEdge.LEFT, 100);
1316
+
1317
+ final YogaNode root_child0 = createNode(config);
1318
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1319
+ root_child0.setWidth(50f);
1320
+ root_child0.setHeight(50f);
1321
+ root.addChildAt(root_child0, 0);
1322
+ root.setDirection(YogaDirection.LTR);
1323
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1324
+
1325
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1326
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1327
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1328
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1329
+
1330
+ assertEquals(100f, root_child0.getLayoutX(), 0.0f);
1331
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1332
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1333
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1334
+
1335
+ root.setDirection(YogaDirection.RTL);
1336
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1337
+
1338
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1339
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1340
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1341
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1342
+
1343
+ assertEquals(150f, root_child0.getLayoutX(), 0.0f);
1344
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1345
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1346
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1347
+ }
1348
+
1349
+ @Test
1350
+ public void test_absolute_layout_padding_right() {
1351
+ YogaConfig config = YogaConfigFactory.create();
1352
+
1353
+ final YogaNode root = createNode(config);
1354
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1355
+ root.setWidth(200f);
1356
+ root.setHeight(200f);
1357
+ root.setPadding(YogaEdge.RIGHT, 100);
1358
+
1359
+ final YogaNode root_child0 = createNode(config);
1360
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1361
+ root_child0.setWidth(50f);
1362
+ root_child0.setHeight(50f);
1363
+ root.addChildAt(root_child0, 0);
1364
+ root.setDirection(YogaDirection.LTR);
1365
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1366
+
1367
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1368
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1369
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1370
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1371
+
1372
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1373
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1374
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1375
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1376
+
1377
+ root.setDirection(YogaDirection.RTL);
1378
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1379
+
1380
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1381
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1382
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1383
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1384
+
1385
+ assertEquals(50f, root_child0.getLayoutX(), 0.0f);
1386
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1387
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1388
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1389
+ }
1390
+
1391
+ @Test
1392
+ public void test_absolute_layout_padding_top() {
1393
+ YogaConfig config = YogaConfigFactory.create();
1394
+
1395
+ final YogaNode root = createNode(config);
1396
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1397
+ root.setWidth(200f);
1398
+ root.setHeight(200f);
1399
+ root.setPadding(YogaEdge.TOP, 100);
1400
+
1401
+ final YogaNode root_child0 = createNode(config);
1402
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1403
+ root_child0.setWidth(50f);
1404
+ root_child0.setHeight(50f);
1405
+ root.addChildAt(root_child0, 0);
1406
+ root.setDirection(YogaDirection.LTR);
1407
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1408
+
1409
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1410
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1411
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1412
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1413
+
1414
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1415
+ assertEquals(100f, root_child0.getLayoutY(), 0.0f);
1416
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1417
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1418
+
1419
+ root.setDirection(YogaDirection.RTL);
1420
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1421
+
1422
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1423
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1424
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1425
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1426
+
1427
+ assertEquals(150f, root_child0.getLayoutX(), 0.0f);
1428
+ assertEquals(100f, root_child0.getLayoutY(), 0.0f);
1429
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1430
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1431
+ }
1432
+
1433
+ @Test
1434
+ public void test_absolute_layout_padding_bottom() {
1435
+ YogaConfig config = YogaConfigFactory.create();
1436
+
1437
+ final YogaNode root = createNode(config);
1438
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1439
+ root.setWidth(200f);
1440
+ root.setHeight(200f);
1441
+ root.setPadding(YogaEdge.BOTTOM, 100);
1442
+
1443
+ final YogaNode root_child0 = createNode(config);
1444
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1445
+ root_child0.setWidth(50f);
1446
+ root_child0.setHeight(50f);
1447
+ root.addChildAt(root_child0, 0);
1448
+ root.setDirection(YogaDirection.LTR);
1449
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1450
+
1451
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1452
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1453
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1454
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1455
+
1456
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1457
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1458
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1459
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1460
+
1461
+ root.setDirection(YogaDirection.RTL);
1462
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1463
+
1464
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1465
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1466
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1467
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1468
+
1469
+ assertEquals(150f, root_child0.getLayoutX(), 0.0f);
1470
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1471
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1472
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1473
+ }
1474
+
1475
+ @Test
1476
+ public void test_absolute_layout_padding() {
1477
+ YogaConfig config = YogaConfigFactory.create();
1478
+
1479
+ final YogaNode root = createNode(config);
1480
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1481
+
1482
+ final YogaNode root_child0 = createNode(config);
1483
+ root_child0.setWidth(200f);
1484
+ root_child0.setHeight(200f);
1485
+ root_child0.setMargin(YogaEdge.ALL, 10f);
1486
+ root.addChildAt(root_child0, 0);
1487
+
1488
+ final YogaNode root_child0_child0 = createNode(config);
1489
+ root_child0_child0.setPositionType(YogaPositionType.STATIC);
1490
+ root_child0_child0.setWidth(200f);
1491
+ root_child0_child0.setHeight(200f);
1492
+ root_child0_child0.setPadding(YogaEdge.ALL, 50);
1493
+ root_child0.addChildAt(root_child0_child0, 0);
1494
+
1495
+ final YogaNode root_child0_child0_child0 = createNode(config);
1496
+ root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
1497
+ root_child0_child0_child0.setWidth(50f);
1498
+ root_child0_child0_child0.setHeight(50f);
1499
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
1500
+ root.setDirection(YogaDirection.LTR);
1501
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1502
+
1503
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1504
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1505
+ assertEquals(220f, root.getLayoutWidth(), 0.0f);
1506
+ assertEquals(220f, root.getLayoutHeight(), 0.0f);
1507
+
1508
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
1509
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
1510
+ assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
1511
+ assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
1512
+
1513
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1514
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1515
+ assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
1516
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
1517
+
1518
+ assertEquals(50f, root_child0_child0_child0.getLayoutX(), 0.0f);
1519
+ assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
1520
+ assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1521
+ assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1522
+
1523
+ root.setDirection(YogaDirection.RTL);
1524
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1525
+
1526
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1527
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1528
+ assertEquals(220f, root.getLayoutWidth(), 0.0f);
1529
+ assertEquals(220f, root.getLayoutHeight(), 0.0f);
1530
+
1531
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
1532
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
1533
+ assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
1534
+ assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
1535
+
1536
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1537
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1538
+ assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
1539
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
1540
+
1541
+ assertEquals(100f, root_child0_child0_child0.getLayoutX(), 0.0f);
1542
+ assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
1543
+ assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1544
+ assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1545
+ }
1546
+
1547
+ @Test
1548
+ public void test_absolute_layout_border() {
1549
+ YogaConfig config = YogaConfigFactory.create();
1550
+
1551
+ final YogaNode root = createNode(config);
1552
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1553
+
1554
+ final YogaNode root_child0 = createNode(config);
1555
+ root_child0.setWidth(200f);
1556
+ root_child0.setHeight(200f);
1557
+ root_child0.setMargin(YogaEdge.ALL, 10f);
1558
+ root.addChildAt(root_child0, 0);
1559
+
1560
+ final YogaNode root_child0_child0 = createNode(config);
1561
+ root_child0_child0.setPositionType(YogaPositionType.STATIC);
1562
+ root_child0_child0.setWidth(200f);
1563
+ root_child0_child0.setHeight(200f);
1564
+ root_child0_child0.setBorder(YogaEdge.ALL, 10f);
1565
+ root_child0.addChildAt(root_child0_child0, 0);
1566
+
1567
+ final YogaNode root_child0_child0_child0 = createNode(config);
1568
+ root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
1569
+ root_child0_child0_child0.setWidth(50f);
1570
+ root_child0_child0_child0.setHeight(50f);
1571
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
1572
+ root.setDirection(YogaDirection.LTR);
1573
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1574
+
1575
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1576
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1577
+ assertEquals(220f, root.getLayoutWidth(), 0.0f);
1578
+ assertEquals(220f, root.getLayoutHeight(), 0.0f);
1579
+
1580
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
1581
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
1582
+ assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
1583
+ assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
1584
+
1585
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1586
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1587
+ assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
1588
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
1589
+
1590
+ assertEquals(10f, root_child0_child0_child0.getLayoutX(), 0.0f);
1591
+ assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
1592
+ assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1593
+ assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1594
+
1595
+ root.setDirection(YogaDirection.RTL);
1596
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1597
+
1598
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1599
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1600
+ assertEquals(220f, root.getLayoutWidth(), 0.0f);
1601
+ assertEquals(220f, root.getLayoutHeight(), 0.0f);
1602
+
1603
+ assertEquals(10f, root_child0.getLayoutX(), 0.0f);
1604
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
1605
+ assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
1606
+ assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
1607
+
1608
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
1609
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
1610
+ assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
1611
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
1612
+
1613
+ assertEquals(140f, root_child0_child0_child0.getLayoutX(), 0.0f);
1614
+ assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
1615
+ assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
1616
+ assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
1617
+ }
1618
+
1619
+ @Test
1620
+ public void test_absolute_layout_column_reverse_margin_border() {
1621
+ YogaConfig config = YogaConfigFactory.create();
1622
+
1623
+ final YogaNode root = createNode(config);
1624
+ root.setPositionType(YogaPositionType.ABSOLUTE);
1625
+ root.setWidth(200f);
1626
+ root.setHeight(200f);
1627
+ root.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE);
1628
+
1629
+ final YogaNode root_child0 = createNode(config);
1630
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
1631
+ root_child0.setWidth(50f);
1632
+ root_child0.setHeight(50f);
1633
+ root_child0.setPosition(YogaEdge.LEFT, 5f);
1634
+ root_child0.setPosition(YogaEdge.RIGHT, 3f);
1635
+ root_child0.setMargin(YogaEdge.RIGHT, 4f);
1636
+ root_child0.setMargin(YogaEdge.LEFT, 3f);
1637
+ root_child0.setBorder(YogaEdge.RIGHT, 7f);
1638
+ root_child0.setBorder(YogaEdge.LEFT, 1f);
1639
+ root.addChildAt(root_child0, 0);
1640
+ root.setDirection(YogaDirection.LTR);
1641
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1642
+
1643
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1644
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1645
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1646
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1647
+
1648
+ assertEquals(8f, root_child0.getLayoutX(), 0.0f);
1649
+ assertEquals(150f, root_child0.getLayoutY(), 0.0f);
1650
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1651
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1652
+
1653
+ root.setDirection(YogaDirection.RTL);
1654
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1655
+
1656
+ assertEquals(0f, root.getLayoutX(), 0.0f);
1657
+ assertEquals(0f, root.getLayoutY(), 0.0f);
1658
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
1659
+ assertEquals(200f, root.getLayoutHeight(), 0.0f);
1660
+
1661
+ assertEquals(143f, root_child0.getLayoutX(), 0.0f);
1662
+ assertEquals(150f, root_child0.getLayoutY(), 0.0f);
1663
+ assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
1664
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
1665
+ }
1666
+
1667
+ private YogaNode createNode(YogaConfig config) {
1668
+ return mNodeFactory.create(config);
1669
+ }
1670
+ }