From e696b8c456ce3ad8816151447148b095e7d0e64b Mon Sep 17 00:00:00 2001 From: Alan Lee Date: Thu, 24 Oct 2024 13:34:03 -0700 Subject: [PATCH 1/2] Bump to Gradle 8.9, AGP 8.7.1 and NDK 27 Summary: Bumping Gradle to 8.9 and NDK to 27.1.12297006 in prep to build native libraries with 16KB page size support See: - Changelog r27: https://github.com/android/ndk/wiki/Changelog-r27 - 16KB page sizes: https://developer.android.com/guide/practices/page-sizes Changelog: [Android][Updated] - Bump Gradle to 8.9, AGP to 8.7.1 and NDK to 27 Reviewed By: cortinico Differential Revision: D64381441 fbshipit-source-id: 5e4236c166568a3990deabfd628f0f34e52ea855 --- build.gradle | 4 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- java/build.gradle.kts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 63448f10..3dec0644 100644 --- a/build.gradle +++ b/build.gradle @@ -6,8 +6,8 @@ */ plugins { - id("com.android.library") version "8.2.1" apply false - id("com.android.application") version "8.2.1" apply false + id("com.android.library") version "8.7.1" apply false + id("com.android.application") version "8.7.1" apply false id("io.github.gradle-nexus.publish-plugin") version "1.3.0" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 03bc5150..c5a661c9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/java/build.gradle.kts b/java/build.gradle.kts index 5459f341..44e476e2 100644 --- a/java/build.gradle.kts +++ b/java/build.gradle.kts @@ -23,7 +23,7 @@ android { namespace = "com.facebook.yoga" compileSdk = 35 buildToolsVersion = "35.0.0" - ndkVersion = "26.0.10792818" + ndkVersion = "27.1.12297006" defaultConfig { minSdk = 21 -- 2.50.1.windows.1 From e9bb3270b3b3bba1809b7629941b007b83323fd2 Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Fri, 25 Oct 2024 10:07:25 +0200 Subject: [PATCH 2/2] Add tests for `LayoutableChildren` --- tests/YGLayoutableChildrenTest.cpp | 191 +++++++++++++++++++++++++++++ yoga/node/LayoutableChildren.h | 1 + 2 files changed, 192 insertions(+) create mode 100644 tests/YGLayoutableChildrenTest.cpp diff --git a/tests/YGLayoutableChildrenTest.cpp b/tests/YGLayoutableChildrenTest.cpp new file mode 100644 index 00000000..1a3a3f60 --- /dev/null +++ b/tests/YGLayoutableChildrenTest.cpp @@ -0,0 +1,191 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#include +#include +#include +#include + +TEST(YogaTest, layoutable_children_single_contents_node) { + YGNodeRef root = YGNodeNew(); + + YGNodeRef root_child0 = YGNodeNew(); + YGNodeRef root_child1 = YGNodeNew(); + YGNodeRef root_child2 = YGNodeNew(); + + YGNodeRef root_grandchild0 = YGNodeNew(); + YGNodeRef root_grandchild1 = YGNodeNew(); + + YGNodeInsertChild(root, root_child0, 0); + YGNodeInsertChild(root, root_child1, 1); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeInsertChild(root_child1, root_grandchild0, 0); + YGNodeInsertChild(root_child1, root_grandchild1, 1); + + YGNodeStyleSetDisplay(root_child1, YGDisplayContents); + + std::vector order = { + facebook::yoga::resolveRef(root_child0), + facebook::yoga::resolveRef(root_grandchild0), + facebook::yoga::resolveRef(root_grandchild1), + facebook::yoga::resolveRef(root_child2), + }; + auto correctOrderIt = order.begin(); + + for (auto node : facebook::yoga::resolveRef(root)->getLayoutChildren()) { + ASSERT_EQ(node, *correctOrderIt); + correctOrderIt++; + } + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, layoutable_children_multiple_contents_nodes) { + YGNodeRef root = YGNodeNew(); + + YGNodeRef root_child0 = YGNodeNew(); + YGNodeRef root_child1 = YGNodeNew(); + YGNodeRef root_child2 = YGNodeNew(); + + YGNodeRef root_grandchild0 = YGNodeNew(); + YGNodeRef root_grandchild1 = YGNodeNew(); + YGNodeRef root_grandchild2 = YGNodeNew(); + YGNodeRef root_grandchild3 = YGNodeNew(); + YGNodeRef root_grandchild4 = YGNodeNew(); + YGNodeRef root_grandchild5 = YGNodeNew(); + + YGNodeInsertChild(root, root_child0, 0); + YGNodeInsertChild(root, root_child1, 1); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeInsertChild(root_child0, root_grandchild0, 0); + YGNodeInsertChild(root_child0, root_grandchild1, 1); + YGNodeInsertChild(root_child1, root_grandchild2, 0); + YGNodeInsertChild(root_child1, root_grandchild3, 1); + YGNodeInsertChild(root_child2, root_grandchild4, 0); + YGNodeInsertChild(root_child2, root_grandchild5, 1); + + YGNodeStyleSetDisplay(root_child0, YGDisplayContents); + YGNodeStyleSetDisplay(root_child1, YGDisplayContents); + YGNodeStyleSetDisplay(root_child2, YGDisplayContents); + + std::vector order = { + facebook::yoga::resolveRef(root_grandchild0), + facebook::yoga::resolveRef(root_grandchild1), + facebook::yoga::resolveRef(root_grandchild2), + facebook::yoga::resolveRef(root_grandchild3), + facebook::yoga::resolveRef(root_grandchild4), + facebook::yoga::resolveRef(root_grandchild5), + }; + auto correctOrderIt = order.begin(); + + for (auto node : facebook::yoga::resolveRef(root)->getLayoutChildren()) { + ASSERT_EQ(node, *correctOrderIt); + correctOrderIt++; + } + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, layoutable_children_nested_contents_nodes) { + YGNodeRef root = YGNodeNew(); + + YGNodeRef root_child0 = YGNodeNew(); + YGNodeRef root_child1 = YGNodeNew(); + YGNodeRef root_child2 = YGNodeNew(); + + YGNodeRef root_grandchild0 = YGNodeNew(); + YGNodeRef root_grandchild1 = YGNodeNew(); + + YGNodeRef root_great_grandchild0 = YGNodeNew(); + YGNodeRef root_great_grandchild1 = YGNodeNew(); + + YGNodeInsertChild(root, root_child0, 0); + YGNodeInsertChild(root, root_child1, 1); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeInsertChild(root_child1, root_grandchild0, 0); + YGNodeInsertChild(root_child1, root_grandchild1, 1); + + YGNodeInsertChild(root_grandchild1, root_great_grandchild0, 0); + YGNodeInsertChild(root_grandchild1, root_great_grandchild1, 1); + + YGNodeStyleSetDisplay(root_child1, YGDisplayContents); + YGNodeStyleSetDisplay(root_grandchild1, YGDisplayContents); + + std::vector order = { + facebook::yoga::resolveRef(root_child0), + facebook::yoga::resolveRef(root_grandchild0), + facebook::yoga::resolveRef(root_great_grandchild0), + facebook::yoga::resolveRef(root_great_grandchild1), + facebook::yoga::resolveRef(root_child2), + }; + auto correctOrderIt = order.begin(); + + for (auto node : facebook::yoga::resolveRef(root)->getLayoutChildren()) { + ASSERT_EQ(node, *correctOrderIt); + correctOrderIt++; + } + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, layoutable_children_contents_leaf_node) { + YGNodeRef root = YGNodeNew(); + + YGNodeRef root_child0 = YGNodeNew(); + YGNodeRef root_child1 = YGNodeNew(); + YGNodeRef root_child2 = YGNodeNew(); + + YGNodeInsertChild(root, root_child0, 0); + YGNodeInsertChild(root, root_child1, 1); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeStyleSetDisplay(root_child1, YGDisplayContents); + + std::vector order = { + facebook::yoga::resolveRef(root_child0), + facebook::yoga::resolveRef(root_child2), + }; + auto correctOrderIt = order.begin(); + + for (auto node : facebook::yoga::resolveRef(root)->getLayoutChildren()) { + ASSERT_EQ(node, *correctOrderIt); + correctOrderIt++; + } + + YGNodeFreeRecursive(root); +} + +TEST(YogaTest, layoutable_children_contents_root_node) { + YGNodeRef root = YGNodeNew(); + + YGNodeRef root_child0 = YGNodeNew(); + YGNodeRef root_child1 = YGNodeNew(); + YGNodeRef root_child2 = YGNodeNew(); + + YGNodeInsertChild(root, root_child0, 0); + YGNodeInsertChild(root, root_child1, 1); + YGNodeInsertChild(root, root_child2, 2); + + YGNodeStyleSetDisplay(root, YGDisplayContents); + + std::vector order = { + facebook::yoga::resolveRef(root_child0), + facebook::yoga::resolveRef(root_child1), + facebook::yoga::resolveRef(root_child2), + }; + auto correctOrderIt = order.begin(); + + for (auto node : facebook::yoga::resolveRef(root)->getLayoutChildren()) { + ASSERT_EQ(node, *correctOrderIt); + correctOrderIt++; + } + + YGNodeFreeRecursive(root); +} diff --git a/yoga/node/LayoutableChildren.h b/yoga/node/LayoutableChildren.h index c8300be3..7d5598fb 100644 --- a/yoga/node/LayoutableChildren.h +++ b/yoga/node/LayoutableChildren.h @@ -4,6 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ +#pragma once #include #include -- 2.50.1.windows.1