Compare commits

..

14 Commits

Author SHA1 Message Date
Nick Gerleman
ed5d2ffc2d Set version to 3.0.3 2024-04-09 16:13:40 -07:00
Willson Haw
8a9758a2cc Add JavaScript bindings for YGHasNewLayout (#1631)
Summary:
Adds JavaScript bindings for YGHasNewLayout which introduces
two new node methods: `hasNewLayout()` and `markLayoutSeen()`.

Closes https://github.com/facebook/yoga/issues/681

Pull Request resolved: https://github.com/facebook/yoga/pull/1631

Reviewed By: joevilches

Differential Revision: D55213296

Pulled By: NickGerleman

fbshipit-source-id: 161288c3f54c2b82a6b2b842387916fe8713c2c9
2024-04-09 16:04:35 -07:00
Bela Bohlender
334eebc484 Entry point without TLA for js package (#1638)
Summary:
Follow up on https://github.com/facebook/yoga/issues/1637

TLDR: tooling for TLA is not there yet; An additional entry point without top-level-await is appropriate

- adds ./load entry to js package
- uses .js file extensions to prevent requiring [allowImportingTsExtensions](https://www.typescriptlang.org/tsconfig#allowImportingTsExtensions)

Pull Request resolved: https://github.com/facebook/yoga/pull/1638

Reviewed By: joevilches

Differential Revision: D55614636

Pulled By: NickGerleman

fbshipit-source-id: 126a94aa68d22d32b938282cfa1a5059bb9df337
2024-04-09 16:03:21 -07:00
Nick Gerleman
5b106e5dd5 Bump README 2024-04-03 20:28:56 -07:00
Nick Gerleman
397d304e14 Set version to 3.0.2 2024-03-12 22:19:15 -07:00
Nick Gerleman
95cf06543f typings -> types 2024-03-12 22:17:59 -07:00
Nick Gerleman
17450191c3 Set version to 3.0.1 2024-03-12 22:07:12 -07:00
Nick Gerleman
75e564d0d5 Fixup npm package README
Summary: Remove some outdated information and make sure that npmjs shows the builtin TypeScript typings (now that we no longer have clever resolution schemes).

Reviewed By: javache

Differential Revision: D54788636

fbshipit-source-id: 76e7663924189fd68ac62b27730f44213b13ad85
2024-03-12 22:06:24 -07:00
Joe Vilches
e82479e4ca Fix bug where absolute nodes were not insetted correctly in certain cases (#1593)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1593

X-link: https://github.com/facebook/react-native/pull/43417

There was a bug where we did not position absolute nodes correctly if the static node had a different main/cross axis from the containing node. This fixes that. The change is somewhat complicated unfortunately but I tried to add sufficient comments to explain what is happening

Reviewed By: NickGerleman

Differential Revision: D54703955

fbshipit-source-id: 096c643f61d4f9bb3ee6278d675ebd69b57350d7
2024-03-12 22:06:06 -07:00
Nick Gerleman
508b9a57fe Reduce warning level of distributed Yoga builds (#1592)
Summary:
X-link: https://github.com/facebook/react-native/pull/43405
Pull Request resolved: https://github.com/facebook/yoga/pull/1592

Fixes https://github.com/facebook/yoga/issues/1590

Yoga may be built with a high warning level. This is helpful in letting Yoga be used in more places, and finding defects. We currently set these in the internal BUCK build, the CMake reference build, and the Yoga Standalone (not RN) CocoaPods build.

Yoga's reference CMake build and spec are consumed today by users of Yoga, instead of just Yoga developers. Here, it makes more sense to avoid anything that could break compiler-to-compiler compatibility.

We default these to a less intense (`-Wall -Werror`). I kept `/W4`, for pragmatic reasons, and since it is relatively standard for MSVC.

We continue to build with strict flags on Buck build on Clang.

Reviewed By: cortinico

Differential Revision: D54735661

fbshipit-source-id: 130e35ac9dcffa2f7e70e48d18770f1275864e2a
2024-03-12 22:05:47 -07:00
Nick Gerleman
749b6b2bf8 Run CocoaPods publish on Mac VM 2024-03-05 16:06:47 -08:00
Nick Gerleman
fe7dc21eb1 Set version to 3.0.0 2024-03-05 15:59:59 -08:00
Riccardo Cipolleschi
59fb251edc Fix MacCatalyst archiving for stand-alone pod (#1585)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1585

When used alone, yoga has no visibility over the USE_FRAMEWORKS variable set by React Native.

In this case, there is no other way to know whether the current target that will install the spec is using use_framewors or not. As a failsafe, condition, let's always add the `"$(PODS_TARGET_SRCROOT)"` to the search paths to make sure that archiving won't fail.

Whe used in other context, that should not be a problem: search paths are just directory Xcode uses to find headers that are needed.

Reviewed By: NickGerleman

Differential Revision: D54417386

fbshipit-source-id: aa2ae41c077e4346c0417c73291a37c992a06b58
2024-03-05 15:56:01 -08:00
Kesha Antonov
efbebb4a97 Update Yoga.podspec: fixes archiving for Mac Catalyst
Summary:
Hi

When I tried to archive macos catalyst app in Xcode I got errors:

<img width="977" alt="Screenshot 2024-02-05 at 00 03 32" src="https://github.com/kesha-antonov/react-native/assets/11584712/b83f75a5-b42f-42e4-9afa-1e2527501baa">

This PR fixes archiving by linking PrivateHeaders in yoga.framework

<img width="399" alt="Screenshot 2024-02-05 at 01 03 48" src="https://github.com/kesha-antonov/react-native/assets/11584712/089080ad-b1dc-4703-9273-d8aa3253205e">

<img width="1404" alt="Screenshot 2024-02-05 at 01 05 18" src="https://github.com/kesha-antonov/react-native/assets/11584712/5263cb80-8a53-4a51-bcfc-9d3a2ba739b4">

Prev PR here https://github.com/facebook/react-native/pull/42159

## Changelog:

[IOS] [FIXED] - fixed archiving for Mac Catalyst

X-link: https://github.com/facebook/react-native/pull/42847

Reviewed By: NickGerleman

Differential Revision: D53920474

Pulled By: cipolleschi

fbshipit-source-id: 0534d9aa9d249e4e0c35ada0464c38c291be7f84
2024-02-22 21:27:59 -08:00
403 changed files with 32038 additions and 52980 deletions

View File

@@ -1,217 +0,0 @@
---
InheritParentConfig: true
Checks: '>
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-bool-pointer-implicit-conversion,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-exception-escape,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-forwarding-reference-overload,
bugprone-incorrect-enable-if,
bugprone-inaccurate-erase,
bugprone-incorrect-roundings,
bugprone-infinite-loop,
bugprone-integer-division,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multiple-statement-macro,
bugprone-optional-value-conversion,
bugprone-parent-virtual-call,
bugprone-redundant-branch-condition,
bugprone-shared-ptr-array-mismatch,
bugprone-signed-char-misuse,
bugprone-sizeof-container,
bugprone-sizeof-expression,
bugprone-string-constructor,
bugprone-string-integer-assignment,
bugprone-string-literal-with-embedded-nul,
bugprone-suspicious-enum-usage,
bugprone-suspicious-memset-usage,
bugprone-suspicious-missing-comma,
bugprone-suspicious-semicolon,
bugprone-suspicious-string-compare,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unique-ptr-array-mismatch,
bugprone-unsafe-functions,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
bugprone-virtual-near-miss,
clang-analyzer-apiModeling.google.GTest,
clang-analyzer-apiModeling.StdCLibraryFunctions,
clang-analyzer-apiModeling.TrustNonnull,
clang-analyzer-core.builtin.BuiltinFunctions,
clang-analyzer-core.builtin.NoReturnFunctions,
clang-analyzer-core.CallAndMessage,
clang-analyzer-core.DivideZero,
clang-analyzer-core.DynamicTypePropagation,
clang-analyzer-core.NonnilStringConstants,
clang-analyzer-core.NonNullParamChecker,
clang-analyzer-core.NullDereference,
clang-analyzer-core.StackAddressEscape,
clang-analyzer-core.UndefinedBinaryOperatorResult,
clang-analyzer-core.uninitialized.ArraySubscript,
clang-analyzer-core.uninitialized.Assign,
clang-analyzer-core.uninitialized.Branch,
clang-analyzer-core.uninitialized.CapturedBlockVariable,
clang-analyzer-core.uninitialized.UndefReturn,
clang-analyzer-core.VLASize,
clang-analyzer-cplusplus.InnerPointer,
clang-analyzer-cplusplus.Move,
clang-analyzer-cplusplus.NewDelete,
clang-analyzer-cplusplus.NewDeleteLeaks,
clang-analyzer-cplusplus.SelfAssignment,
clang-analyzer-deadcode.DeadStores,
clang-analyzer-nullability.NullableDereferenced,
clang-analyzer-nullability.NullablePassedToNonnull,
clang-analyzer-nullability.NullableReturnedFromNonnull,
clang-analyzer-nullability.NullPassedToNonnull,
clang-analyzer-nullability.NullReturnedFromNonnull,
clang-analyzer-optin.cplusplus.VirtualCall,
clang-analyzer-optin.mpi.MPI-Checker,
clang-analyzer-optin.performance.GCDAntipattern,
clang-analyzer-optin.performance.Padding,
clang-analyzer-optin.portability.UnixAPI,
clang-analyzer-security.FloatLoopCounter,
clang-analyzer-security.insecureAPI.bcmp,
clang-analyzer-security.insecureAPI.bcopy,
clang-analyzer-security.insecureAPI.bzero,
clang-analyzer-security.insecureAPI.getpw,
clang-analyzer-security.insecureAPI.gets,
clang-analyzer-security.insecureAPI.mkstemp,
clang-analyzer-security.insecureAPI.mktemp,
clang-analyzer-security.insecureAPI.rand,
clang-analyzer-security.insecureAPI.strcpy,
clang-analyzer-security.insecureAPI.UncheckedReturn,
clang-analyzer-security.insecureAPI.vfork,
clang-analyzer-unix.API,
clang-analyzer-unix.cstring.BadSizeArg,
clang-analyzer-unix.cstring.NullArg,
clang-analyzer-unix.Malloc,
clang-analyzer-unix.MallocSizeof,
clang-analyzer-unix.MismatchedDeallocator,
clang-analyzer-unix.Vfork,
clang-analyzer-valist.CopyToSelf,
clang-analyzer-valist.Uninitialized,
clang-analyzer-valist.Unterminated,
clang-diagnostic-*,
cppcoreguidelines-avoid-const-or-ref-data-members,
cppcoreguidelines-avoid-non-const-global-variables,
cppcoreguidelines-init-variables,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-macro-usage,
cppcoreguidelines-missing-std-forward,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-no-malloc,
cppcoreguidelines-prefer-member-initializer,
cppcoreguidelines-pro-bounds-pointer-arithmetic,
cppcoreguidelines-pro-type-const-cast,
cppcoreguidelines-pro-type-cstyle-cast,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-reinterpret-cast,
cppcoreguidelines-pro-type-union-access,
cppcoreguidelines-pro-type-vararg,
cppcoreguidelines-slicing,
cppcoreguidelines-special-member-functions,
facebook-hte-BadEnum,
facebook-hte-MissingStatic,
google-build-using-namespace,
misc-definitions-in-headers,
misc-header-include-cycle,
misc-misplaced-const,
misc-new-delete-overloads,
misc-non-copyable-objects,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
misc-unused-alias-decls,
misc-unused-parameters,
misc-unused-using-decls,
modernize-avoid-bind,
modernize-avoid-c-arrays,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
modernize-pass-by-value,
modernize-raw-string-literal,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-random-shuffle,
modernize-return-braced-init-list,
modernize-shrink-to-fit,
modernize-unary-static-assert,
modernize-use-auto,
modernize-use-bool-literals,
modernize-use-constraints,
modernize-use-default-member-init,
modernize-use-designated-initializers,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-noexcept,
modernize-use-nullptr,
modernize-use-override,
modernize-use-starts-ends-with,
modernize-use-transparent-functors,
modernize-use-using,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-string-concatenation,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-move-constructor-init,
performance-noexcept-move-constructor,
performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
readability-avoid-const-params-in-decls,
readability-braces-around-statements,
readability-const-return-type,
readability-container-size-empty,
readability-delete-null-pointer,
readability-deleted-default,
readability-implicit-bool-conversion,
readability-inconsistent-declaration-parameter-name,
readability-isolate-declaration,
readability-misplaced-array-index,
readability-named-parameter,
readability-non-const-parameter,
readability-redundant-control-flow,
readability-redundant-declaration,
readability-redundant-function-ptr-dereference,
readability-redundant-preprocessor,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-redundant-string-init,
readability-simplify-boolean-expr,
readability-simplify-subscript-expr,
readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
readability-uniqueptr-delete-release,
'
CheckOptions:
- key: performance-unnecessary-value-param.AllowedTypes
value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$;'
- key: performance-unnecessary-copy-initialization.AllowedTypes
value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'
...

View File

@@ -9,7 +9,12 @@
module.exports = {
root: true,
ignorePatterns: ['**/binaries/**', '**/build/**', '**/generated/**'],
ignorePatterns: [
'/website',
'**/binaries/**',
'**/build/**',
'**/generated/**',
],
overrides: [
// Catch-all
{

View File

@@ -6,7 +6,7 @@ runs:
- name: Setup Node environment
uses: actions/setup-node@v3
with:
node-version: 20.x
node-version: 18.x
cache: yarn
cache-dependency-path: yarn.lock
env:

View File

@@ -0,0 +1,23 @@
name: Setup Website envirionment
runs:
using: "composite"
steps:
# TODO: Update to latest when website is moved to the workspace version of
# yoga-layout
- name: Setup Node environment
uses: actions/setup-node@v3
with:
node-version: 12.x
cache: yarn
cache-dependency-path: website/yarn.lock
env:
# https://github.com/actions/setup-node/issues/317
FORCE_COLOR: 0
# TODO: the website should be in a yarn workspace with the library, but the
# current version of gatsby is incompatible with hoisting.
- name: yarn install
shell: bash
run: yarn install --frozen-lockfile --network-timeout 1000000
working-directory: website

35
.github/workflows/publish-website.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: Publish Website
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
jobs:
publish:
name: Publish to GitHub Pages
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-website
- name: yarn build
run: yarn build
working-directory: website
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: website/public
cname: yogalayout.dev
keep_files: true
user_name: 'Yoga-bot'
user_email: 'yogabot@fb.com'

View File

@@ -5,6 +5,7 @@ on:
push:
branches:
- main
- 'release-*'
workflow_dispatch:
jobs:

View File

@@ -10,8 +10,22 @@ on:
workflow_dispatch:
jobs:
build:
name: Build [Gatsby]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Setup
uses: ./.github/actions/setup-website
- name: yarn build
run: yarn build
working-directory: website
build_next:
name: Build
name: Build [Docusaurus]
runs-on: ubuntu-latest
steps:
@@ -25,7 +39,7 @@ jobs:
- name: Build Website
run: yarn build
working-directory: website
working-directory: website-next
typecheck:
name: Typecheck [Docusaurus]
@@ -39,4 +53,4 @@ jobs:
- name: yarn tsc
run: yarn tsc
working-directory: website
working-directory: website-next

View File

@@ -1,4 +1,4 @@
# Yoga [![CocoaPods](https://img.shields.io/cocoapods/v/Yoga.svg)](http://cocoapods.org/pods/Yoga) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout) [![Maven Central](https://img.shields.io/maven-central/v/com.facebook.yoga/yoga)](https://search.maven.org/artifact/com.facebook.yoga/yoga) ![SPM](https://img.shields.io/badge/SPM-Supported-blue.svg)
# Yoga [![Support Ukraine](https://img.shields.io/badge/Support-Ukraine-FFD500?style=flat&labelColor=005BBB)](https://opensource.fb.com/support-ukraine) [![CocoaPods](https://img.shields.io/cocoapods/v/Yoga.svg)](http://cocoapods.org/pods/Yoga) [![npm](https://img.shields.io/npm/v/yoga-layout.svg)](https://www.npmjs.com/package/yoga-layout) [![Maven Central](https://img.shields.io/maven-central/v/com.facebook.yoga/yoga)](https://search.maven.org/artifact/com.facebook.yoga/yoga)
Yoga is an embeddable and performant flexbox layout engine with bindings for multiple languages.

View File

@@ -6,7 +6,7 @@
Pod::Spec.new do |spec|
spec.name = 'Yoga'
spec.version = '3.2.1'
spec.version = '3.0.3'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://yogalayout.dev/'
spec.documentation_url = 'https://yogalayout.dev/docs'

View File

@@ -21,9 +21,9 @@ namespace facebook::yoga {
using namespace nlohmann;
using namespace std::chrono;
constexpr uint32_t kNumRepetitions = 100;
constexpr uint32_t kNumRepititions = 100;
using SteadyClockDurations =
std::array<steady_clock::duration, kNumRepetitions>;
std::array<steady_clock::duration, kNumRepititions>;
static bool inputsMatch(
float actualWidth,
@@ -46,11 +46,6 @@ static bool inputsMatch(
actualHeightMode == expectedHeightMode;
}
YGSize defaultMeasureFunctionResult() {
std::cout << "Trying to measure a node that wasn't serialized" << std::endl;
return {10.0, 10.0};
}
YGSize mockMeasureFunc(
YGNodeConstRef node,
float availableWidth,
@@ -58,34 +53,42 @@ YGSize mockMeasureFunc(
float availableHeight,
YGMeasureMode heightMode) {
(void)node;
auto fnsPtr = static_cast<SerializedMeasureFuncMap*>(YGNodeGetContext(node));
MeasureFuncVecWithIndex* fns =
static_cast<MeasureFuncVecWithIndex*>(YGNodeGetContext(node));
if (fnsPtr == nullptr) {
return defaultMeasureFunctionResult();
if (fns->index >= fns->vec.size()) {
std::cout << "Extra measure function call made" << std::endl;
return {10.0, 10.0};
}
auto fnsIt = fnsPtr->find(node);
if (fnsIt == fnsPtr->end()) {
return defaultMeasureFunctionResult();
auto values = fns->vec.at(fns->index);
if (!inputsMatch(
availableWidth,
values.inputWidth,
availableHeight,
values.inputHeight,
widthMode,
values.widthMode,
heightMode,
values.heightMode)) {
std::cout << "Measure function input mismatch." << std::endl
<< "Expected width: " << values.inputWidth
<< ", actual width: " << availableWidth << std::endl
<< "Expected height: " << values.inputHeight
<< ", actual height: " << availableHeight << std::endl
<< "Expected width mode: " << values.widthMode
<< ", actual width mode: " << widthMode << std::endl
<< "Expected height mode: " << values.heightMode
<< ", actual height mode: " << heightMode << std::endl;
return {10.0, 10.0};
}
for (auto measureFunc : fnsIt->second) {
if (inputsMatch(
availableWidth,
measureFunc.inputWidth,
availableHeight,
measureFunc.inputHeight,
widthMode,
measureFunc.widthMode,
heightMode,
measureFunc.heightMode)) {
std::this_thread::sleep_for(
std::chrono::nanoseconds(measureFunc.durationNs));
return {measureFunc.outputWidth, measureFunc.outputHeight};
}
}
fns->index++;
return defaultMeasureFunctionResult();
std::this_thread::sleep_for(std::chrono::nanoseconds(values.durationNs));
return {values.outputWidth, values.outputHeight};
}
std::shared_ptr<const YGConfig> buildConfigFromJson(const json& j) {
@@ -113,8 +116,8 @@ std::shared_ptr<const YGConfig> buildConfigFromJson(const json& j) {
}
std::string edgeStringFromPropertyName(
const std::string& key,
const std::string& propertyName) {
std::string key,
std::string propertyName) {
return key.substr(propertyName.length() + 1);
}
@@ -254,7 +257,7 @@ void setStylesFromJson(const json& j, YGNodeRef node) {
std::shared_ptr<YGNode> buildNodeFromJson(
const json& j,
std::shared_ptr<const YGConfig> config,
std::shared_ptr<SerializedMeasureFuncMap> fns) {
std::shared_ptr<MeasureFuncVecWithIndex> fns) {
std::shared_ptr<YGNode> node(YGNodeNewWithConfig(config.get()), YGNodeFree);
if (!j.contains("node") || j["node"].is_null()) {
@@ -265,13 +268,8 @@ std::shared_ptr<YGNode> buildNodeFromJson(
for (json::iterator it = nodeState.begin(); it != nodeState.end(); it++) {
if (it.key() == "always-forms-containing-block") {
YGNodeSetAlwaysFormsContainingBlock(node.get(), it.value());
} else if (it.key() == "measure-funcs") {
std::vector<SerializedMeasureFunc> vec{};
for (auto measureFuncJson : it.value()) {
vec.push_back(serializedMeasureFuncFromJson(measureFuncJson));
}
fns->insert(std::make_pair(node.get(), vec));
YGNodeSetContext(node.get(), it.value().is_null() ? nullptr : fns.get());
} else if (it.key() == "has-custom-measure" && it.value()) {
YGNodeSetContext(node.get(), fns.get());
YGNodeSetMeasureFunc(node.get(), mockMeasureFunc);
}
}
@@ -281,7 +279,7 @@ std::shared_ptr<YGNode> buildNodeFromJson(
std::shared_ptr<YogaNodeAndConfig> buildTreeFromJson(
const json& j,
std::shared_ptr<SerializedMeasureFuncMap> fns,
std::shared_ptr<MeasureFuncVecWithIndex> fns,
std::shared_ptr<YogaNodeAndConfig> parent,
size_t index) {
auto config = buildConfigFromJson(j);
@@ -299,7 +297,7 @@ std::shared_ptr<YogaNodeAndConfig> buildTreeFromJson(
if (j.contains("children")) {
json children = j["children"];
size_t childIndex = 0;
for (const json& child : children) {
for (json child : children) {
buildTreeFromJson(child, fns, wrapper, childIndex);
childIndex++;
}
@@ -309,7 +307,8 @@ std::shared_ptr<YogaNodeAndConfig> buildTreeFromJson(
}
BenchmarkResult generateBenchmark(json& capture) {
auto fns = std::make_shared<SerializedMeasureFuncMap>();
auto fns = std::make_shared<MeasureFuncVecWithIndex>();
populateMeasureFuncVec(capture["measure-funcs"], fns);
auto treeCreationBegin = steady_clock::now();
std::shared_ptr<YogaNodeAndConfig> root =
@@ -331,25 +330,25 @@ BenchmarkResult generateBenchmark(json& capture) {
}
static void printBenchmarkResult(
const std::string& name,
std::string name,
SteadyClockDurations& durations) {
std::array<double, kNumRepetitions> timesInMs{};
std::array<double, kNumRepititions> timesInMs;
double mean = 0;
for (uint32_t i = 0; i < kNumRepetitions; i++) {
for (uint32_t i = 0; i < kNumRepititions; i++) {
auto ms = duration<double, std::milli>(durations[i]).count();
timesInMs[i] = ms;
mean += ms;
}
mean /= kNumRepetitions;
mean /= kNumRepititions;
std::sort(timesInMs.begin(), timesInMs.end());
double median = timesInMs[kNumRepetitions / 2];
double median = timesInMs[kNumRepititions / 2];
double variance = 0;
for (uint32_t i = 0; i < kNumRepetitions; i++) {
for (uint32_t i = 0; i < kNumRepititions; i++) {
variance += std::pow(timesInMs[i] - mean, 2);
}
variance /= kNumRepetitions;
variance /= kNumRepititions;
double stddev = std::sqrt(variance);
printf("%s: median: %lf ms, stddev: %lf ms\n", name.c_str(), median, stddev);
@@ -370,7 +369,7 @@ void benchmark(std::filesystem::path& capturesDir) {
std::string captureName = capture.path().stem().string();
std::cout << "Starting benchmark for " << captureName << std::endl;
for (uint32_t i = 0; i < kNumRepetitions; i++) {
for (uint32_t i = 0; i < kNumRepititions; i++) {
BenchmarkResult result = generateBenchmark(j);
treeCreationDurations[i] = result.treeCreationDuration;
layoutDurations[i] = result.layoutDuration;

View File

@@ -10,7 +10,6 @@
#include <chrono>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <yoga/Yoga.h>
@@ -22,9 +21,7 @@ struct YogaNodeAndConfig {
std::shared_ptr<YGNode> node,
std::shared_ptr<const YGConfig> config,
std::vector<std::shared_ptr<YogaNodeAndConfig>> children)
: node_(std::move(node)),
config_(std::move(config)),
children_(std::move(children)) {}
: node_(node), config_(config), children_(children) {}
std::shared_ptr<YGNode> node_;
std::shared_ptr<const YGConfig> config_;

View File

@@ -21,13 +21,9 @@ static inline bool isAuto(json& j) {
return j.is_string() && j == "auto";
}
static inline bool isUndefined(json& j) {
return j.is_string() && j == "undefined";
}
static inline std::string invalidArgumentMessage(
const std::string& arg,
const std::string& enumName) {
std::string arg,
std::string enumName) {
return arg + " does not represent any " + enumName + " values";
}
@@ -40,7 +36,7 @@ static inline float floatFromJson(json& j) {
return result;
}
YGFlexDirection flexDirectionFromString(const std::string& str) {
YGFlexDirection flexDirectionFromString(std::string str) {
if (str == "row") {
return YGFlexDirectionRow;
} else if (str == "row-reverse") {
@@ -54,7 +50,7 @@ YGFlexDirection flexDirectionFromString(const std::string& str) {
}
}
YGJustify justifyContentFromString(const std::string& str) {
YGJustify justifyContentFromString(std::string str) {
if (str == "flex-start") {
return YGJustifyFlexStart;
} else if (str == "center") {
@@ -72,7 +68,7 @@ YGJustify justifyContentFromString(const std::string& str) {
}
}
YGAlign alignFromString(const std::string& str) {
YGAlign alignFromString(std::string str) {
if (str == "auto") {
return YGAlignAuto;
} else if (str == "flex-start") {
@@ -96,7 +92,7 @@ YGAlign alignFromString(const std::string& str) {
}
}
YGWrap wrapFromString(const std::string& str) {
YGWrap wrapFromString(std::string str) {
if (str == "no-wrap") {
return YGWrapNoWrap;
} else if (str == "wrap") {
@@ -108,7 +104,7 @@ YGWrap wrapFromString(const std::string& str) {
}
}
YGOverflow overflowFromString(const std::string& str) {
YGOverflow overflowFromString(std::string str) {
if (str == "visible") {
return YGOverflowVisible;
} else if (str == "hidden") {
@@ -120,7 +116,7 @@ YGOverflow overflowFromString(const std::string& str) {
}
}
YGDisplay displayFromString(const std::string& str) {
YGDisplay displayFromString(std::string str) {
if (str == "flex") {
return YGDisplayFlex;
} else if (str == "none") {
@@ -130,7 +126,7 @@ YGDisplay displayFromString(const std::string& str) {
}
}
YGPositionType positionTypeFromString(const std::string& str) {
YGPositionType positionTypeFromString(std::string str) {
if (str == "static") {
return YGPositionTypeStatic;
} else if (str == "relative") {
@@ -146,9 +142,6 @@ YGUnit unitFromJson(json& j) {
if (isAuto(j)) {
return YGUnitAuto;
}
if (isUndefined(j)) {
return YGUnitUndefined;
}
std::string unit = j["unit"];
if (unit == "px") {
@@ -160,7 +153,7 @@ YGUnit unitFromJson(json& j) {
}
}
YGEdge edgeFromString(const std::string& str) {
YGEdge edgeFromString(std::string str) {
if (str == "left") {
return YGEdgeLeft;
} else if (str == "top") {
@@ -184,7 +177,7 @@ YGEdge edgeFromString(const std::string& str) {
}
}
YGErrata errataFromString(const std::string& str) {
YGErrata errataFromString(std::string str) {
if (str == "none") {
return YGErrataNone;
} else if (str == "all") {
@@ -196,7 +189,7 @@ YGErrata errataFromString(const std::string& str) {
}
}
YGExperimentalFeature experimentalFeatureFromString(const std::string& str) {
YGExperimentalFeature experimentalFeatureFromString(std::string str) {
if (str == "web-flex-basis") {
return YGExperimentalFeatureWebFlexBasis;
} else {
@@ -206,12 +199,12 @@ YGExperimentalFeature experimentalFeatureFromString(const std::string& str) {
}
std::string edgeStringFromPropertyName(
const json::iterator& it,
const std::string& propertyName) {
json::iterator it,
std::string propertyName) {
return it.key().substr(propertyName.length() + 1);
}
YGDirection directionFromString(const std::string& str) {
YGDirection directionFromString(std::string str) {
if (str == "ltr") {
return YGDirectionLTR;
} else if (str == "rtl") {
@@ -223,7 +216,7 @@ YGDirection directionFromString(const std::string& str) {
}
}
YGMeasureMode measureModeFromString(const std::string& str) {
YGMeasureMode measureModeFromString(std::string str) {
if (str == "at-most") {
return YGMeasureModeAtMost;
} else if (str == "exactly") {
@@ -235,14 +228,18 @@ YGMeasureMode measureModeFromString(const std::string& str) {
}
}
SerializedMeasureFunc serializedMeasureFuncFromJson(json& j) {
return SerializedMeasureFunc{
floatFromJson(j["width"]),
measureModeFromString(j["width-mode"]),
floatFromJson(j["height"]),
measureModeFromString(j["height-mode"]),
floatFromJson(j["output-width"]),
floatFromJson(j["output-height"]),
j["duration-ns"]};
void populateMeasureFuncVec(
json& j,
std::shared_ptr<MeasureFuncVecWithIndex> fns) {
for (auto measureFuncJson : j) {
fns->vec.push_back(SerializedMeasureFunc{
floatFromJson(measureFuncJson["width"]),
measureModeFromString(measureFuncJson["width-mode"]),
floatFromJson(measureFuncJson["height"]),
measureModeFromString(measureFuncJson["height-mode"]),
floatFromJson(measureFuncJson["output-width"]),
floatFromJson(measureFuncJson["output-height"]),
measureFuncJson["duration-ns"]});
}
}
} // namespace facebook::yoga

View File

@@ -18,35 +18,42 @@ namespace facebook::yoga {
using namespace nlohmann;
YGFlexDirection flexDirectionFromString(const std::string& str);
struct MeasureFuncVecWithIndex {
std::vector<SerializedMeasureFunc> vec;
size_t index;
};
YGJustify justifyContentFromString(const std::string& str);
YGFlexDirection flexDirectionFromString(std::string str);
YGAlign alignFromString(const std::string& str);
YGJustify justifyContentFromString(std::string str);
YGWrap wrapFromString(const std::string& str);
YGAlign alignFromString(std::string str);
YGOverflow overflowFromString(const std::string& str);
YGWrap wrapFromString(std::string str);
YGDisplay displayFromString(const std::string& str);
YGOverflow overflowFromString(std::string str);
YGPositionType positionTypeFromString(const std::string& str);
YGDisplay displayFromString(std::string str);
YGPositionType positionTypeFromString(std::string str);
YGUnit unitFromJson(json& j);
YGEdge edgeFromString(const std::string& str);
YGEdge edgeFromString(std::string str);
YGErrata errataFromString(const std::string& str);
YGErrata errataFromString(std::string str);
YGExperimentalFeature experimentalFeatureFromString(const std::string& str);
YGExperimentalFeature experimentalFeatureFromString(std::string str);
std::string edgeStringFromPropertyName(
const json::iterator& it,
const std::string& propertyName);
json::iterator it,
std::string propertyName);
YGDirection directionFromString(const std::string& str);
YGDirection directionFromString(std::string str);
YGMeasureMode measureModeFromString(const std::string& str);
YGMeasureMode measureModeFromString(std::string str);
SerializedMeasureFunc serializedMeasureFuncFromJson(json& j);
void populateMeasureFuncVec(
json& j,
std::shared_ptr<MeasureFuncVecWithIndex> fns);
} // namespace facebook::yoga

View File

@@ -7,7 +7,7 @@ cd "$(dirname "$0")" || exit
CAPTURES_PATH="$(dirname "$(realpath "$0")")""/captures"
if [ "$1" = "buck" ]; then
buck run @//fbcode/mode/opt :benchmarkCXX "${CAPTURES_PATH}"
buck run @fbcode/mode/opt :benchmarkCXX "${CAPTURES_PATH}"
else
cmake -B build -S . -D CMAKE_BUILD_TYPE=Release
cmake --build build

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -4,6 +4,224 @@
"available-width": 1080.0,
"owner-direction": "ltr"
},
"measure-funcs": [
{
"duration-ns": 23667,
"height": null,
"height-mode": "undefined",
"output-height": 330.0,
"output-width": 408.0,
"width": 647.3333129882813,
"width-mode": "at-most"
},
{
"duration-ns": 9083,
"height": null,
"height-mode": "undefined",
"output-height": 448.0,
"output-width": 562.5,
"width": 647.3333129882813,
"width-mode": "at-most"
},
{
"duration-ns": 7667,
"height": null,
"height-mode": "undefined",
"output-height": 100.0,
"output-width": 294.0,
"width": 647.3333129882813,
"width-mode": "at-most"
},
{
"duration-ns": 8333,
"height": 676.0,
"height-mode": "at-most",
"output-height": 94.0,
"output-width": 328.6666564941406,
"width": 328.6666564941406,
"width-mode": "exactly"
},
{
"duration-ns": 7791,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 8041,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 8000,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7709,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7666,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 6916,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7167,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 9333,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7125,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7125,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7209,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7083,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7333,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7375,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 8917,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 7667,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
},
{
"duration-ns": 8583,
"height": null,
"height-mode": "undefined",
"output-height": 295.0,
"output-width": 816.0,
"width": null,
"width-mode": "undefined"
},
{
"duration-ns": 7667,
"height": null,
"height-mode": "undefined",
"output-height": 7.0,
"output-width": 70.5,
"width": 1076.0,
"width-mode": "at-most"
},
{
"duration-ns": 494291,
"height": 44.0,
"height-mode": "at-most",
"output-height": 18.0,
"output-width": 5.0,
"width": 1016.0,
"width-mode": "at-most"
},
{
"duration-ns": 58250,
"height": 44.0,
"height-mode": "at-most",
"output-height": 18.0,
"output-width": 10.0,
"width": 10.0,
"width-mode": "exactly"
}
],
"tree": {
"children": [
{
@@ -19,17 +237,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 8167,
"height": null,
"height-mode": "undefined",
"output-height": 295.0,
"output-width": 816.0,
"width": null,
"width-mode": "undefined"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -512,17 +720,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 24625,
"height": null,
"height-mode": "undefined",
"output-height": 330.0,
"output-width": 408.0,
"width": 647.3333129882813,
"width-mode": "at-most"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -549,17 +747,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 9625,
"height": null,
"height-mode": "undefined",
"output-height": 448.0,
"output-width": 562.5,
"width": 647.3333129882813,
"width-mode": "at-most"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -586,17 +774,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 8417,
"height": null,
"height-mode": "undefined",
"output-height": 100.0,
"output-width": 294.0,
"width": 647.3333129882813,
"width-mode": "at-most"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -637,17 +815,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 9166,
"height": 676.0,
"height-mode": "at-most",
"output-height": 94.0,
"output-width": 328.6666564941406,
"width": 328.6666564941406,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"padding-all": {
@@ -669,17 +837,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 8250,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -722,17 +880,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 8625,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -775,17 +923,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 7250,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -828,17 +966,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 6833,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -881,17 +1009,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 7042,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -934,17 +1052,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 6208,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -987,17 +1095,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 6834,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1040,17 +1138,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 8500,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1093,17 +1181,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 6750,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1146,17 +1224,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 6667,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1199,17 +1267,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 8958,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1252,17 +1310,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 8125,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1305,17 +1353,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 6541,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1358,17 +1396,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 6541,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1411,17 +1439,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 6333,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1464,17 +1482,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 7875,
"height": 566.0,
"height-mode": "at-most",
"output-height": 21.0,
"output-width": 158.33331298828125,
"width": 158.33331298828125,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": {
"margin-all": {
@@ -1611,17 +1619,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 7583,
"height": null,
"height-mode": "undefined",
"output-height": 7.0,
"output-width": 70.5,
"width": 1076.0,
"width-mode": "at-most"
}
]
"has-custom-measure": true
},
"style": null
}
@@ -1666,26 +1664,7 @@
"errata": "all"
},
"node": {
"measure-funcs": [
{
"duration-ns": 478791,
"height": 44.0,
"height-mode": "at-most",
"output-height": 18.0,
"output-width": 5.0,
"width": 1016.0,
"width-mode": "at-most"
},
{
"duration-ns": 61250,
"height": 44.0,
"height-mode": "at-most",
"output-height": 18.0,
"output-width": 10.0,
"width": 10.0,
"width-mode": "exactly"
}
]
"has-custom-measure": true
},
"style": null
}
@@ -1730,7 +1709,7 @@
"errata": "all"
},
"node": {
"measure-funcs": null
"has-custom-measure": true
},
"style": {
"flex": 1.0

View File

@@ -6,8 +6,8 @@
*/
plugins {
id("com.android.library") version "8.7.1" apply false
id("com.android.application") version "8.7.1" apply false
id("com.android.library") version "8.2.1" apply false
id("com.android.application") version "8.2.1" apply false
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}

View File

@@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
#include <cassert>
#include <fstream>
#include <vector>
#include <capture/CaptureTree.h>
#include <capture/NodeToString.h>
@@ -23,9 +23,10 @@ static void captureTree(
file << serializedTree;
}
static SerializedMeasureFuncMap& currentSerializedMeasureFuncMap() {
static thread_local SerializedMeasureFuncMap map{};
return map;
static std::vector<SerializedMeasureFunc>& currentSerializedMeasureFuncVec() {
static thread_local std::vector<SerializedMeasureFunc>
currentSerializedMeasureFuncVec;
return currentSerializedMeasureFuncVec;
}
/*
@@ -56,45 +57,38 @@ void YGNodeCalculateLayoutWithCapture(
YGDirection ownerDirection,
const std::filesystem::path& path) {
dirtyTree(node);
YGNodeCalculateLayout(node, availableWidth, availableHeight, ownerDirection);
json j;
serializeLayoutInputs(j, availableWidth, availableHeight, ownerDirection);
serializeTree(
j,
currentSerializedMeasureFuncMap(),
node,
PrintOptions::Style | PrintOptions::Children | PrintOptions::Config |
PrintOptions::Node);
YGNodeCalculateLayout(node, availableWidth, availableHeight, ownerDirection);
serializeMeasureFuncResults(j, currentSerializedMeasureFuncVec());
// TODO: It is possible to have a measure function call layout again if, e.g.,
// views are nested in text. Need to be able to resolve this special case.
currentSerializedMeasureFuncMap().clear();
currentSerializedMeasureFuncVec().clear();
captureTree(j.dump(2), path);
}
void captureMeasureFunc(
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode,
YGSize output,
std::chrono::steady_clock::duration durationNs) {
auto measureFuncIt = currentSerializedMeasureFuncMap().find(node);
if (measureFuncIt == currentSerializedMeasureFuncMap().end()) {
std::vector<SerializedMeasureFunc> vec{};
currentSerializedMeasureFuncMap().insert(std::make_pair(node, vec));
}
measureFuncIt = currentSerializedMeasureFuncMap().find(node);
assert(measureFuncIt != currentSerializedMeasureFuncMap().end());
measureFuncIt->second.push_back(
{width,
widthMode,
height,
heightMode,
output.width,
output.height,
durationNs.count()});
currentSerializedMeasureFuncVec().push_back(SerializedMeasureFunc{
width,
widthMode,
height,
heightMode,
output.width,
output.height,
durationNs.count()});
}
} // namespace facebook::yoga

View File

@@ -8,8 +8,6 @@
#pragma once
#include <filesystem>
#include <unordered_map>
#include <vector>
#include <yoga/Yoga.h>
@@ -22,12 +20,9 @@ struct SerializedMeasureFunc {
YGMeasureMode heightMode{YGMeasureModeUndefined};
float outputWidth{0.0f};
float outputHeight{0.0f};
std::chrono::steady_clock::duration::rep durationNs{};
std::chrono::steady_clock::duration::rep durationNs;
};
using SerializedMeasureFuncMap =
std::unordered_map<YGNodeConstRef, std::vector<SerializedMeasureFunc>>;
void YGNodeCalculateLayoutWithCapture(
YGNodeRef node,
float availableWidth,
@@ -36,7 +31,6 @@ void YGNodeCalculateLayoutWithCapture(
const std::filesystem::path& path);
void captureMeasureFunc(
YGNodeConstRef node,
float width,
YGMeasureMode widthMode,
float height,

View File

@@ -6,7 +6,6 @@
*/
#include <memory>
#include <vector>
#include <capture/NodeToString.h>
@@ -121,26 +120,7 @@ static YGValue borderFloatToYGValue(YGNodeRef node, YGEdge edge) {
return YGValue{val, unit};
}
static void serializeMeasureFuncResults(
json& j,
std::vector<SerializedMeasureFunc>& measureFuncs) {
for (auto measureFunc : measureFuncs) {
j["measure-funcs"].push_back(
{{"width", measureFunc.inputWidth},
{"width-mode", YGMeasureModeToString(measureFunc.widthMode)},
{"height", measureFunc.inputHeight},
{"height-mode", YGMeasureModeToString(measureFunc.heightMode)},
{"output-width", measureFunc.outputWidth},
{"output-height", measureFunc.outputHeight},
{"duration-ns", measureFunc.durationNs}});
}
}
static void serializeTreeImpl(
json& j,
SerializedMeasureFuncMap& nodesToMeasureFuncs,
YGNodeRef node,
PrintOptions options) {
static void serializeTreeImpl(json& j, YGNodeRef node, PrintOptions options) {
if ((options & PrintOptions::Layout) == PrintOptions::Layout) {
j["layout"]["width"] = YGNodeStyleGetWidth(node).value;
j["layout"]["height"] = YGNodeStyleGetHeight(node).value;
@@ -313,12 +293,7 @@ static void serializeTreeImpl(
YGNodeGetAlwaysFormsContainingBlock(node),
YGNodeGetAlwaysFormsContainingBlock(defaultNode.get()));
if (YGNodeHasMeasureFunc(node)) {
auto measureFuncIt = nodesToMeasureFuncs.find(node);
if (measureFuncIt == nodesToMeasureFuncs.end()) {
j["node"]["measure-funcs"];
} else {
serializeMeasureFuncResults(j["node"], measureFuncIt->second);
}
j["node"]["has-custom-measure"] = true;
}
}
@@ -327,21 +302,13 @@ static void serializeTreeImpl(
childCount > 0) {
for (size_t i = 0; i < childCount; i++) {
j["children"].push_back({});
serializeTreeImpl(
j["children"][i],
nodesToMeasureFuncs,
YGNodeGetChild(node, i),
options);
serializeTreeImpl(j["children"][i], YGNodeGetChild(node, i), options);
}
}
}
void serializeTree(
json& j,
SerializedMeasureFuncMap& nodesToMeasureFuncs,
YGNodeRef node,
PrintOptions options) {
serializeTreeImpl(j["tree"], nodesToMeasureFuncs, node, options);
void serializeTree(json& j, YGNodeRef node, PrintOptions options) {
serializeTreeImpl(j["tree"], node, options);
}
void serializeLayoutInputs(
@@ -356,4 +323,19 @@ void serializeLayoutInputs(
};
}
void serializeMeasureFuncResults(
json& j,
std::vector<SerializedMeasureFunc>& measureFuncs) {
for (auto measureFunc : measureFuncs) {
j["measure-funcs"].push_back(
{{"width", measureFunc.inputWidth},
{"width-mode", YGMeasureModeToString(measureFunc.widthMode)},
{"height", measureFunc.inputHeight},
{"height-mode", YGMeasureModeToString(measureFunc.heightMode)},
{"output-width", measureFunc.outputWidth},
{"output-height", measureFunc.outputHeight},
{"duration-ns", measureFunc.durationNs}});
}
}
} // namespace facebook::yoga

View File

@@ -25,11 +25,7 @@ enum class PrintOptions : uint8_t {
};
YG_DEFINE_ENUM_FLAG_OPERATORS(PrintOptions);
void serializeTree(
nlohmann::json& j,
SerializedMeasureFuncMap& nodesToMeasureFuncs,
YGNodeRef node,
PrintOptions options);
void serializeTree(nlohmann::json& j, YGNodeRef root, PrintOptions options);
void serializeLayoutInputs(
nlohmann::json& j,
@@ -37,4 +33,8 @@ void serializeLayoutInputs(
float availableHeight,
YGDirection ownerDirection);
void serializeMeasureFuncResults(
nlohmann::json& j,
std::vector<SerializedMeasureFunc>& measureFuncs);
} // namespace facebook::yoga

View File

@@ -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.
import math
import os
ENUMS = {
@@ -31,9 +32,8 @@ ENUMS = {
"SpaceEvenly",
],
"PositionType": ["Static", "Relative", "Absolute"],
"Display": ["Flex", "None", "Contents"],
"Display": ["Flex", "None"],
"Wrap": ["NoWrap", "Wrap", "WrapReverse"],
"BoxSizing": ["BorderBox", "ContentBox"],
"MeasureMode": ["Undefined", "Exactly", "AtMost"],
"Dimension": ["Width", "Height"],
"Edge": [
@@ -61,10 +61,9 @@ ENUMS = {
# Allows main-axis flex basis to be stretched without flexGrow being
# set (previously referred to as "UseLegacyStretchBehaviour")
("StretchFlexBasis", 1 << 0),
# Absolute position in a given axis will be relative to the padding
# edge of the parent container instead of the content edge when a
# specific inset (top/bottom/left/right) is not set.
("AbsolutePositionWithoutInsetsExcludesPadding", 1 << 1),
# Positioning of absolute nodes will have various bugs related to
# justification, alignment, and insets
("AbsolutePositioningIncorrect", 1 << 1),
# Absolute nodes will resolve percentages against the inner size of
# their containing node, not the padding box
("AbsolutePercentAgainstInnerSize", 1 << 2),

View File

@@ -2,18 +2,6 @@
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
</div>
<div id="absolute_layout_width_height_left_auto_right" style="width: 100px; height: 100px">
<div style="width: 10px; height: 10px; position: absolute; left: auto; right: 10px;"></div>
</div>
<div id="absolute_layout_width_height_left_right_auto" style="width: 100px; height: 100px">
<div style="width: 10px; height: 10px; position: absolute; left: 10px; right: auto;"></div>
</div>
<div id="absolute_layout_width_height_left_auto_right_auto" style="width: 100px; height: 100px">
<div style="width: 10px; height: 10px; position: absolute; left: auto; right: auto;"></div>
</div>
<div id="absolute_layout_width_height_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; end: 10px; bottom: 10px;"></div>
</div>
@@ -144,22 +132,6 @@
<div style="position:absolute; width:50px; height:50px;"></div>
</div>
<div id="absolute_layout_padding">
<div style="width:200px; height:200px; margin:10px; position: relative">
<div style="position:static; width:200px; height:200px; padding: 50px;">
<div style="position:absolute; width:50px; height:50px;"></div>
</div>
</div>
</div>
<div id="absolute_layout_border">
<div style="width:200px; height:200px; margin:10px; position: relative">
<div style="position:static; width:200px; height:200px; border: 10px solid black;">
<div style="position:absolute; width:50px; height:50px;"></div>
</div>
</div>
</div>
<div id="absolute_layout_column_reverse_margin_border"
style="width:200px; height:200px; flex-direction: column-reverse;">
<div

View File

@@ -155,14 +155,6 @@
</div>
</div>
<div id="align_content_space_between_wrapped_negative_space_row_reverse" style="display: flex; flex-direction: column; width: 320px; height: 320px; border-width: 60px;">
<div style="display: flex; flex-direction: row-reverse; flex-wrap: wrap; align-content: space-between; justify-content: center; height: 10px;">
<div style="width: 80%; height: 20px; flex-shrink: 0;"></div>
<div style="width: 80%; height: 20px; flex-shrink: 0;"></div>
<div style="width: 80%; height: 20px; flex-shrink: 0;"></div>
</div>
</div>
<div id="align_content_space_between_wrapped_negative_space_gap" style="display: flex; flex-direction: column; width: 320px; height: 320px; border-width: 60px;">
<div style="display: flex; flex-direction: row; flex-wrap: wrap; align-content: space-between; justify-content: center; height: 10px; gap: 10px;">
<div style="width: 80%; height: 20px; flex-shrink: 0;"></div>
@@ -200,14 +192,6 @@
</div>
</div>
<div id="align_content_space_around_wrapped_negative_space_row_reverse" style="display: flex; flex-direction: column; width: 320px; height: 320px; border-width: 60px;">
<div style="display: flex; flex-direction: row-reverse; flex-wrap: wrap; align-content: space-around; justify-content: center; height: 10px;">
<div style="width: 80%; height: 20px; flex-shrink: 0;"></div>
<div style="width: 80%; height: 20px; flex-shrink: 0;"></div>
<div style="width: 80%; height: 20px; flex-shrink: 0;"></div>
</div>
</div>
<div id="align_content_space_around_wrapped_negative_space_gap" style="display: flex; flex-direction: column; width: 320px; height: 320px; border-width: 60px;">
<div style="display: flex; flex-direction: row; flex-wrap: wrap; align-content: space-around; justify-content: center; height: 10px; gap: 10px;">
<div style="width: 80%; height: 20px; flex-shrink: 0;"></div>
@@ -448,32 +432,3 @@
</div>
<div style="height: 50px; width: 50px; margin-left: 20px;"></div>
</div>
<div id="align_content_stretch_and_align_items_flex_end_with_flex_wrap"
style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: stretch;align-items: flex-end;">
<div style="height: 50px; width: 150px; align-self: flex-start;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>
<div id="align_content_stretch_and_align_items_flex_start_with_flex_wrap"
style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: stretch;align-items: flex-start;">
<div style="height: 50px; width: 150px; align-self: flex-end;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>
<div id="align_content_stretch_and_align_items_center_with_flex_wrap"
style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: stretch;align-items: center;">
<div style="height: 50px; width: 150px; align-self: flex-end;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>
<div id="align_content_stretch_and_align_items_stretch_with_flex_wrap"
style="width: 300px; height: 300px; flex-direction: row; flex-wrap: wrap; align-content: stretch;align-items: stretch;">
<div style="height: 50px; width: 150px; align-self: flex-end;"></div>
<div style="height: 100px; width: 120px;"></div>
<div style="height: 50px; width: 120px;"></div>
</div>

View File

@@ -2,10 +2,10 @@
<div id="aspect_ratio_does_not_stretch_cross_axis_dim" data-disabled="true" style="width: 300px; height: 300px;">
<div style="flex: 1; overflow: scroll;">
<div style="flex-direction: row;">
<div style="flex: 2; aspect-ratio: 1;"></div>
<div style="width: 5px"></div>
<div style="flex: 1">
<div style="flex: 1; aspect-ratio: 1;">
<div style="flex: 2; aspect-ratio: 1;"></div>
<div style="width: 5px"></div>
<div style="flex: 1">
<div style="flex: 1; aspect-ratio: 1;">
<div style="width: 5px"></div>
<div style="flex: 1; aspect-ratio: 1;"></div>
</div>
@@ -13,7 +13,3 @@
</div>
</div>
</div>
<div id="zero_aspect_ratio_behaves_like_auto" style="width: 300px; height: 300px;">
<div style="aspect-ratio: 0; width: 50px"></div>
</div>

View File

@@ -1,25 +0,0 @@
<div id="auto_width" style="width: auto; height: 50px; flex-direction: row;">
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
</div>
<div id="auto_height" style="width: 50px; height: auto;">
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
</div>
<div id="auto_flex_basis" style="width: 50px; flex-basis: auto;">
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
<div style="width: 50px; height: 50px"></div>
</div>
<div id="auto_position" style="width: 50px; height: 50px;">
<div style="width: 25px; height: 25px; right: auto"></div>
</div>
<div id="auto_margin" style="width: 50px; height: 50px;">
<div style="width: 25px; height: 25px; margin-left: auto"></div>
</div>

View File

@@ -1,252 +0,0 @@
<div id="box_sizing_content_box_simple"
style="width: 100px; height: 100px; padding: 5px; border-width: 10px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_simple"
style="width: 100px; height: 100px; padding: 5px; border-width: 10px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_percent" style="width: 100px; height: 100px;">
<div style="width: 50%; height: 25%; padding: 4px; border-width: 16px; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_percent" style="width: 100px; height: 100px;">
<div style="width: 50%; height: 25%; padding: 4px; border-width: 16px; box-sizing: border-box">
</div>
</div>
<div id="box_sizing_content_box_absolute" style="width: 100px; height: 100px;">
<div style="width: 50; height: 25%; padding: 12px; border-width: 8px; box-sizing: content-box; position: absolute;">
</div>
</div>
<div id="box_sizing_border_box_absolute" style="width: 100px; height: 100px;">
<div style="width: 50; height: 25%; padding: 12px; border-width: 8px; box-sizing: border-box; position: absolute;">
</div>
</div>
<div id="box_sizing_content_box_comtaining_block"
style="width: 100px; height: 100px; padding: 12px; border-width: 8px; box-sizing: content-box; ">
<div style="width: 75; height: 75; position: static;">
<div style="width: 50px; height: 25%; position: absolute;">
</div>
</div>
</div>
<div id="box_sizing_border_box_comtaining_block"
style="width: 100px; height: 100px; padding: 12px; border-width: 8px; box-sizing: border-box; ">
<div style="width: 75; height: 75; position: static;">
<div style="width: 50px; height: 25%; position: absolute;">
</div>
</div>
</div>
<div id="box_sizing_content_box_padding_only"
style="width: 100px; height: 100px; padding: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_content_box_padding_only_percent" style="width: 100px; height: 150px;">
<div style="width: 50px; height: 75px; padding: 10%; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_padding_only" style="width: 100px; height: 100px; padding: 5px; box-sizing: border-box">
</div>
<div id="box_sizing_border_box_padding_only_percent" style="width: 100px; height: 150px;">
<div style="width: 50px; height: 75px; padding: 10%; box-sizing: border-box">
</div>
</div>
<div id="box_sizing_content_box_border_only"
style="width: 100px; height: 100px; border-width: 10px; box-sizing: content-box">
</div>
<div id="box_sizing_content_box_border_only_percent" style="width: 100px; height: 100px;">
<div style="width: 50%; height: 75; border-width: 10%; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_border_only"
style="width: 100px; height: 100px; border-width: 10px; box-sizing: border-box">
</div>
<div id="box_sizing_border_box_border_only_percent" style="width: 100px; height: 100px;">
<div style="width: 50%; height: 75; border-width: 10%; box-sizing: border-box">
</div>
</div>
<div id="box_sizing_content_box_no_padding_no_border" style="width: 100px; height: 100px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_no_padding_no_border" style="width: 100px; height: 100px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_children"
style="width: 100px; height: 100px; padding: 5px; border-width: 10px; box-sizing: content-box">
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_children"
style="width: 100px; height: 100px; padding: 5px; border-width: 10px; box-sizing: border-box">
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_siblings" style="width: 100px; height: 100px;">
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px; box-sizing: content-box; padding: 10px; border-width: 10px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_siblings" style="width: 100px; height: 100px;">
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px; box-sizing: border-box; padding: 10px; border-width: 10px"></div>
<div style="width: 25px; height: 25px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_max_width" style="width: 100px; height: 100px;">
<div style="max-width: 50px; height: 25px; box-sizing: content-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_max_width" style="width: 100px; height: 100px;">
<div style="max-width: 50px; height: 25px; box-sizing: border-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_max_height" style="width: 100px; height: 100px;">
<div style="width: 50px; max-height: 50px; box-sizing: content-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_max_height" style="width: 100px; height: 100px;">
<div style="width: 50px; max-height: 50px; box-sizing: border-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_min_width" style="width: 100px; height: 100px;">
<div style="min-width: 50px; height: 25px; box-sizing: content-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_min_width" style="width: 100px; height: 100px;">
<div style="min-width: 50px; height: 25px; box-sizing: border-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_min_height" style="width: 100px; height: 100px;">
<div style="width: 50px; min-height: 50px; box-sizing: content-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_border_box_min_height" style="width: 100px; height: 100px;">
<div style="width: 50px; min-height: 50px; box-sizing: border-box; padding: 5px; border-width: 15px"></div>
<div style="width: 25px; height: 25px"></div>
</div>
<div id="box_sizing_content_box_no_height_no_width" style="width: 100px; height: 100px;">
<div style="box-sizing: content-box; padding: 2px; border-width: 7px">
</div>
</div>
<div id="box_sizing_border_box_no_height_no_width" style="width: 100px; height: 100px;">
<div style="box-sizing: border-box; padding: 2px; border-width: 7px">
</div>
</div>
<div id="box_sizing_content_box_nested"
style="width: 100px; height: 100px; box-sizing: content-box; padding: 15px; border-width: 3px;">
<div style="width: 20px; height: 20px; box-sizing: content-box; padding: 2px; border-width: 7px">
<div style="width: 10px; height: 5px; box-sizing: content-box; padding: 1px; border-width: 2px"></div>
</div>
</div>
<div id="box_sizing_border_box_nested"
style="width: 100px; height: 100px; box-sizing: border-box; padding: 15px; border-width: 3px;">
<div style="width: 20px; height: 20px; box-sizing: border-box; padding: 2px; border-width: 7px">
<div style="width: 10px; height: 5px; box-sizing: border-box; padding: 1px; border-width: 2px"></div>
</div>
</div>
<div id="box_sizing_content_box_nested_alternating"
style="width: 100px; height: 100px; box-sizing: content-box; padding: 3px; border-width: 2px;">
<div style="width: 40px; height: 40px; box-sizing: border-box; padding: 8px; border-width: 2px">
<div style="width: 20px; height: 25px; box-sizing: content-box; padding: 3px; border-width: 6px">
<div style="width: 10px; height: 5px; box-sizing: border-box; padding: 1px; border-width: 1px">
</div>
</div>
</div>
</div>
<div id="box_sizing_border_box_nested_alternating"
style="width: 100px; height: 100px; box-sizing: border-box; padding: 3px; border-width: 2px;">
<div style="width: 40px; height: 40px; box-sizing: content-box; padding: 8px; border-width: 2px">
<div style="width: 20px; height: 25px; box-sizing: border-box; padding: 3px; border-width: 6px">
<div style="width: 10px; height: 5px; box-sizing: content-box; padding: 1px; border-width: 1px">
</div>
</div>
</div>
</div>
<div data-disabled="true" id="box_sizing_content_box_flex_basis_row"
style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 50px; height: 25px; padding: 5px; border-width: 10px; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_flex_basis_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 50px; height: 25px; padding: 5px; border-width: 10px; box-sizing: border-box">
</div>
</div>
<div data-disabled="true" id="box_sizing_content_box_flex_basis_column"
style="width: 100px; height: 100px; flex-direction: column;">
<div style="flex-basis: 50px; height: 25px; padding: 5px; border-width: 10px; box-sizing: content-box">
</div>
</div>
<div id="box_sizing_border_box_flex_basis_column" style="width: 100px; height: 100px; flex-direction: column;">
<div style="flex-basis: 50px; height: 25px; padding: 5px; border-width: 10px; box-sizing: border-box">
</div>
</div>
<div id="box_sizing_content_box_padding_start"
style="width: 100px; height: 100px; padding-start: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_padding_start"
style="width: 100px; height: 100px; padding-start: 5px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_padding_end"
style="width: 100px; height: 100px; padding-end: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_padding_end"
style="width: 100px; height: 100px; padding-end: 5px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_border_start"
style="width: 100px; height: 100px; border-start-width: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_border_start"
style="width: 100px; height: 100px; border-start-width: 5px; box-sizing: border-box">
</div>
<div id="box_sizing_content_box_border_end"
style="width: 100px; height: 100px; border-end-width: 5px; box-sizing: content-box">
</div>
<div id="box_sizing_border_box_border_end"
style="width: 100px; height: 100px; border-end-width: 5px; box-sizing: border-box">
</div>

View File

@@ -29,61 +29,3 @@
<div id="display_none_with_position_absolute" style="width: 100px; height: 100px;">
<div style="display:none; position: absolute; width: 100px; height: 100px"></div>
</div>
<div id="display_contents" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_fixed_size" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents; width: 50px; height: 50px;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_with_margin" style="width: 100px; height: 100px; flex-direction: row;">
<div style="width: 20px; height: 20px; display: contents; margin: 10px;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="display_contents_with_padding" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents; padding: 10px;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_with_position" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents; top: 10px;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_with_position_absolute" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents; position: absolute; width: 50px; height: 50px;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
<div id="display_contents_nested" style="width: 100px; height: 100px; flex-direction: row;">
<div style="display: contents;">
<div style="display: contents;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
</div>
</div>
<div id="display_contents_with_siblings" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex: 1; height: 30px;"></div>
<div style="display: contents;">
<div style="flex: 1; height: 10px;"></div>
<div style="flex: 1; height: 20px;"></div>
</div>
<div style="flex: 1; height: 30px;"></div>
</div>

View File

@@ -400,8 +400,3 @@
<div style="width: 10px;"></div>
</div>
</div>
<div id="flex_direction_alternating_with_percent" style="height: 300px; width: 200px; flex-direction: column;">
<div style="height: 50%; width: 50%; left: 10%; top: 10%; flex-direction: row;">
</div>
</div>

View File

@@ -171,72 +171,3 @@
<div style="height: 20px"></div>
<div style="height: 30px"></div>
</div>
<div id="row_gap_percent_wrapping" style="flex-direction: row; width: 300px; height: 700px; padding: 10px; gap: 10%; flex-wrap: wrap;">
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
</div>
<div id="row_gap_percent_determines_parent_height" style="flex-direction: row; width: 300px; gap: 10%; flex-wrap: wrap;">
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
</div>
<div id="row_gap_percent_wrapping_with_both_content_padding_and_item_padding" style="flex-direction: row; width: 300px; height: 700px; padding: 10px; gap: 10%; flex-wrap: wrap;">
<div style="width: 100px; height: 100px; padding: 10px;"></div>
<div style="width: 100px; height: 100px; padding: 10px;"></div>
<div style="width: 100px; height: 100px; padding: 10px;"></div>
<div style="width: 100px; height: 100px; padding: 10px;"></div>
<div style="width: 100px; height: 100px; padding: 10px;"></div>
</div>
<div id="row_gap_percent_wrapping_with_both_content_padding" style="flex-direction: row; width: 300px; height: 700px; padding: 10px; gap: 10%; flex-wrap: wrap;">
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
</div>
<div id="row_gap_percent_wrapping_with_content_margin" style="flex-direction: row; width: 300px; height: 700px; margin: 10px; gap: 10%; flex-wrap: wrap;">
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
</div>
<div id="row_gap_percent_wrapping_with_content_margin_and_padding" style="flex-direction: row; width: 300px; height: 700px; margin: 10px; padding: 10px; gap: 10%; flex-wrap: wrap;">
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
</div>
<div id="row_gap_percent_wrapping_with_flexible_content" style="flex-direction: row; width: 300px; height: 300px; gap: 10%;">
<div style="flex: 1;"></div>
<div style="flex: 1;"></div>
<div style="flex: 1;"></div>
</div>
<div id="row_gap_percent_wrapping_with_mixed_flexible_content" style="flex-direction: row; width: 300px; height: 300px; gap: 10%;">
<div style="width: 10px;"></div>
<div style="flex: 1;"></div>
<div style="width: 10%;"></div>
</div>
<!-- TODO: Existing bug that Yoga is not inline with Chromium for calculation with min-width -->
<div id="row_gap_percent_wrapping_with_min_width" data-disabled="true" style="flex-direction: row; min-width: 300px; gap: 10%; flex-wrap: wrap;">
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
<div style="width: 100px; height: 100px;"></div>
</div>

View File

@@ -1,221 +0,0 @@
<div id="contains_inner_text_long_word" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;">
LoremipsumdolorsitametconsecteturadipiscingelitSedeleifasdfettortoracauctorFuscerhoncusipsumtemporerosaliquamconsequatPraesentsoda
</div>
</div>
<div id="contains_inner_text_no_width_no_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_no_width_no_height_long_word_in_paragraph"
style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus
loremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumlorem
Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_fixed_width" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;width:100px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_no_width_fixed_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;height:20px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_fixed_width_fixed_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;width: 50px; height:20px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_max_width_max_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;max-width: 50px; max-height:20px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_max_width" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;max-width:100px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>
<div id="contains_inner_text_fixed_width_shorter_text" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;width:100px">
Lorem ipsum
</div>
</div>
<div id="contains_inner_text_fixed_height_shorter_text" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;height:100px">
Lorem ipsum
</div>
</div>
<div id="contains_inner_text_max_height" style="width:2000px;height:2000px;align-items: flex-start;">
<div style="flex-direction:row;max-height:20px">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at
volutpat
libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus
fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus
vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor,
vitae
finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet
consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo
tincidunt
finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam
vulputate eleifasd lectus vel varius.
Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis
in
faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel
venenatis
turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed
nunc
malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor
lobortis.
Sed at consectetur ipsum.
</div>
</div>

View File

@@ -70,7 +70,7 @@
<div style="height: 20px; width: 20px;"></div>
</div>
<div id="justify_content_column_max_height_and_margin" style="height: 100px; max-height: 80px; margin-top: 100px; justify-content: center; flex-direction: column;">
<div id="justify_content_colunn_max_height_and_margin" style="height: 100px; max-height: 80px; margin-top: 100px; justify-content: center; flex-direction: column;">
<div style="height: 20px; width: 20px;"></div>
</div>
@@ -120,59 +120,3 @@
<div style="width: 20px;"></div>
<div style="width: 20px;"></div>
</div>
<div id="justify_content_overflow_row_flex_start" style="width: 102px; height: 102px; flex-direction: row; justify-content: flex-start;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>
<div id="justify_content_overflow_row_flex_end" style="width: 102px; height: 102px; flex-direction: row; justify-content: flex-end;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>
<div id="justify_content_overflow_row_center" style="width: 102px; height: 102px; flex-direction: row; justify-content: center;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>
<div id="justify_content_overflow_row_space_between" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-between;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>
<div id="justify_content_overflow_row_space_around" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-around;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>
<div id="justify_content_overflow_row_space_evenly" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-evenly;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>
<!-- TODO T208209388: fallback to start vs flexstart in overflowed cases -->
<div data-disabled="true" id="justify_content_overflow_row_reverse_space_around" style="width: 102px; height: 102px; flex-direction: row-reverse; justify-content: space-around;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>
<!-- TODO T208209388: fallback to start vs flexstart in overflowed cases -->
<div data-disabled="true" id="justify_content_overflow_row_reverse_space_evenly" style="width: 102px; height: 102px; flex-direction: row-reverse; justify-content: space-evenly;">
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>
<div id="justify_content_overflow_row_space_evenly_auto_margin" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-evenly;">
<div style="width: 40px; margin-right: auto;"></div>
<div style="width: 40px;"></div>
<div style="width: 40px;"></div>
</div>

View File

@@ -60,13 +60,13 @@
<div style="width: 50px; height: 50px;"></div>
</div>
<div id="margin_auto_multiple_children_column" style="width: 200px; height: 200px; flex-direction: column; align-items: center;">
<div id="margin_auto_mutiple_children_column" style="width: 200px; height: 200px; flex-direction: column; align-items: center;">
<div style="width: 50px; height: 50px; margin-top:auto;"></div>
<div style="width: 50px; height: 50px; margin-top:auto;"></div>
<div style="width: 50px; height: 50px;"></div>
</div>
<div id="margin_auto_multiple_children_row" style="width: 200px; height: 200px; flex-direction:row; align-items: center;">
<div id="margin_auto_mutiple_children_row" style="width: 200px; height: 200px; flex-direction:row; align-items: center;">
<div style="width: 50px; height: 50px; margin-right:auto;"></div>
<div style="width: 50px; height: 50px; margin-right:auto;"></div>
<div style="width: 50px; height: 50px;"></div>
@@ -150,8 +150,3 @@
<div style="flex: 1; margin-left:auto;"></div>
<div style="width: 50px; height: 50px;"></div>
</div>
<div id="margin_auto_overflowing_container" style="width: 200px; height: 200px; align-items: center;">
<div style="width: 50px; height: 150px; margin-bottom: auto;"></div>
<div style="width: 50px; height: 150px;"></div>
</div>

View File

@@ -13,17 +13,10 @@
<div style="height: 10px;"></div>
</div>
<div id="padding_center_child"
style="width: 100px; height: 100px; padding-start: 10px; padding-top: 10; padding-end: 20px; padding-bottom: 20px; align-items: center; justify-content: center;">
<div id="padding_center_child" style="width: 100px; height: 100px; padding-start: 10px; padding-top: 10; padding-end: 20px; padding-bottom: 20px; align-items: center; justify-content: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
<div id="child_with_padding_align_end"
style="width: 200px; height: 200px; justify-content: flex-end; align-items: flex-end;">
<div id="child_with_padding_align_end" style="width: 200px; height: 200px; justify-content: flex-end; align-items: flex-end;">
<div style="width: 100px; height: 100px; padding: 20px;"></div>
</div>
<div id="physical_and_relative_edge_defined"
style="width: 200px; height: 200px; padding-left: 20px; padding-end: 50px;">
<div style="width: 100%; height: 50px;"></div>
</div>

View File

@@ -693,20 +693,3 @@
style="height: 50%; width: 50%; position: absolute; border-width: 3px 2px 1px 4px; padding: 7px 5px 4px 3px; margin: 11px 15px 1px 12px">
</div>
</div>
<div id="static_position_absolute_child_multiple">
<div style="width: 400px; height: 400px; padding: 100px; position: relative">
<div style="height:100px; width: 100px; position: static">
<div style="height: 50px; width: 10%; position: absolute">
</div>
</div>
<div style="height:100px; width: 100px; position: static">
<div style="height: 50px; width: 50%; position: absolute">
</div>
<div style="height: 50px; width: 50%; position: absolute">
</div>
</div>
<div style="height: 50px; width: 25px; position: absolute">
</div>
</div>
</div>

Binary file not shown.

View File

@@ -12,7 +12,7 @@ function toValueCpp(value) {
return n + (Number(n) == n && n % 1 !== 0 ? 'f' : '');
}
function toFunctionNameCpp(value) {
function toFunctionName(value) {
if (value.indexOf('%') >= 0) {
return 'Percent';
} else if (value.indexOf('Auto') >= 0) {
@@ -21,23 +21,6 @@ function toFunctionNameCpp(value) {
return '';
}
function keywordFunctionCpp(functionPrefix, nodeName, value) {
const functionSuffix = toFunctionNameCpp(value);
if (functionSuffix == 'Auto') {
return functionPrefix + functionSuffix + '(' + nodeName + ');';
} else {
return (
functionPrefix +
functionSuffix +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');'
);
}
}
const CPPEmitter = function () {
Emitter.call(this, 'cpp', ' ');
};
@@ -47,12 +30,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
emitPrologue: {
value: function () {
this.push([
'#include <gtest/gtest.h>',
'#include <yoga/Yoga.h>',
'#include "../util/TestUtil.h"',
'',
]);
this.push(['#include <gtest/gtest.h>', '#include <yoga/Yoga.h>', '']);
},
},
@@ -66,7 +44,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
this.push('');
}
this.push('YGConfigRef config = YGConfigNew();');
this.push('const YGConfigRef config = YGConfigNew();');
for (const i in experiments) {
this.push(
'YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeature' +
@@ -80,7 +58,9 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
emitTestTreePrologue: {
value: function (nodeName) {
this.push('YGNodeRef ' + nodeName + ' = YGNodeNewWithConfig(config);');
this.push(
'const YGNodeRef ' + nodeName + ' = YGNodeNewWithConfig(config);',
);
},
},
@@ -153,14 +133,10 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGWrapWrap: {value: 'YGWrapWrap'},
YGWrapWrapReverse: {value: 'YGWrapWrapReverse'},
YGBoxSizingBorderBox: {value: 'YGBoxSizingBorderBox'},
YGBoxSizingContentBox: {value: 'YGBoxSizingContentBox'},
YGUndefined: {value: 'YGUndefined'},
YGDisplayFlex: {value: 'YGDisplayFlex'},
YGDisplayNone: {value: 'YGDisplayNone'},
YGDisplayContents: {value: 'YGDisplayContents'},
YGAuto: {value: 'YGAuto'},
YGNodeCalculateLayout: {
@@ -249,7 +225,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetAspectRatio' +
toFunctionNameCpp(value) +
toFunctionName(value) +
'(' +
nodeName +
', ' +
@@ -291,7 +267,15 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetFlexBasis: {
value: function (nodeName, value) {
this.push(keywordFunctionCpp('YGNodeStyleSetFlexBasis', nodeName, value));
this.push(
'YGNodeStyleSetFlexBasis' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
},
},
@@ -335,6 +319,20 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetHeight: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetHeight' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
},
},
YGNodeStyleSetJustifyContent: {
value: function (nodeName, value) {
this.push(
@@ -357,7 +355,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
}
this.push(
'YGNodeStyleSetMargin' +
toFunctionNameCpp(value) +
toFunctionName(value) +
'(' +
nodeName +
', ' +
@@ -368,23 +366,11 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetHeight: {
value: function (nodeName, value) {
this.push(keywordFunctionCpp('YGNodeStyleSetHeight', nodeName, value));
},
},
YGNodeStyleSetWidth: {
value: function (nodeName, value) {
this.push(keywordFunctionCpp('YGNodeStyleSetWidth', nodeName, value));
},
},
YGNodeStyleSetMaxHeight: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetMaxHeight' +
toFunctionNameCpp(value) +
toFunctionName(value) +
'(' +
nodeName +
', ' +
@@ -398,7 +384,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetMaxWidth' +
toFunctionNameCpp(value) +
toFunctionName(value) +
'(' +
nodeName +
', ' +
@@ -412,7 +398,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetMinHeight' +
toFunctionNameCpp(value) +
toFunctionName(value) +
'(' +
nodeName +
', ' +
@@ -426,7 +412,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetMinWidth' +
toFunctionNameCpp(value) +
toFunctionName(value) +
'(' +
nodeName +
', ' +
@@ -448,7 +434,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
value: function (nodeName, edge, value) {
this.push(
'YGNodeStyleSetPadding' +
toFunctionNameCpp(value) +
toFunctionName(value) +
'(' +
nodeName +
', ' +
@@ -462,20 +448,15 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetPosition: {
value: function (nodeName, edge, value) {
let valueStr = toValueCpp(value);
if (valueStr != 'YGAuto') {
valueStr = ', ' + valueStr;
} else {
valueStr = '';
}
this.push(
'YGNodeStyleSetPosition' +
toFunctionNameCpp(value) +
toFunctionName(value) +
'(' +
nodeName +
', ' +
edge +
valueStr +
', ' +
toValueCpp(value) +
');',
);
},
@@ -493,11 +474,25 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetWidth: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetWidth' +
toFunctionName(value) +
'(' +
nodeName +
', ' +
toValueCpp(value) +
');',
);
},
},
YGNodeStyleSetGap: {
value: function (nodeName, gap, value) {
this.push(
'YGNodeStyleSetGap' +
toFunctionNameCpp(value) +
toFunctionName(value) +
'(' +
nodeName +
', ' +
@@ -508,21 +503,4 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
);
},
},
YGNodeStyleSetBoxSizing: {
value: function (nodeName, value) {
this.push(
'YGNodeStyleSetBoxSizing(' + nodeName + ', ' + toValueCpp(value) + ');',
);
},
},
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText) {
this.push(`YGNodeSetContext(${nodeName}, (void*)"${innerText}");`);
this.push(
`YGNodeSetMeasureFunc(${nodeName}, &facebook::yoga::test::IntrinsicSizeMeasure);`,
);
},
},
});

View File

@@ -100,21 +100,15 @@ for (const fileName of fixtures) {
await driver.get('file://' + process.cwd() + '/test.html');
const logs = await driver.manage().logs().get(logging.Type.BROWSER);
const testLogs = logs.filter(
log => !log.message.replace(/^[^"]*/, '').startsWith('"gentest-log:'),
);
await fs.writeFile(
`${yogaDir}/tests/generated/${fileNameNoExtension}.cpp`,
addSignatureToSourceCode(
JSON.parse(testLogs[0].message.replace(/^[^"]*/, '')),
),
addSignatureToSourceCode(JSON.parse(logs[0].message.replace(/^[^"]*/, ''))),
);
await fs.writeFile(
`${yogaDir}/java/tests/generated/com/facebook/yoga/${fileNameNoExtension}.java`,
`${yogaDir}/java/tests/com/facebook/yoga/${fileNameNoExtension}.java`,
addSignatureToSourceCode(
JSON.parse(testLogs[1].message.replace(/^[^"]*/, '')).replace(
JSON.parse(logs[1].message.replace(/^[^"]*/, '')).replace(
'YogaTest',
fileNameNoExtension,
),
@@ -124,7 +118,7 @@ for (const fileName of fixtures) {
await fs.writeFile(
`${yogaDir}/javascript/tests/generated/${fileNameNoExtension}.test.ts`,
addSignatureToSourceCode(
JSON.parse(testLogs[2].message.replace(/^[^"]*/, '')).replace(
JSON.parse(logs[2].message.replace(/^[^"]*/, '')).replace(
'YogaTest',
fileNameNoExtension,
),

View File

@@ -21,23 +21,6 @@ function toMethodName(value) {
return '';
}
function keywordMethod(methodPrefix, nodeName, value) {
const methodSuffix = toMethodName(value);
if (methodSuffix == 'Auto') {
return nodeName + '.' + methodPrefix + methodSuffix + '();';
} else {
return (
nodeName +
'.' +
methodPrefix +
methodSuffix +
'(' +
toValueJava(value) +
'f);'
);
}
}
const JavaEmitter = function () {
Emitter.call(this, 'java', ' ');
};
@@ -72,7 +55,6 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
'import org.junit.Test;',
'import org.junit.runner.RunWith;',
'import org.junit.runners.Parameterized;',
'import com.facebook.yoga.utils.TestUtils;',
'',
'@RunWith(Parameterized.class)',
'public class YogaTest {',
@@ -195,16 +177,12 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGDisplayFlex: {value: 'YogaDisplay.FLEX'},
YGDisplayNone: {value: 'YogaDisplay.NONE'},
YGDisplayContents: {value: 'YogaDisplay.CONTENTS'},
YGAuto: {value: 'YogaConstants.AUTO'},
YGWrapNoWrap: {value: 'YogaWrap.NO_WRAP'},
YGWrapWrap: {value: 'YogaWrap.WRAP'},
YGWrapWrapReverse: {value: 'YogaWrap.WRAP_REVERSE'},
YGBoxSizingBorderBox: {value: 'YogaBoxSizing.BORDER_BOX'},
YGBoxSizingContentBox: {value: 'YogaBoxSizing.CONTENT_BOX'},
YGNodeCalculateLayout: {
value: function (node, dir, _experiments) {
this.push(node + '.setDirection(' + dir + ');');
@@ -291,7 +269,14 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetFlexBasis: {
value: function (nodeName, value) {
this.push(keywordMethod('setFlexBasis', nodeName, value));
this.push(
nodeName +
'.setFlexBasis' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
},
},
@@ -319,6 +304,19 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetHeight: {
value: function (nodeName, value) {
this.push(
nodeName +
'.setHeight' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
},
},
YGNodeStyleSetJustifyContent: {
value: function (nodeName, value) {
this.push(nodeName + '.setJustifyContent(' + toValueJava(value) + ');');
@@ -346,18 +344,6 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetHeight: {
value: function (nodeName, value) {
this.push(keywordMethod('setHeight', nodeName, value));
},
},
YGNodeStyleSetWidth: {
value: function (nodeName, value) {
this.push(keywordMethod('setWidth', nodeName, value));
},
},
YGNodeStyleSetMaxHeight: {
value: function (nodeName, value) {
this.push(
@@ -433,21 +419,15 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetPosition: {
value: function (nodeName, edge, value) {
let valueStr = toValueJava(value);
if (valueStr == 'YogaConstants.AUTO') {
valueStr = '';
} else {
valueStr = ', ' + valueStr + 'f';
}
this.push(
nodeName +
'.setPosition' +
toMethodName(value) +
'(' +
edge +
valueStr +
');',
', ' +
toValueJava(value) +
'f);',
);
},
},
@@ -458,6 +438,19 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
},
},
YGNodeStyleSetWidth: {
value: function (nodeName, value) {
this.push(
nodeName +
'.setWidth' +
toMethodName(value) +
'(' +
toValueJava(value) +
'f);',
);
},
},
YGNodeStyleSetGap: {
value: function (nodeName, gap, value) {
this.push(
@@ -472,19 +465,4 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
);
},
},
YGNodeStyleSetBoxSizing: {
value: function (nodeName, value) {
this.push(nodeName + '.setBoxSizing(' + toValueJava(value) + ');');
},
},
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText) {
this.push(`${nodeName}.setData("${innerText}");`);
this.push(
`${nodeName}.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());`,
);
},
},
});

View File

@@ -23,14 +23,10 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
emitPrologue: {
value: function () {
this.push(
"import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'",
);
this.push("import Yoga from 'yoga-layout';");
this.push('import {');
this.pushIndent();
this.push('Align,');
this.push('BoxSizing,');
this.push('Direction,');
this.push('Display,');
this.push('Edge,');
@@ -171,10 +167,6 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
YGDisplayFlex: {value: 'Display.Flex'},
YGDisplayNone: {value: 'Display.None'},
YGDisplayContents: {value: 'Display.Contents'},
YGBoxSizingBorderBox: {value: 'BoxSizing.BorderBox'},
YGBoxSizingContentBox: {value: 'BoxSizing.ContentBox'},
YGNodeCalculateLayout: {
value: function (node, dir, _experiments) {
@@ -369,22 +361,14 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetPosition: {
value: function (nodeName, edge, value) {
const valueStr = toValueJavascript(value);
if (valueStr == "'auto'") {
this.push(
nodeName + '.setPositionAuto(' + toValueJavascript(edge) + ');',
);
} else {
this.push(
nodeName +
'.setPosition(' +
toValueJavascript(edge) +
', ' +
valueStr +
');',
);
}
this.push(
nodeName +
'.setPosition(' +
toValueJavascript(edge) +
', ' +
toValueJavascript(value) +
');',
);
},
},
@@ -414,18 +398,4 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
);
},
},
YGNodeStyleSetBoxSizing: {
value: function (nodeName, value) {
this.push(nodeName + '.setBoxSizing(' + toValueJavascript(value) + ');');
},
},
YGNodeSetMeasureFunc: {
value: function (nodeName, innerText) {
this.push(
`${nodeName}.setMeasureFunc(instrinsicSizeMeasureFunc.bind("${innerText}"));`,
);
},
},
});

View File

@@ -11,33 +11,30 @@ import * as fs from 'node:fs/promises';
import {dirname} from 'path';
import {fileURLToPath} from 'url';
import signedsource from 'signedsource';
import {glob} from 'glob';
const yogaRootDir = dirname(dirname(fileURLToPath(import.meta.url)));
const yogaDir = dirname(dirname(fileURLToPath(import.meta.url)));
const cppTestDir = `${yogaDir}/tests/generated`;
const jsTestDir = `${yogaDir}/javascript/tests/generated`;
const javaTestDir = `${yogaDir}/java/tests/com/facebook/yoga`;
const testDirs = [cppTestDir, jsTestDir, javaTestDir];
const filesToValidate = await glob(
[
'tests/generated/**/*.{h,cpp}',
'javascript/tests/generated/**/*.test.ts',
'java/tests/generated/com/facebook/yoga/**/*.java',
],
{
cwd: yogaRootDir,
},
);
for (const testDir of testDirs) {
const tests = await fs.readdir(testDir);
console.log(`Found ${filesToValidate.length} files to validate`);
for (const file of filesToValidate) {
const content = await fs.readFile(`${yogaRootDir}/${file}`, 'utf8');
if (signedsource.isSigned(content)) {
console.log(`Checking ${file}`);
const validSignature = signedsource.verifySignature(content);
if (!validSignature) {
console.error(`Invalid signature "${file}"`);
process.exitCode = 1;
for (const test of tests) {
const testData = await fs.readFile(`${testDir}/${test}`, 'utf8');
try {
const validSignature = signedsource.verifySignature(testData);
if (!validSignature) {
console.error(`Invalid signature for ${test}`);
process.exitCode = 1;
}
} catch (e) {
// Java test dir does not separate generated tests from non-generated ones
if (testDir != javaTestDir) {
console.error(`${test}: ${e}`);
process.exitCode = 1;
}
}
} else {
console.log(`Skipped ${file}`);
}
}

View File

@@ -175,7 +175,6 @@ function checkDefaultValues() {
{style: 'right', value: 'undefined'},
{style: 'bottom', value: 'undefined'},
{style: 'display', value: 'flex'},
{style: 'box-sizing', value: 'border-box'},
].forEach(item => {
assert(
isDefaultStyleValue(item.style, item.value),
@@ -194,6 +193,7 @@ function setupTestTree(
index,
) {
e.emitTestTreePrologue(nodeName);
for (const style in node.style) {
// Skip position info for root as it messes up tests
if (
@@ -207,6 +207,7 @@ function setupTestTree(
) {
continue;
}
if (!isDefaultStyleValue(style, node.style[style])) {
switch (style) {
case 'aspect-ratio':
@@ -519,11 +520,6 @@ function setupTestTree(
case 'display':
e.YGNodeStyleSetDisplay(nodeName, displayValue(e, node.style[style]));
break;
case 'box-sizing':
e.YGNodeStyleSetBoxSizing(
nodeName,
boxSizingValue(e, node.style[style]),
);
}
}
}
@@ -532,10 +528,6 @@ function setupTestTree(
e.YGNodeInsertChild(parentName, nodeName, index);
}
if (node.innerText && node.children.length === 0) {
e.YGNodeSetMeasureFunc(nodeName, node.innerText);
}
for (let i = 0; i < node.children.length; i++) {
e.push('');
const childName = nodeName + '_child' + i;
@@ -665,17 +657,6 @@ function displayValue(e, value) {
return e.YGDisplayFlex;
case 'none':
return e.YGDisplayNone;
case 'contents':
return e.YGDisplayContents;
}
}
function boxSizingValue(e, value) {
switch (value) {
case 'border-box':
return e.YGBoxSizingBorderBox;
case 'content-box':
return e.YGBoxSizingContentBox;
}
}
@@ -742,7 +723,6 @@ function calculateTree(root, parentOffsetLeft, parentOffsetTop) {
? child.dataset.experiments.split(' ')
: [],
disabled: child.dataset.disabled === 'true',
innerText: child.innerText,
};
const size = getRoundedSize(child);
@@ -797,7 +777,6 @@ function getYogaStyle(node) {
'row-gap',
'display',
'aspect-ratio',
'box-sizing',
].reduce((map, key) => {
map[key] =
node.style[key] || getComputedStyle(node, null).getPropertyValue(key);

View File

@@ -3,8 +3,8 @@
"version": "0.0.0",
"private": true,
"scripts": {
"gentest": "node --disable-warning=ExperimentalWarning --loader=babel-register-esm ./gentest-driver.ts",
"gentest-validate": "node --disable-warning=ExperimentalWarning --loader=babel-register-esm ./gentest-validate.ts"
"gentest": "node --loader=babel-register-esm ./gentest-driver.ts",
"gentest-validate": "node --loader=babel-register-esm ./gentest-validate.ts"
},
"type": "module",
"dependencies": {
@@ -19,7 +19,6 @@
"@types/minimist": "^1.2.5",
"@types/node": "^20.10.3",
"@types/selenium-webdriver": "^4.1.21",
"babel-register-esm": "^1.2.5",
"glob": "^10.4.2"
"babel-register-esm": "^1.2.5"
}
}

View File

@@ -1,79 +1,70 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>%s</title>
<script src="gentest.js"></script>
<script src="gentest-cpp.js"></script>
<script src="gentest-java.js"></script>
<script src="gentest-javascript.js"></script>
<head>
<meta charset="UTF-8">
<title>%s</title>
<script src="gentest.js"></script>
<script src="gentest-cpp.js"></script>
<script src="gentest-java.js"></script>
<script src="gentest-javascript.js"></script>
<script src="gentest-log.js"></script>
<style>
body {
padding: 0;
margin: 0;
font-family: Helvetica;
font-size: 14px;
font-weight: 100;
}
<style>
@font-face {
font-family: 'Ahem';
src: url('./fonts/Ahem.ttf') format('truetype');
}
div, span {
box-sizing: border-box;
position: relative;
border: 0 solid black;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: stretch;
align-content: flex-start;
justify-content: flex-start;
flex-shrink: 0;
}
body {
padding: 0;
margin: 0;
font: 10px/1 Ahem;
font-weight: 100;
}
body > * {
position: absolute;
}
div,
span {
box-sizing: border-box;
position: relative;
border: 0 solid black;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: stretch;
align-content: flex-start;
justify-content: flex-start;
flex-shrink: 0;
}
#ltr-container > * {
position: absolute;
direction: ltr;
}
body>* {
position: absolute;
}
#rtl-container > * {
position: absolute;
direction: rtl;
}
</style>
</head>
#ltr-container>* {
position: absolute;
direction: ltr;
}
<body>
<div id='ltr-container'>
#rtl-container>* {
position: absolute;
direction: rtl;
}
%s
</style>
</head>
<div id='default'></div>
</div>
<div id='rtl-container'>
<body>
<div id='ltr-container'>
%s
%s
<div id='default'></div>
</div>
<div id='default'></div>
</div>
<div id='rtl-container'>
<div>
%s
<div id='default'></div>
</div>
<div>
%s
</div>
</body>
%s
</div>
</body>
</html>

View File

@@ -11,4 +11,4 @@ android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
VERSION_NAME=3.2.1
VERSION_NAME=3.0.3

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -21,16 +21,15 @@ val ndkVersionProperty: String by rootProject.extra
android {
namespace = "com.facebook.yoga"
compileSdk = 35
buildToolsVersion = "35.0.0"
ndkVersion = "27.1.12297006"
compileSdk = 34
buildToolsVersion = "34.0.0"
ndkVersion = "26.0.10792818"
defaultConfig {
minSdk = 21
consumerProguardFiles("proguard-rules.pro")
ndk { abiFilters.addAll(setOf("x86", "x86_64", "armeabi-v7a", "arm64-v8a")) }
externalNativeBuild { cmake { arguments("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON") } }
}
externalNativeBuild { cmake { path("CMakeLists.txt") } }

View File

@@ -1,33 +0,0 @@
/*
* 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.
*/
// @generated by enums.py
package com.facebook.yoga;
public enum YogaBoxSizing {
BORDER_BOX(0),
CONTENT_BOX(1);
private final int mIntValue;
YogaBoxSizing(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static YogaBoxSizing fromInt(int value) {
switch (value) {
case 0: return BORDER_BOX;
case 1: return CONTENT_BOX;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}
}

View File

@@ -11,8 +11,7 @@ package com.facebook.yoga;
public enum YogaDisplay {
FLEX(0),
NONE(1),
CONTENTS(2);
NONE(1);
private final int mIntValue;
@@ -28,7 +27,6 @@ public enum YogaDisplay {
switch (value) {
case 0: return FLEX;
case 1: return NONE;
case 2: return CONTENTS;
default: throw new IllegalArgumentException("Unknown enum value: " + value);
}
}

View File

@@ -12,7 +12,7 @@ package com.facebook.yoga;
public enum YogaErrata {
NONE(0),
STRETCH_FLEX_BASIS(1),
ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING(2),
ABSOLUTE_POSITIONING_INCORRECT(2),
ABSOLUTE_PERCENT_AGAINST_INNER_SIZE(4),
ALL(2147483647),
CLASSIC(2147483646);
@@ -31,7 +31,7 @@ public enum YogaErrata {
switch (value) {
case 0: return NONE;
case 1: return STRETCH_FLEX_BASIS;
case 2: return ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING;
case 2: return ABSOLUTE_POSITIONING_INCORRECT;
case 4: return ABSOLUTE_PERCENT_AGAINST_INNER_SIZE;
case 2147483647: return ALL;
case 2147483646: return CLASSIC;

View File

@@ -56,8 +56,6 @@ public class YogaNative {
static native void jni_YGNodeStyleSetAlignContentJNI(long nativePointer, int alignContent);
static native int jni_YGNodeStyleGetPositionTypeJNI(long nativePointer);
static native void jni_YGNodeStyleSetPositionTypeJNI(long nativePointer, int positionType);
static native int jni_YGNodeStyleGetBoxSizingJNI(long nativePointer);
static native void jni_YGNodeStyleSetBoxSizingJNI(long nativePointer, int boxSizing);
static native int jni_YGNodeStyleGetFlexWrapJNI(long nativePointer);
static native void jni_YGNodeStyleSetFlexWrapJNI(long nativePointer, int wrapType);
static native int jni_YGNodeStyleGetOverflowJNI(long nativePointer);
@@ -86,7 +84,6 @@ public class YogaNative {
static native long jni_YGNodeStyleGetPositionJNI(long nativePointer, int edge);
static native void jni_YGNodeStyleSetPositionJNI(long nativePointer, int edge, float position);
static native void jni_YGNodeStyleSetPositionPercentJNI(long nativePointer, int edge, float percent);
static native void jni_YGNodeStyleSetPositionAutoJNI(long nativePointer, int edge);
static native long jni_YGNodeStyleGetWidthJNI(long nativePointer);
static native void jni_YGNodeStyleSetWidthJNI(long nativePointer, float width);
static native void jni_YGNodeStyleSetWidthPercentJNI(long nativePointer, float percent);
@@ -111,7 +108,6 @@ public class YogaNative {
static native void jni_YGNodeStyleSetAspectRatioJNI(long nativePointer, float aspectRatio);
static native float jni_YGNodeStyleGetGapJNI(long nativePointer, int gutter);
static native void jni_YGNodeStyleSetGapJNI(long nativePointer, int gutter, float gapLength);
static native void jni_YGNodeStyleSetGapPercentJNI(long nativePointer, int gutter, float gapLength);
static native void jni_YGNodeSetHasMeasureFuncJNI(long nativePointer, boolean hasMeasureFunc);
static native void jni_YGNodeSetHasBaselineFuncJNI(long nativePointer, boolean hasMeasureFunc);
static native void jni_YGNodeSetStyleInputsJNI(long nativePointer, float[] styleInputsArray, int size);

View File

@@ -88,10 +88,6 @@ public abstract class YogaNode implements YogaProps {
public abstract void setPositionType(YogaPositionType positionType);
public abstract YogaBoxSizing getBoxSizing();
public abstract void setBoxSizing(YogaBoxSizing boxSizing);
public abstract YogaWrap getWrap();
public abstract void setWrap(YogaWrap flexWrap);
@@ -148,8 +144,6 @@ public abstract class YogaNode implements YogaProps {
public abstract void setPositionPercent(YogaEdge edge, float percent);
public abstract void setPositionAuto(YogaEdge edge);
public abstract YogaValue getWidth();
public abstract void setWidth(float width);
@@ -198,8 +192,6 @@ public abstract class YogaNode implements YogaProps {
public abstract void setGap(YogaGutter gutter, float gapLength);
public abstract void setGapPercent(YogaGutter gutter, float gapLength);
public abstract float getLayoutX();
public abstract float getLayoutY();

View File

@@ -32,7 +32,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
private static final byte LAYOUT_BORDER_START_INDEX = 14;
@Nullable private YogaNodeJNIBase mOwner;
@Nullable private YogaConfig mConfig;
@Nullable private List<YogaNodeJNIBase> mChildren;
@Nullable private YogaMeasureFunction mMeasureFunction;
@Nullable private YogaBaselineFunction mBaselineFunction;
@@ -58,7 +57,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNodeJNIBase(YogaConfig config) {
this(YogaNative.jni_YGNodeNewWithConfigJNI(((YogaConfigJNIBase) config).mNativePointer));
mConfig = config; // makes sure the YogaConfig is not garbage collected
}
public void reset() {
@@ -301,14 +299,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetPositionTypeJNI(mNativePointer, positionType.intValue());
}
public YogaBoxSizing getBoxSizing() {
return YogaBoxSizing.fromInt(YogaNative.jni_YGNodeStyleGetBoxSizingJNI(mNativePointer));
}
public void setBoxSizing(YogaBoxSizing boxSizing) {
YogaNative.jni_YGNodeStyleSetBoxSizingJNI(mNativePointer, boxSizing.intValue());
}
public YogaWrap getWrap() {
return YogaWrap.fromInt(YogaNative.jni_YGNodeStyleGetFlexWrapJNI(mNativePointer));
}
@@ -421,10 +411,6 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetPositionPercentJNI(mNativePointer, edge.intValue(), percent);
}
public void setPositionAuto(YogaEdge edge) {
YogaNative.jni_YGNodeStyleSetPositionAutoJNI(mNativePointer, edge.intValue());
}
public YogaValue getWidth() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer));
}
@@ -735,9 +721,4 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
public void setGap(YogaGutter gutter, float gapLength) {
YogaNative.jni_YGNodeStyleSetGapJNI(mNativePointer, gutter.intValue(), gapLength);
}
@Override
public void setGapPercent(YogaGutter gutter, float gapLength) {
YogaNative.jni_YGNodeStyleSetGapPercentJNI(mNativePointer, gutter.intValue(), gapLength);
}
}

View File

@@ -105,8 +105,6 @@ public interface YogaProps {
void setBaselineFunction(YogaBaselineFunction yogaBaselineFunction);
void setBoxSizing(YogaBoxSizing boxSizing);
/* Getters */
YogaValue getWidth();
@@ -150,6 +148,4 @@ public interface YogaProps {
YogaValue getPosition(YogaEdge edge);
float getBorder(YogaEdge edge);
YogaBoxSizing getBoxSizing();
}

View File

@@ -33,10 +33,9 @@ namespace facebook::yoga::vanillajni {
*
* This class is very explicit in its behavior, and it does not allow to perform
* unexpected conversions or unexpected ownership transfer. In practice, this
* class acts as a unique pointer where the underlying JNI reference can have
* one and just one owner. Transferring ownership is allowed but it is an
* explicit operation (implemented via move semantics and also via explicitly
* API calls).
* class acts as a unique pointer where the underying JNI reference can have one
* and just one owner. Transferring ownership is allowed but it is an explicit
* operation (implemented via move semantics and also via explicitly API calls).
*
* Note that this class doesn't receive an explicit JNIEnv at construction time.
* At destruction time it uses vanillajni::getCurrentEnv() to retrieve the
@@ -63,7 +62,7 @@ class ScopedGlobalRef {
*
* @param globalRef the global reference to wrap. Can be NULL.
*/
explicit ScopedGlobalRef(T globalRef) : mGlobalRef(globalRef) {}
ScopedGlobalRef(T globalRef) : mGlobalRef(globalRef) {}
/**
* Equivalent to ScopedGlobalRef(NULL)
@@ -73,12 +72,12 @@ class ScopedGlobalRef {
/**
* Move construction is allowed.
*/
ScopedGlobalRef(ScopedGlobalRef&& s) noexcept : mGlobalRef(s.release()) {}
ScopedGlobalRef(ScopedGlobalRef&& s) : mGlobalRef(s.release()) {}
/**
* Move assignment is allowed.
*/
ScopedGlobalRef& operator=(ScopedGlobalRef&& s) noexcept {
ScopedGlobalRef& operator=(ScopedGlobalRef&& s) {
reset(s.release());
return *this;
}

View File

@@ -35,10 +35,9 @@ namespace facebook::yoga::vanillajni {
*
* This class is very explicit in its behavior, and it does not allow to perform
* unexpected conversions or unexpected ownership transfer. In practice, this
* class acts as a unique pointer where the underlying JNI reference can have
* one and just one owner. Transferring ownership is allowed but it is an
* explicit operation (implemented via move semantics and also via explicitly
* API calls).
* class acts as a unique pointer where the underying JNI reference can have one
* and just one owner. Transferring ownership is allowed but it is an explicit
* operation (implemented via move semantics and also via explicitly API calls).
*
* As with standard JNI local references it is not a valid operation to keep a
* reference around between different native method calls.
@@ -71,13 +70,12 @@ class ScopedLocalRef {
/**
* Move construction is allowed.
*/
ScopedLocalRef(ScopedLocalRef&& s) noexcept
: mEnv(s.mEnv), mLocalRef(s.release()) {}
ScopedLocalRef(ScopedLocalRef&& s) : mEnv(s.mEnv), mLocalRef(s.release()) {}
/**
* Move assignment is allowed.
*/
ScopedLocalRef& operator=(ScopedLocalRef&& s) noexcept {
ScopedLocalRef& operator=(ScopedLocalRef&& s) {
reset(s.release());
mEnv = s.mEnv;
return *this;

View File

@@ -36,7 +36,7 @@ class YGNodeEdges {
BORDER = 4,
};
explicit YGNodeEdges(YGNodeRef node) {
YGNodeEdges(YGNodeRef node) {
auto context = YGNodeContext{};
context.asVoidPtr = YGNodeGetContext(node);
edges_ = context.edgesSet;

View File

@@ -54,9 +54,7 @@ static void jni_YGConfigSetExperimentalFeatureEnabledJNI(
jboolean enabled) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetExperimentalFeatureEnabled(
config,
static_cast<YGExperimentalFeature>(feature),
static_cast<bool>(enabled));
config, static_cast<YGExperimentalFeature>(feature), enabled);
}
static void jni_YGConfigSetUseWebDefaultsJNI(
@@ -65,7 +63,7 @@ static void jni_YGConfigSetUseWebDefaultsJNI(
jlong nativePointer,
jboolean useWebDefaults) {
const YGConfigRef config = _jlong2YGConfigRef(nativePointer);
YGConfigSetUseWebDefaults(config, static_cast<bool>(useWebDefaults));
YGConfigSetUseWebDefaults(config, useWebDefaults);
}
static void jni_YGConfigSetPointScaleFactorJNI(
@@ -163,7 +161,7 @@ static void jni_YGConfigSetLoggerJNI(
auto context =
reinterpret_cast<ScopedGlobalRef<jobject>*>(YGConfigGetContext(config));
if (logger != nullptr) {
if (logger) {
if (context == nullptr) {
context = new ScopedGlobalRef<jobject>();
YGConfigSetContext(config, context);
@@ -227,15 +225,14 @@ static void jni_YGNodeSetIsReferenceBaselineJNI(
jlong nativePointer,
jboolean isReferenceBaseline) {
YGNodeSetIsReferenceBaseline(
_jlong2YGNodeRef(nativePointer), static_cast<bool>(isReferenceBaseline));
_jlong2YGNodeRef(nativePointer), isReferenceBaseline);
}
static jboolean jni_YGNodeIsReferenceBaselineJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer) {
return static_cast<jboolean>(
YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer)));
return YGNodeIsReferenceBaseline(_jlong2YGNodeRef(nativePointer));
}
static void jni_YGNodeRemoveAllChildrenJNI(
@@ -343,7 +340,7 @@ static void jni_YGNodeCalculateLayoutJNI(
try {
PtrJNodeMapVanilla* layoutContext = nullptr;
auto map = PtrJNodeMapVanilla{};
if (nativePointers != nullptr) {
if (nativePointers) {
map = PtrJNodeMapVanilla{nativePointers, javaNodes};
layoutContext = &map;
}
@@ -359,7 +356,7 @@ static void jni_YGNodeCalculateLayoutJNI(
YGTransferLayoutOutputsRecursive(env, obj, root);
} catch (const YogaJniException& jniException) {
ScopedLocalRef<jthrowable> throwable = jniException.getThrowable();
if (throwable.get() != nullptr) {
if (throwable.get()) {
env->Throw(throwable.get());
}
} catch (const std::logic_error& ex) {
@@ -460,14 +457,6 @@ static void jni_YGNodeCopyStyleJNI(
static_cast<float>(value)); \
}
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(name) \
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
static void jni_YGNodeStyleSet##name##AutoJNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
YGNodeStyleSet##name##Auto( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
}
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
@@ -475,7 +464,6 @@ YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignItems);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignSelf);
YG_NODE_JNI_STYLE_PROP(jint, YGAlign, AlignContent);
YG_NODE_JNI_STYLE_PROP(jint, YGPositionType, PositionType);
YG_NODE_JNI_STYLE_PROP(jint, YGBoxSizing, BoxSizing);
YG_NODE_JNI_STYLE_PROP(jint, YGWrap, FlexWrap);
YG_NODE_JNI_STYLE_PROP(jint, YGOverflow, Overflow);
YG_NODE_JNI_STYLE_PROP(jint, YGDisplay, Display);
@@ -491,7 +479,7 @@ YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Height);
YG_NODE_JNI_STYLE_UNIT_PROP(MinHeight);
YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(Position);
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Position);
static jlong jni_YGNodeStyleGetMarginJNI(
JNIEnv* /*env*/,
@@ -638,8 +626,8 @@ static YGSize YGJNIMeasureFunc(
uint32_t wBits = 0xFFFFFFFF & (measureResult >> 32);
uint32_t hBits = 0xFFFFFFFF & measureResult;
auto measuredWidth = std::bit_cast<float>(wBits);
auto measuredHeight = std::bit_cast<float>(hBits);
float measuredWidth = std::bit_cast<float>(wBits);
float measuredHeight = std::bit_cast<float>(hBits);
return YGSize{measuredWidth, measuredHeight};
} else {
@@ -657,7 +645,7 @@ static void jni_YGNodeSetHasMeasureFuncJNI(
jboolean hasMeasureFunc) {
YGNodeSetMeasureFunc(
_jlong2YGNodeRef(nativePointer),
static_cast<bool>(hasMeasureFunc) ? YGJNIMeasureFunc : nullptr);
hasMeasureFunc ? YGJNIMeasureFunc : nullptr);
}
static float YGJNIBaselineFunc(YGNodeConstRef node, float width, float height) {
@@ -681,7 +669,7 @@ static void jni_YGNodeSetHasBaselineFuncJNI(
jboolean hasBaselineFunc) {
YGNodeSetBaselineFunc(
_jlong2YGNodeRef(nativePointer),
static_cast<bool>(hasBaselineFunc) ? YGJNIBaselineFunc : nullptr);
hasBaselineFunc ? YGJNIBaselineFunc : nullptr);
}
static void jni_YGNodeSetAlwaysFormsContainingBlockJNI(
@@ -690,8 +678,7 @@ static void jni_YGNodeSetAlwaysFormsContainingBlockJNI(
jlong nativePointer,
jboolean alwaysFormsContainingBlock) {
YGNodeSetAlwaysFormsContainingBlock(
_jlong2YGNodeRef(nativePointer),
static_cast<bool>(alwaysFormsContainingBlock));
_jlong2YGNodeRef(nativePointer), alwaysFormsContainingBlock);
}
static jlong
@@ -724,18 +711,6 @@ static void jni_YGNodeStyleSetGapJNI(
static_cast<float>(gapLength));
}
static void jni_YGNodeStyleSetGapPercentJNI(
JNIEnv* /*env*/,
jobject /*obj*/,
jlong nativePointer,
jint gutter,
jfloat gapLength) {
YGNodeStyleSetGapPercent(
_jlong2YGNodeRef(nativePointer),
static_cast<YGGutter>(gutter),
static_cast<float>(gapLength));
}
// Yoga specific properties, not compatible with flexbox specification
YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
@@ -820,12 +795,6 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetPositionTypeJNI",
"(JI)V",
(void*)jni_YGNodeStyleSetPositionTypeJNI},
{"jni_YGNodeStyleGetBoxSizingJNI",
"(J)I",
(void*)jni_YGNodeStyleGetBoxSizingJNI},
{"jni_YGNodeStyleSetBoxSizingJNI",
"(JI)V",
(void*)jni_YGNodeStyleSetBoxSizingJNI},
{"jni_YGNodeStyleGetFlexWrapJNI",
"(J)I",
(void*)jni_YGNodeStyleGetFlexWrapJNI},
@@ -906,9 +875,6 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetPositionPercentJNI",
"(JIF)V",
(void*)jni_YGNodeStyleSetPositionPercentJNI},
{"jni_YGNodeStyleSetPositionAutoJNI",
"(JI)V",
(void*)jni_YGNodeStyleSetPositionAutoJNI},
{"jni_YGNodeStyleGetWidthJNI", "(J)J", (void*)jni_YGNodeStyleGetWidthJNI},
{"jni_YGNodeStyleSetWidthJNI", "(JF)V", (void*)jni_YGNodeStyleSetWidthJNI},
{"jni_YGNodeStyleSetWidthPercentJNI",
@@ -974,9 +940,6 @@ static JNINativeMethod methods[] = {
(void*)jni_YGNodeSetHasMeasureFuncJNI},
{"jni_YGNodeStyleGetGapJNI", "(JI)F", (void*)jni_YGNodeStyleGetGapJNI},
{"jni_YGNodeStyleSetGapJNI", "(JIF)V", (void*)jni_YGNodeStyleSetGapJNI},
{"jni_YGNodeStyleSetGapPercentJNI",
"(JIF)V",
(void*)jni_YGNodeStyleSetGapPercentJNI},
{"jni_YGNodeSetHasBaselineFuncJNI",
"(JZ)V",
(void*)jni_YGNodeSetHasBaselineFuncJNI},

View File

@@ -25,7 +25,7 @@ YogaJniException::YogaJniException(jthrowable throwable) {
throwable_ = newGlobalRef(getCurrentEnv(), throwable);
}
YogaJniException::YogaJniException(YogaJniException&& rhs) noexcept
YogaJniException::YogaJniException(YogaJniException&& rhs)
: throwable_(std::move(rhs.throwable_)) {}
YogaJniException::YogaJniException(const YogaJniException& rhs) {

View File

@@ -22,9 +22,9 @@ class YogaJniException : public std::exception {
explicit YogaJniException(jthrowable throwable);
YogaJniException(YogaJniException&& rhs) noexcept;
YogaJniException(YogaJniException&& rhs);
YogaJniException(const YogaJniException& rhs);
YogaJniException(const YogaJniException& other);
ScopedLocalRef<jthrowable> getThrowable() const noexcept;

View File

@@ -16,7 +16,7 @@ void registerNatives(
size_t numMethods) {
jclass clazz = env->FindClass(className);
assertNoPendingJniExceptionIf(env, clazz == nullptr);
assertNoPendingJniExceptionIf(env, !clazz);
auto result =
env->RegisterNatives(clazz, methods, static_cast<int32_t>(numMethods));
@@ -31,7 +31,7 @@ jmethodID getStaticMethodId(
const char* methodDescriptor) {
jmethodID methodId =
env->GetStaticMethodID(clazz, methodName, methodDescriptor);
assertNoPendingJniExceptionIf(env, methodId == nullptr);
assertNoPendingJniExceptionIf(env, !methodId);
return methodId;
}
@@ -41,7 +41,7 @@ jmethodID getMethodId(
const char* methodName,
const char* methodDescriptor) {
jmethodID methodId = env->GetMethodID(clazz, methodName, methodDescriptor);
assertNoPendingJniExceptionIf(env, methodId == nullptr);
assertNoPendingJniExceptionIf(env, !methodId);
return methodId;
}
@@ -51,7 +51,7 @@ jfieldID getFieldId(
const char* fieldName,
const char* fieldSignature) {
jfieldID fieldId = env->GetFieldID(clazz, fieldName, fieldSignature);
assertNoPendingJniExceptionIf(env, fieldId == nullptr);
assertNoPendingJniExceptionIf(env, !fieldId);
return fieldId;
}
@@ -82,14 +82,14 @@ callStaticObjectMethod(JNIEnv* env, jclass clazz, jmethodID methodId, ...) {
va_start(args, methodId);
jobject result = env->CallStaticObjectMethodV(clazz, methodId, args);
va_end(args);
assertNoPendingJniExceptionIf(env, result == nullptr);
assertNoPendingJniExceptionIf(env, !result);
return make_local_ref(env, result);
}
ScopedGlobalRef<jobject> newGlobalRef(JNIEnv* env, jobject obj) {
jobject result = env->NewGlobalRef(obj);
if (result == nullptr) {
if (!result) {
logErrorMessageAndDie("Could not obtain global reference from object");
}
@@ -97,9 +97,9 @@ ScopedGlobalRef<jobject> newGlobalRef(JNIEnv* env, jobject obj) {
}
ScopedGlobalRef<jthrowable> newGlobalRef(JNIEnv* env, jthrowable obj) {
auto result = static_cast<jthrowable>(env->NewGlobalRef(obj));
jthrowable result = static_cast<jthrowable>(env->NewGlobalRef(obj));
if (result == nullptr) {
if (!result) {
logErrorMessageAndDie("Could not obtain global reference from object");
}

View File

@@ -12,9 +12,9 @@
namespace facebook::yoga::vanillajni {
namespace {
JavaVM* globalVm = nullptr;
JavaVM* globalVm = NULL;
struct JavaVMInitializer {
explicit JavaVMInitializer(JavaVM* vm) {
JavaVMInitializer(JavaVM* vm) {
if (!vm) {
logErrorMessageAndDie(
"You cannot pass a NULL JavaVM to ensureInitialized");
@@ -27,7 +27,7 @@ struct JavaVMInitializer {
jint ensureInitialized(JNIEnv** env, JavaVM* vm) {
static JavaVMInitializer init(vm);
if (env == nullptr) {
if (!env) {
logErrorMessageAndDie(
"Need to pass a valid JNIEnv pointer to vanillajni initialization "
"routine");
@@ -43,7 +43,7 @@ jint ensureInitialized(JNIEnv** env, JavaVM* vm) {
// TODO why we need JNIEXPORT for getCurrentEnv ?
JNIEXPORT JNIEnv* getCurrentEnv() {
JNIEnv* env = nullptr;
JNIEnv* env;
jint ret = globalVm->GetEnv((void**)&env, JNI_VERSION_1_6);
if (ret != JNI_OK) {
logErrorMessageAndDie(
@@ -68,7 +68,7 @@ void assertNoPendingJniException(JNIEnv* env) {
}
auto throwable = env->ExceptionOccurred();
if (throwable == nullptr) {
if (!throwable) {
logErrorMessageAndDie("Unable to get pending JNI exception.");
}
env->ExceptionClear();

View File

@@ -10,8 +10,8 @@
using namespace facebook::yoga;
jint JNI_OnLoad(JavaVM* vm, void* /*unused*/) {
JNIEnv* env = nullptr;
jint JNI_OnLoad(JavaVM* vm, void*) {
JNIEnv* env;
jint ret = vanillajni::ensureInitialized(&env, vm);
YGJNIVanilla::registerNatives(env);
return ret;

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<c4a613bef526a87ca88e3b28e1abc215>>
* @generated SignedSource<<ff8c3bfd84ae0fa4cc6ce4b728200f82>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAbsolutePositionTest {
@@ -70,135 +69,6 @@ public class YGAbsolutePositionTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_left_auto_right() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPositionAuto(YogaEdge.LEFT);
root_child0.setPosition(YogaEdge.RIGHT, 10f);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_left_right_auto() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.LEFT, 10f);
root_child0.setPositionAuto(YogaEdge.RIGHT);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_left_auto_right_auto() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPositionAuto(YogaEdge.LEFT);
root_child0.setPositionAuto(YogaEdge.RIGHT);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_end_bottom() {
YogaConfig config = YogaConfigFactory.create();
@@ -1487,162 +1357,6 @@ public class YGAbsolutePositionTest {
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_padding() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.LEFT, 10f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.RIGHT, 10f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
root_child0.setWidth(200f);
root_child0.setHeight(200f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setPositionType(YogaPositionType.STATIC);
root_child0_child0.setPadding(YogaEdge.LEFT, 50);
root_child0_child0.setPadding(YogaEdge.TOP, 50);
root_child0_child0.setPadding(YogaEdge.RIGHT, 50);
root_child0_child0.setPadding(YogaEdge.BOTTOM, 50);
root_child0_child0.setWidth(200f);
root_child0_child0.setHeight(200f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = createNode(config);
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child0_child0.setWidth(50f);
root_child0_child0_child0.setHeight(50f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(220f, root.getLayoutWidth(), 0.0f);
assertEquals(220f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(220f, root.getLayoutWidth(), 0.0f);
assertEquals(220f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_border() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.LEFT, 10f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.RIGHT, 10f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
root_child0.setWidth(200f);
root_child0.setHeight(200f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setPositionType(YogaPositionType.STATIC);
root_child0_child0.setBorder(YogaEdge.LEFT, 10f);
root_child0_child0.setBorder(YogaEdge.TOP, 10f);
root_child0_child0.setBorder(YogaEdge.RIGHT, 10f);
root_child0_child0.setBorder(YogaEdge.BOTTOM, 10f);
root_child0_child0.setWidth(200f);
root_child0_child0.setHeight(200f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = createNode(config);
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child0_child0.setWidth(50f);
root_child0_child0_child0.setHeight(50f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(220f, root.getLayoutWidth(), 0.0f);
assertEquals(220f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(220f, root.getLayoutWidth(), 0.0f);
assertEquals(220f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(140f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_column_reverse_margin_border() {
YogaConfig config = YogaConfigFactory.create();

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<cafd5a49032616243a68af66ae440904>>
* @generated SignedSource<<d93836c91c231c9c029763da7dc2d911>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAlignContentTest {
@@ -1746,98 +1745,6 @@ public class YGAlignContentTest {
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_space_between_wrapped_negative_space_row_reverse() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setBorder(YogaEdge.LEFT, 60f);
root.setBorder(YogaEdge.TOP, 60f);
root.setBorder(YogaEdge.RIGHT, 60f);
root.setBorder(YogaEdge.BOTTOM, 60f);
root.setWidth(320f);
root.setHeight(320f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root_child0.setJustifyContent(YogaJustify.CENTER);
root_child0.setAlignContent(YogaAlign.SPACE_BETWEEN);
root_child0.setWrap(YogaWrap.WRAP);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setWidthPercent(80f);
root_child0_child0.setHeight(20f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setWidthPercent(80f);
root_child0_child1.setHeight(20f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setWidthPercent(80f);
root_child0_child2.setHeight(20f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(320f, root.getLayoutWidth(), 0.0f);
assertEquals(320f, root.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
assertEquals(60f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(320f, root.getLayoutWidth(), 0.0f);
assertEquals(320f, root.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
assertEquals(60f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_space_between_wrapped_negative_space_gap() {
YogaConfig config = YogaConfigFactory.create();
@@ -2199,17 +2106,17 @@ public class YGAlignContentTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(-25f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(-5f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(15f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
@@ -2227,109 +2134,17 @@ public class YGAlignContentTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(-25f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(-5f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_space_around_wrapped_negative_space_row_reverse() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setBorder(YogaEdge.LEFT, 60f);
root.setBorder(YogaEdge.TOP, 60f);
root.setBorder(YogaEdge.RIGHT, 60f);
root.setBorder(YogaEdge.BOTTOM, 60f);
root.setWidth(320f);
root.setHeight(320f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root_child0.setJustifyContent(YogaJustify.CENTER);
root_child0.setAlignContent(YogaAlign.SPACE_AROUND);
root_child0.setWrap(YogaWrap.WRAP);
root_child0.setHeight(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setWidthPercent(80f);
root_child0_child0.setHeight(20f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setWidthPercent(80f);
root_child0_child1.setHeight(20f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setWidthPercent(80f);
root_child0_child2.setHeight(20f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(320f, root.getLayoutWidth(), 0.0f);
assertEquals(320f, root.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
assertEquals(60f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(320f, root.getLayoutWidth(), 0.0f);
assertEquals(320f, root.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0.getLayoutX(), 0.0f);
assertEquals(60f, root_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(15f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@@ -2385,17 +2200,17 @@ public class YGAlignContentTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(-35f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(30f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(-5f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(60f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
@@ -2413,17 +2228,17 @@ public class YGAlignContentTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(-35f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(30f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(-5f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(60f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@@ -2695,17 +2510,17 @@ public class YGAlignContentTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(-25f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(-5f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(15f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
@@ -2723,17 +2538,17 @@ public class YGAlignContentTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(-25f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(-5f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(40f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(15f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@@ -2789,17 +2604,17 @@ public class YGAlignContentTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(-35f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(30f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(-5f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(60f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
@@ -2817,17 +2632,17 @@ public class YGAlignContentTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(-35f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(30f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(-5f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(60f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(160f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@@ -4415,12 +4230,12 @@ public class YGAlignContentTest {
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(200f, root_child1.getLayoutY(), 0.0f);
assertEquals(150f, root_child1.getLayoutY(), 0.0f);
assertEquals(400f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
@@ -4433,12 +4248,12 @@ public class YGAlignContentTest {
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child1.getLayoutX(), 0.0f);
assertEquals(200f, root_child1.getLayoutY(), 0.0f);
assertEquals(150f, root_child1.getLayoutY(), 0.0f);
assertEquals(400f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
}
@@ -4481,12 +4296,12 @@ public class YGAlignContentTest {
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(7f, root_child0.getLayoutX(), 0.0f);
assertEquals(7f, root_child0.getLayoutY(), 0.0f);
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(7f, root_child1.getLayoutX(), 0.0f);
assertEquals(207f, root_child1.getLayoutY(), 0.0f);
assertEquals(150f, root_child1.getLayoutY(), 0.0f);
assertEquals(400f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
@@ -4499,12 +4314,12 @@ public class YGAlignContentTest {
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(93f, root_child0.getLayoutX(), 0.0f);
assertEquals(7f, root_child0.getLayoutY(), 0.0f);
assertEquals(-50f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(93f, root_child1.getLayoutX(), 0.0f);
assertEquals(207f, root_child1.getLayoutY(), 0.0f);
assertEquals(150f, root_child1.getLayoutY(), 0.0f);
assertEquals(400f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(200f, root_child1.getLayoutHeight(), 0.0f);
}
@@ -5207,305 +5022,6 @@ public class YGAlignContentTest {
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_stretch_and_align_items_flex_end_with_flex_wrap() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setAlignItems(YogaAlign.FLEX_END);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_START);
root_child0.setWidth(150f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(120f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(120f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child1.getLayoutX(), 0.0f);
assertEquals(75f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(250f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(75f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(180f, root_child2.getLayoutX(), 0.0f);
assertEquals(250f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_stretch_and_align_items_flex_start_with_flex_wrap() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_END);
root_child0.setWidth(150f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(120f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(120f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(175f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(180f, root_child2.getLayoutX(), 0.0f);
assertEquals(175f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_stretch_and_align_items_center_with_flex_wrap() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setAlignItems(YogaAlign.CENTER);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_END);
root_child0.setWidth(150f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(120f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(120f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child1.getLayoutX(), 0.0f);
assertEquals(38f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(213f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(38f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(180f, root_child2.getLayoutX(), 0.0f);
assertEquals(213f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_align_content_stretch_and_align_items_stretch_with_flex_wrap() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setAlignContent(YogaAlign.STRETCH);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setAlignSelf(YogaAlign.FLEX_END);
root_child0.setWidth(150f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(120f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(120f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(175f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(150f, root_child0.getLayoutX(), 0.0f);
assertEquals(125f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(120f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(180f, root_child2.getLayoutX(), 0.0f);
assertEquals(175f, root_child2.getLayoutY(), 0.0f);
assertEquals(120f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<e8d11c0e97041bb2f1487f0d87363fdc>>
* @generated SignedSource<<17eb6adbebe0409ff047a82dc3257d91>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignItemsTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAlignItemsTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<90c29809153285d8773124e93961ba55>>
* @generated SignedSource<<473604215dcf5ee686799fe2c2dc2004>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignSelfTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAlignSelfTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<245b1ad71f126cebcb48b66239bbc759>>
* @generated SignedSource<<a6047e80a41c4f9d4de130eaba8f57c0>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAndroidNewsFeed.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAndroidNewsFeed {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<37a01c67158df025b1b43b8378071746>>
* @generated SignedSource<<474f52d92a8fc32c66d5b5c1cc446124>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAspectRatioTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAspectRatioTest {
@@ -179,46 +178,6 @@ public class YGAspectRatioTest {
assertEquals(197f, root_child0_child0_child2_child0_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_zero_aspect_ratio_behaves_like_auto() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(300f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(50f);
root_child0.setAspectRatio(0 / 1f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(250f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<d4e5fb968cdc2a3a64ddc14d21e8f867>>
* @generated SignedSource<<c313aae6965f21b021d2dae0af1173bf>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGBorderTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGBorderTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<6a430747c0b764e9fb683f023b45391a>>
* @generated SignedSource<<0f79d7debf11777b10de09656cb38147>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGDimensionTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGDimensionTest {

View File

@@ -0,0 +1,393 @@
/*
* 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.
*
* @generated SignedSource<<b1b955741beb678b9f3f72a74ad0ae50>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayTest.html
*/
package com.facebook.yoga;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@RunWith(Parameterized.class)
public class YGDisplayTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
return TestParametrization.nodeFactories();
}
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
@Test
public void test_display_none() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_fixed_size() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(20f);
root_child1.setHeight(20f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_with_margin() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.LEFT, 10f);
root_child0.setMargin(YogaEdge.TOP, 10f);
root_child0.setMargin(YogaEdge.RIGHT, 10f);
root_child0.setMargin(YogaEdge.BOTTOM, 10f);
root_child0.setWidth(20f);
root_child0.setHeight(20f);
root_child0.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_with_child() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasisPercent(0f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root_child1.setFlexBasisPercent(0f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
final YogaNode root_child1_child0 = createNode(config);
root_child1_child0.setFlexGrow(1f);
root_child1_child0.setFlexShrink(1f);
root_child1_child0.setFlexBasisPercent(0f);
root_child1_child0.setWidth(20f);
root_child1.addChildAt(root_child1_child0, 0);
final YogaNode root_child2 = createNode(config);
root_child2.setFlexGrow(1f);
root_child2.setFlexShrink(1f);
root_child2.setFlexBasisPercent(0f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_with_position() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setPosition(YogaEdge.TOP, 10f);
root_child1.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_display_none_with_position_absolute() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root_child0.setDisplay(YogaDisplay.NONE);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<5e698842feb033db77ff508df3f33b4a>>
* @generated SignedSource<<4007f83eb3e84f3ee3fcf46d6d7be3bc>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexDirectionTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGFlexDirectionTest {
@@ -4243,49 +4242,6 @@ public class YGFlexDirectionTest {
assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_flex_direction_alternating_with_percent() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(200f);
root.setHeight(300f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setPositionPercent(YogaEdge.LEFT, 10f);
root_child0.setPositionPercent(YogaEdge.TOP, 10f);
root_child0.setWidthPercent(50f);
root_child0.setHeightPercent(50f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(120f, root_child0.getLayoutX(), 0.0f);
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<a33d3aa3ed335ded287fa37f788c321c>>
* @generated SignedSource<<744d504e2ab572337ace7a2589bc3570>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGFlexTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<f977e27ada480c9023d16368fae4fab2>>
* @generated SignedSource<<ef62c060fc074248a6d6db6c619f38d4>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGFlexWrapTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGFlexWrapTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<feba5f3f4c830be8a570d3a4c9deb8eb>>
* @generated SignedSource<<f45f69191b808fe39b56a1473be47963>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGGapTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGGapTest {
@@ -2217,925 +2216,6 @@ public class YGGapTest {
assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_row_gap_percent_wrapping() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setPadding(YogaEdge.LEFT, 10);
root.setPadding(YogaEdge.TOP, 10);
root.setPadding(YogaEdge.RIGHT, 10);
root.setPadding(YogaEdge.BOTTOM, 10);
root.setWidth(300f);
root.setHeight(700f);
root.setGapPercent(YogaGutter.COLUMN, 10f);
root.setGapPercent(YogaGutter.ROW, 10f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(100f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(100f);
root_child2.setHeight(100f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = createNode(config);
root_child3.setWidth(100f);
root_child3.setHeight(100f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = createNode(config);
root_child4.setWidth(100f);
root_child4.setHeight(100f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(138f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child2.getLayoutX(), 0.0f);
assertEquals(178f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(138f, root_child3.getLayoutX(), 0.0f);
assertEquals(178f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child4.getLayoutX(), 0.0f);
assertEquals(346f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child2.getLayoutX(), 0.0f);
assertEquals(178f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child3.getLayoutX(), 0.0f);
assertEquals(178f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child4.getLayoutX(), 0.0f);
assertEquals(346f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
}
@Test
public void test_row_gap_percent_determines_parent_height() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setWidth(300f);
root.setGapPercent(YogaGutter.COLUMN, 10f);
root.setGapPercent(YogaGutter.ROW, 10f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(100f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(100f);
root_child2.setHeight(100f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = createNode(config);
root_child3.setWidth(100f);
root_child3.setHeight(100f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = createNode(config);
root_child4.setWidth(100f);
root_child4.setHeight(100f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(130f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(130f, root_child3.getLayoutX(), 0.0f);
assertEquals(100f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(200f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child3.getLayoutX(), 0.0f);
assertEquals(100f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child4.getLayoutX(), 0.0f);
assertEquals(200f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
}
@Test
public void test_row_gap_percent_wrapping_with_both_content_padding_and_item_padding() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setPadding(YogaEdge.LEFT, 10);
root.setPadding(YogaEdge.TOP, 10);
root.setPadding(YogaEdge.RIGHT, 10);
root.setPadding(YogaEdge.BOTTOM, 10);
root.setWidth(300f);
root.setHeight(700f);
root.setGapPercent(YogaGutter.COLUMN, 10f);
root.setGapPercent(YogaGutter.ROW, 10f);
final YogaNode root_child0 = createNode(config);
root_child0.setPadding(YogaEdge.LEFT, 10);
root_child0.setPadding(YogaEdge.TOP, 10);
root_child0.setPadding(YogaEdge.RIGHT, 10);
root_child0.setPadding(YogaEdge.BOTTOM, 10);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setPadding(YogaEdge.LEFT, 10);
root_child1.setPadding(YogaEdge.TOP, 10);
root_child1.setPadding(YogaEdge.RIGHT, 10);
root_child1.setPadding(YogaEdge.BOTTOM, 10);
root_child1.setWidth(100f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setPadding(YogaEdge.LEFT, 10);
root_child2.setPadding(YogaEdge.TOP, 10);
root_child2.setPadding(YogaEdge.RIGHT, 10);
root_child2.setPadding(YogaEdge.BOTTOM, 10);
root_child2.setWidth(100f);
root_child2.setHeight(100f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = createNode(config);
root_child3.setPadding(YogaEdge.LEFT, 10);
root_child3.setPadding(YogaEdge.TOP, 10);
root_child3.setPadding(YogaEdge.RIGHT, 10);
root_child3.setPadding(YogaEdge.BOTTOM, 10);
root_child3.setWidth(100f);
root_child3.setHeight(100f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = createNode(config);
root_child4.setPadding(YogaEdge.LEFT, 10);
root_child4.setPadding(YogaEdge.TOP, 10);
root_child4.setPadding(YogaEdge.RIGHT, 10);
root_child4.setPadding(YogaEdge.BOTTOM, 10);
root_child4.setWidth(100f);
root_child4.setHeight(100f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(138f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child2.getLayoutX(), 0.0f);
assertEquals(178f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(138f, root_child3.getLayoutX(), 0.0f);
assertEquals(178f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child4.getLayoutX(), 0.0f);
assertEquals(346f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child2.getLayoutX(), 0.0f);
assertEquals(178f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child3.getLayoutX(), 0.0f);
assertEquals(178f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child4.getLayoutX(), 0.0f);
assertEquals(346f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
}
@Test
public void test_row_gap_percent_wrapping_with_both_content_padding() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setPadding(YogaEdge.LEFT, 10);
root.setPadding(YogaEdge.TOP, 10);
root.setPadding(YogaEdge.RIGHT, 10);
root.setPadding(YogaEdge.BOTTOM, 10);
root.setWidth(300f);
root.setHeight(700f);
root.setGapPercent(YogaGutter.COLUMN, 10f);
root.setGapPercent(YogaGutter.ROW, 10f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(100f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(100f);
root_child2.setHeight(100f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = createNode(config);
root_child3.setWidth(100f);
root_child3.setHeight(100f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = createNode(config);
root_child4.setWidth(100f);
root_child4.setHeight(100f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(138f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child2.getLayoutX(), 0.0f);
assertEquals(178f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(138f, root_child3.getLayoutX(), 0.0f);
assertEquals(178f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child4.getLayoutX(), 0.0f);
assertEquals(346f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child2.getLayoutX(), 0.0f);
assertEquals(178f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child3.getLayoutX(), 0.0f);
assertEquals(178f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child4.getLayoutX(), 0.0f);
assertEquals(346f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
}
@Test
public void test_row_gap_percent_wrapping_with_content_margin() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setMargin(YogaEdge.LEFT, 10f);
root.setMargin(YogaEdge.TOP, 10f);
root.setMargin(YogaEdge.RIGHT, 10f);
root.setMargin(YogaEdge.BOTTOM, 10f);
root.setWidth(300f);
root.setHeight(700f);
root.setGapPercent(YogaGutter.COLUMN, 10f);
root.setGapPercent(YogaGutter.ROW, 10f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(100f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(100f);
root_child2.setHeight(100f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = createNode(config);
root_child3.setWidth(100f);
root_child3.setHeight(100f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = createNode(config);
root_child4.setWidth(100f);
root_child4.setHeight(100f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(10f, root.getLayoutX(), 0.0f);
assertEquals(10f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(130f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(170f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(130f, root_child3.getLayoutX(), 0.0f);
assertEquals(170f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(340f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(10f, root.getLayoutX(), 0.0f);
assertEquals(10f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child2.getLayoutX(), 0.0f);
assertEquals(170f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child3.getLayoutX(), 0.0f);
assertEquals(170f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child4.getLayoutX(), 0.0f);
assertEquals(340f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
}
@Test
public void test_row_gap_percent_wrapping_with_content_margin_and_padding() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setMargin(YogaEdge.LEFT, 10f);
root.setMargin(YogaEdge.TOP, 10f);
root.setMargin(YogaEdge.RIGHT, 10f);
root.setMargin(YogaEdge.BOTTOM, 10f);
root.setPadding(YogaEdge.LEFT, 10);
root.setPadding(YogaEdge.TOP, 10);
root.setPadding(YogaEdge.RIGHT, 10);
root.setPadding(YogaEdge.BOTTOM, 10);
root.setWidth(300f);
root.setHeight(700f);
root.setGapPercent(YogaGutter.COLUMN, 10f);
root.setGapPercent(YogaGutter.ROW, 10f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(100f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(100f);
root_child2.setHeight(100f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = createNode(config);
root_child3.setWidth(100f);
root_child3.setHeight(100f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = createNode(config);
root_child4.setWidth(100f);
root_child4.setHeight(100f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(10f, root.getLayoutX(), 0.0f);
assertEquals(10f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(138f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child2.getLayoutX(), 0.0f);
assertEquals(178f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(138f, root_child3.getLayoutX(), 0.0f);
assertEquals(178f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child4.getLayoutX(), 0.0f);
assertEquals(346f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(10f, root.getLayoutX(), 0.0f);
assertEquals(10f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(700f, root.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child0.getLayoutX(), 0.0f);
assertEquals(10f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child1.getLayoutX(), 0.0f);
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child2.getLayoutX(), 0.0f);
assertEquals(178f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child3.getLayoutX(), 0.0f);
assertEquals(178f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(190f, root_child4.getLayoutX(), 0.0f);
assertEquals(346f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
}
@Test
public void test_row_gap_percent_wrapping_with_flexible_content() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(300f);
root.setHeight(300f);
root.setGapPercent(YogaGutter.COLUMN, 10f);
root.setGapPercent(YogaGutter.ROW, 10f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexGrow(1f);
root_child0.setFlexShrink(1f);
root_child0.setFlexBasisPercent(0f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root_child1.setFlexBasisPercent(0f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setFlexGrow(1f);
root_child2.setFlexShrink(1f);
root_child2.setFlexBasisPercent(0f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(110f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(220f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(80f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(220f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(80f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(110f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(80f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(80f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_row_gap_percent_wrapping_with_mixed_flexible_content() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(300f);
root.setHeight(300f);
root.setGapPercent(YogaGutter.COLUMN, 10f);
root.setGapPercent(YogaGutter.ROW, 10f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(10f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setFlexGrow(1f);
root_child1.setFlexShrink(1f);
root_child1.setFlexBasisPercent(0f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidthPercent(10f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(270f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(290f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
@Ignore
public void test_row_gap_percent_wrapping_with_min_width() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWrap(YogaWrap.WRAP);
root.setMinWidth(300f);
root.setGapPercent(YogaGutter.COLUMN, 10f);
root.setGapPercent(YogaGutter.ROW, 10f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(100f);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(100f);
root_child1.setHeight(100f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(100f);
root_child2.setHeight(100f);
root.addChildAt(root_child2, 2);
final YogaNode root_child3 = createNode(config);
root_child3.setWidth(100f);
root_child3.setHeight(100f);
root.addChildAt(root_child3, 3);
final YogaNode root_child4 = createNode(config);
root_child4.setWidth(100f);
root_child4.setHeight(100f);
root.addChildAt(root_child4, 4);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(130f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(130f, root_child3.getLayoutX(), 0.0f);
assertEquals(100f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
assertEquals(200f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(300f, root.getLayoutWidth(), 0.0f);
assertEquals(300f, root.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
assertEquals(70f, root_child3.getLayoutX(), 0.0f);
assertEquals(100f, root_child3.getLayoutY(), 0.0f);
assertEquals(100f, root_child3.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child3.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child4.getLayoutX(), 0.0f);
assertEquals(200f, root_child4.getLayoutY(), 0.0f);
assertEquals(100f, root_child4.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child4.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<ebd50ee9980922e7e6f3beabff5375ea>>
* @generated SignedSource<<88d2dd510790179efc539f8d3cba00bb>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGJustifyContentTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGJustifyContentTest {
@@ -837,7 +836,7 @@ public class YGJustifyContentTest {
}
@Test
public void test_justify_content_column_max_height_and_margin() {
public void test_justify_content_colunn_max_height_and_margin() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
@@ -1376,629 +1375,6 @@ public class YGJustifyContentTest {
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_overflow_row_flex_start() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(40f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(40f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(40f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_overflow_row_flex_end() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.FLEX_END);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(40f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(40f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(40f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_overflow_row_center() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.CENTER);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(40f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(40f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(40f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(-9f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(31f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(71f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(71f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(31f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(-9f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_overflow_row_space_between() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.SPACE_BETWEEN);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(40f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(40f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(40f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_overflow_row_space_around() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.SPACE_AROUND);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(40f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(40f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(40f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_overflow_row_space_evenly() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.SPACE_EVENLY);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(40f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(40f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(40f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
@Ignore
public void test_justify_content_overflow_row_reverse_space_around() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root.setJustifyContent(YogaJustify.SPACE_AROUND);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(40f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(40f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(40f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
@Ignore
public void test_justify_content_overflow_row_reverse_space_evenly() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW_REVERSE);
root.setJustifyContent(YogaJustify.SPACE_EVENLY);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(40f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(40f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(40f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_justify_content_overflow_row_space_evenly_auto_margin() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setJustifyContent(YogaJustify.SPACE_EVENLY);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(102f);
root.setHeight(102f);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.RIGHT);
root_child0.setWidth(40f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(40f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(40f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(40f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(102f, root.getLayoutWidth(), 0.0f);
assertEquals(102f, root.getLayoutHeight(), 0.0f);
assertEquals(62f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(22f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(-18f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(40f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(102f, root_child2.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<f9410af3e2849999ef3aec09cebbeef1>>
* @generated SignedSource<<5dd3ad63c5d4b6fcbb3016005e08b162>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGMarginTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGMarginTest {
@@ -697,7 +696,7 @@ public class YGMarginTest {
}
@Test
public void test_margin_auto_multiple_children_column() {
public void test_margin_auto_mutiple_children_column() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
@@ -770,7 +769,7 @@ public class YGMarginTest {
}
@Test
public void test_margin_auto_multiple_children_row() {
public void test_margin_auto_mutiple_children_row() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
@@ -1733,63 +1732,6 @@ public class YGMarginTest {
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
}
@Test
public void test_margin_auto_overflowing_container() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.CENTER);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.BOTTOM);
root_child0.setWidth(50f);
root_child0.setHeight(150f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(150f);
root.addChildAt(root_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(75f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
assertEquals(150f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(75f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(75f, root_child1.getLayoutX(), 0.0f);
assertEquals(150f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(150f, root_child1.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<19cdc4fc9425af726b656ef628bab8af>>
* @generated SignedSource<<857e5626695bb6b524eb6b609a6c7b55>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGMinMaxDimensionTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<6116c0f130b77b635a6551b3204c3cf8>>
* @generated SignedSource<<176b6a98b0b08ef3f3fd20289e8fd089>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGPaddingTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGPaddingTest {
@@ -274,48 +273,6 @@ public class YGPaddingTest {
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_physical_and_relative_edge_defined() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setPadding(YogaEdge.LEFT, 20);
root.setPadding(YogaEdge.END, 50);
root.setWidth(200f);
root.setHeight(200f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidthPercent(100f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(20f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(130f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(200f, root.getLayoutWidth(), 0.0f);
assertEquals(200f, root.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(150f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<27e18496d4ee880d9ba95ad0b2648071>>
* @generated SignedSource<<baefd1632c2e9c66e4c42114856aa74f>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGPercentageTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGPercentageTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<06c18c6b3b9735644daf5b5bd0777eb8>>
* @generated SignedSource<<40959004b04825e4f8f58e8a6d796047>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGRoundingTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGRoundingTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<26e773ec772f84370bc0f3f53d8221ed>>
* @generated SignedSource<<debde6a37b3a2ad5892a15611a2fa8ec>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGSizeOverflowTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGSizeOverflowTest {

View File

@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<997d12880828a3c2881898b769618b43>>
* @generated SignedSource<<3bbbf27ae54f7b245d6adad352761339>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
*/
@@ -16,7 +16,6 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGStaticPositionTest {
@@ -5887,144 +5886,6 @@ public class YGStaticPositionTest {
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_static_position_absolute_child_multiple() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
final YogaNode root_child0 = createNode(config);
root_child0.setPadding(YogaEdge.LEFT, 100);
root_child0.setPadding(YogaEdge.TOP, 100);
root_child0.setPadding(YogaEdge.RIGHT, 100);
root_child0.setPadding(YogaEdge.BOTTOM, 100);
root_child0.setWidth(400f);
root_child0.setHeight(400f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setPositionType(YogaPositionType.STATIC);
root_child0_child0.setWidth(100f);
root_child0_child0.setHeight(100f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = createNode(config);
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child0_child0.setWidthPercent(10f);
root_child0_child0_child0.setHeight(50f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setPositionType(YogaPositionType.STATIC);
root_child0_child1.setWidth(100f);
root_child0_child1.setHeight(100f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child1_child0 = createNode(config);
root_child0_child1_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child1_child0.setWidthPercent(50f);
root_child0_child1_child0.setHeight(50f);
root_child0_child1.addChildAt(root_child0_child1_child0, 0);
final YogaNode root_child0_child1_child1 = createNode(config);
root_child0_child1_child1.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child1_child1.setWidthPercent(50f);
root_child0_child1_child1.setHeight(50f);
root_child0_child1.addChildAt(root_child0_child1_child1, 1);
final YogaNode root_child0_child2 = createNode(config);
root_child0_child2.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child2.setWidth(25f);
root_child0_child2.setHeight(50f);
root_child0.addChildAt(root_child0_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(400f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(400f, root.getLayoutWidth(), 0.0f);
assertEquals(400f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(400f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(60f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(-100f, root_child0_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
assertEquals(-100f, root_child0_child1_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child1.getLayoutY(), 0.0f);
assertEquals(200f, root_child0_child1_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child1_child1.getLayoutHeight(), 0.0f);
assertEquals(275f, root_child0_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
assertEquals(25f, root_child0_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child2.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}

View File

@@ -1,92 +0,0 @@
/*
* 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.
*/
package com.facebook.yoga.utils;
import com.facebook.yoga.YogaMeasureMode;
import com.facebook.yoga.YogaMeasureOutput;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaNode;
public class TestUtils {
public static class intrinsicMeasureFunction implements YogaMeasureFunction {
private static float widthPerChar = 10;
private static float heightPerChar = 10;
@Override
public long measure(
YogaNode node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode) {
String text = (String) node.getData();
float measuredWidth;
float measuredHeight;
if (widthMode == YogaMeasureMode.EXACTLY) {
measuredWidth = width;
} else if (widthMode == YogaMeasureMode.AT_MOST) {
measuredWidth = Math.min(text.length() * widthPerChar, width);
} else {
measuredWidth = text.length() * widthPerChar;
}
if (heightMode == YogaMeasureMode.EXACTLY) {
measuredHeight = height;
} else if (heightMode == YogaMeasureMode.AT_MOST) {
measuredHeight =
Math.min(
caclulateHeight(text, Math.max(measuredWidth, getWidestWordWidth(text))), height);
} else {
measuredHeight = caclulateHeight(text, Math.max(measuredWidth, getWidestWordWidth(text)));
}
return YogaMeasureOutput.make(measuredWidth, measuredHeight);
}
static float getWidestWordWidth(String text) {
int widestWordLength = 0;
String[] words = text.split(" ");
for (String word : words) {
int wordLength = word.length();
if (widestWordLength < wordLength) {
widestWordLength = wordLength;
}
}
return (float) widestWordLength * widthPerChar;
}
static float caclulateHeight(String text, float measuredWidth) {
if (text.length() * widthPerChar <= measuredWidth) {
return heightPerChar;
}
String[] words = text.split(" ");
float lines = 1;
float currentLineLength = 0;
for (String word : words) {
float wordWidth = word.length() * widthPerChar;
if (wordWidth > measuredWidth) {
if (currentLineLength > 0) {
lines++;
}
lines++;
currentLineLength = 0;
} else if (currentLineLength + wordWidth <= measuredWidth) {
currentLineLength += wordWidth + widthPerChar;
} else {
lines++;
currentLineLength = wordWidth + widthPerChar;
}
}
return (currentLineLength == 0 ? lines - 1 : lines) * heightPerChar;
}
}
}

View File

@@ -1,325 +0,0 @@
/*
* 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.
*
* @generated SignedSource<<30103b31d09984d8443cf1ba544adeb7>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAutoTest.html
*/
package com.facebook.yoga;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGAutoTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
return TestParametrization.nodeFactories();
}
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
@Test
public void test_auto_width() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidthAuto();
root.setHeight(50f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(150f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(150f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_auto_height() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(50f);
root.setHeightAuto();
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(150f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(150f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_auto_flex_basis() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(50f);
final YogaNode root_child0 = createNode(config);
root_child0.setWidth(50f);
root_child0.setHeight(50f);
root.addChildAt(root_child0, 0);
final YogaNode root_child1 = createNode(config);
root_child1.setWidth(50f);
root_child1.setHeight(50f);
root.addChildAt(root_child1, 1);
final YogaNode root_child2 = createNode(config);
root_child2.setWidth(50f);
root_child2.setHeight(50f);
root.addChildAt(root_child2, 2);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(150f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(150f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
assertEquals(100f, root_child2.getLayoutY(), 0.0f);
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child2.getLayoutHeight(), 0.0f);
}
@Test
public void test_auto_position() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(50f);
root.setHeight(50f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionAuto(YogaEdge.RIGHT);
root_child0.setWidth(25f);
root_child0.setHeight(25f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_auto_margin() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(50f);
root.setHeight(50f);
final YogaNode root_child0 = createNode(config);
root_child0.setMarginAuto(YogaEdge.LEFT);
root_child0.setWidth(25f);
root_child0.setHeight(25f);
root.addChildAt(root_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(50f, root.getLayoutWidth(), 0.0f);
assertEquals(50f, root.getLayoutHeight(), 0.0f);
assertEquals(25f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(25f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(25f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,107 +0,0 @@
/*
* 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.
*
* @generated SignedSource<<be0d102e74e15f15050520f21afcaee1>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGDisplayContentsTest.html
*/
package com.facebook.yoga;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGDisplayContentsTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
return TestParametrization.nodeFactories();
}
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
@Test
public void test_test1() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setDisplay(YogaDisplay.CONTENTS);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexShrink(1f);
root_child0_child0.setFlexBasisPercent(0f);
root_child0_child0.setHeight(10f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child1 = createNode(config);
root_child0_child1.setFlexGrow(1f);
root_child0_child1.setFlexShrink(1f);
root_child0_child1.setFlexBasisPercent(0f);
root_child0_child1.setHeight(20f);
root_child0.addChildAt(root_child0_child1, 1);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(50f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(50f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0_child1.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,505 +0,0 @@
/*
* 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.
*
* @generated SignedSource<<a7ff8df3045dffe162674b23a62e9abf>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGIntrinsicSizeTest.html
*/
package com.facebook.yoga;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import com.facebook.yoga.utils.TestUtils;
@RunWith(Parameterized.class)
public class YGIntrinsicSizeTest {
@Parameterized.Parameters(name = "{0}")
public static Iterable<TestParametrization.NodeFactory> nodeFactories() {
return TestParametrization.nodeFactories();
}
@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;
@Test
public void test_contains_inner_text_long_word() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root.addChildAt(root_child0, 0);
root_child0.setData("LoremipsumdolorsitametconsecteturadipiscingelitSedeleifasdfettortoracauctorFuscerhoncusipsumtemporerosaliquamconsequatPraesentsoda");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(1300f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(700f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(1300f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_no_width_no_height() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(2000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(70f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(2000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(70f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_no_width_no_height_long_word_in_paragraph() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus loremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumloremipsumlorem Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(2000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(70f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(2000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(70f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_fixed_width() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setWidth(100f);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(1290f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(1900f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(1290f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_no_width_fixed_height() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setHeight(20f);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(2000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(2000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_fixed_width_fixed_height() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setWidth(50f);
root_child0.setHeight(20f);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(1950f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_max_width_max_height() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setMaxWidth(50f);
root_child0.setMaxHeight(20f);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(1950f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_max_width() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setMaxWidth(100f);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(1290f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(1900f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(1290f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_fixed_width_shorter_text() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setWidth(100f);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(1900f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_fixed_height_shorter_text() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setHeight(100f);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(110f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(1890f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(110f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_contains_inner_text_max_height() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setAlignItems(YogaAlign.FLEX_START);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(2000f);
root.setHeight(2000f);
final YogaNode root_child0 = createNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setMaxHeight(20f);
root.addChildAt(root_child0, 0);
root_child0.setData("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eleifasd et tortor ac auctor. Integer at volutpat libero, sed elementum dui interdum id. Aliquam consectetur massa vel neque aliquet, quis consequat risus fringilla. Fusce rhoncus ipsum tempor eros aliquam, vel tempus metus ullamcorper. Nam at nulla sed tellus vestibulum fringilla vel sit amet ligula. Proin velit lectus, euismod sit amet quam vel ultricies dolor, vitae finibus lorem ipsum. Pellentesque molestie at mi sit amet dictum. Donec vehicula lacinia felis sit amet consectetur. Praesent sodales enim sapien, sed varius ipsum pellentesque vel. Aenean eu mi eu justo tincidunt finibus vel sit amet ipsum. Sed bibasdum purus vel ipsum sagittis, quis fermentum dolor lobortis. Etiam vulputate eleifasd lectus vel varius. Phasellus imperdiet lectus sit amet ipsum egestas, ut bibasdum ipsum malesuada. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed mollis eros sit amet elit porttitor, vel venenatis turpis venenatis. Nulla tempus tortor at eros efficitur, sit amet dapibus ipsum malesuada. Ut at mauris sed nunc malesuada convallis. Duis id sem vel magna varius eleifasd vel at est. Donec eget orci a ipsum tempor lobortis. Sed at consectetur ipsum.");
root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction());
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(2000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(2000f, root.getLayoutWidth(), 0.0f);
assertEquals(2000f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(2000f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
}

View File

@@ -13,17 +13,17 @@ const {
logger,
jestTask,
option,
parallel,
series,
spawn,
task,
tscTask,
copyTask,
} = require('just-scripts');
const {existsSync} = require('fs');
const {readFile, writeFile, rm} = require('fs/promises');
const {glob} = require('glob');
const glob = require('glob');
const path = require('path');
const which = require('which');
@@ -58,32 +58,16 @@ task('prepack-package-json', async () => {
const packageJsonContents = await readFile(packageJsonPath);
const packageJson = JSON.parse(packageJsonContents.toString('utf-8'));
packageJson.main = packageJson.main.replace(
/^.\/src\/(.*)\.ts/,
'./dist/src/$1.js',
);
packageJson.types = packageJson.main.replace(/(.*)\.js/, '$1.d.ts');
recursiveReplace(
packageJson.exports,
/^.\/src\/(.*)\.ts/,
'./dist/src/$1.js',
);
recursiveReplace(packageJson, /(.\/src\/.*)\.ts/, '$1.js');
packageJson.types = packageJson.main.replace(/(.\/src\/.*)\.js/, '$1.d.ts');
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2));
});
task(
'prepack',
series(
'build',
copyTask({paths: ['binaries'], dest: 'dist/binaries'}),
tscTask({
emitDeclarationOnly: true,
rootDir: '.',
declarationDir: 'dist',
}),
babelTransformTask({src: 'src', dst: 'dist/src'}),
parallel('build', tscTask({emitDeclarationOnly: true})),
babelTransformTask({dir: 'src'}),
'prepack-package-json',
),
);
@@ -101,14 +85,14 @@ function recursiveReplace(obj, pattern, replacement) {
function babelTransformTask(opts) {
return () => {
const args = [
opts.src,
opts.dir,
'--source-maps',
'--out-dir',
opts.dst,
opts.dir,
'--extensions',
'.js,.cjs,.mjs,.ts,.cts,.mts',
];
logger.info(`Transforming "${path.resolve(opts.src)}"`);
logger.info(`Transforming "${path.resolve(opts.dir)}"`);
return spawn(node, [require.resolve('@babel/cli/bin/babel'), ...args], {
cwd: __dirname,
@@ -168,9 +152,9 @@ function installEmsdkTask() {
{stdio: 'inherit'},
);
await spawnShell(emsdkBin, ['install', emsdkVersion], {stdio: 'inherit'});
await spawn(emsdkBin, ['install', emsdkVersion], {stdio: 'inherit'});
await spawnShell(emsdkBin, ['activate', emsdkVersion], {
await spawn(emsdkBin, ['activate', emsdkVersion], {
stdio: logger.enableVerbose ? 'inherit' : 'ignore',
});
};
@@ -216,7 +200,7 @@ function emcmakeGenerateTask() {
];
logger.info(['emcmake', ...args].join(' '));
return spawnShell(emcmakeBin, args, {
return spawn(emcmakeBin, args, {
stdio: logger.enableVerbose ? 'inherit' : 'ignore',
});
};
@@ -234,7 +218,7 @@ function cmakeBuildTask(opts) {
];
logger.info(['cmake', ...args].join(' '));
return spawnShell(cmake, args, {stdio: 'inherit'});
return spawn(cmake, args, {stdio: 'inherit'});
};
}
@@ -246,13 +230,8 @@ function clangFormatTask(opts) {
];
logger.info(['clang-format', ...args].join(' '));
return spawnShell(node, [require.resolve('clang-format'), ...args], {
return spawn(node, [require.resolve('clang-format'), ...args], {
stdio: 'inherit',
});
};
}
function spawnShell(cmd, args, opts) {
// https://github.com/nodejs/node/issues/52554
return spawn(cmd, args, {...opts, shell: true});
}

View File

@@ -1,6 +1,6 @@
{
"name": "yoga-layout",
"version": "3.2.1",
"version": "3.0.3",
"description": "An embeddable and performant flexbox layout engine with bindings for multiple languages",
"license": "MIT",
"author": "Meta Open Source",
@@ -11,14 +11,12 @@
},
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"exports": {
".": "./src/index.ts",
"./load": "./src/load.ts"
},
"files": [
"dist/binaries/**",
"dist/src/**",
"binaries/**",
"src/**"
],
"scripts": {
@@ -38,13 +36,14 @@
"@babel/core": "^7.23.0",
"@babel/preset-env": "^7.23.0",
"@babel/preset-typescript": "^7.23.0",
"@types/glob": "^8.1.0",
"@types/jest": "^29.5.1",
"@types/node": "^16.18.25",
"@types/which": "^3.0.0",
"@yogalayout/cmake-bin": "3.28.0-1",
"babel-register-esm": "^1.2.5",
"clang-format": "^1.8.0",
"glob": "^10.4.2",
"glob": "^8.0.3",
"jest": "^29.3.1",
"just-scripts": "^2.1.0",
"ninja-binaries": "^1.11.1",

View File

@@ -75,10 +75,6 @@ void Node::copyStyle(Node const& other) {
YGNodeCopyStyle(m_node, other.m_node);
}
void Node::setBoxSizing(int boxSizing) {
YGNodeStyleSetBoxSizing(m_node, static_cast<YGBoxSizing>(boxSizing));
}
void Node::setPositionType(int positionType) {
YGNodeStyleSetPositionType(m_node, static_cast<YGPositionType>(positionType));
}
@@ -91,10 +87,6 @@ void Node::setPositionPercent(int edge, double position) {
YGNodeStyleSetPositionPercent(m_node, static_cast<YGEdge>(edge), position);
}
void Node::setPositionAuto(int edge) {
YGNodeStyleSetPositionAuto(m_node, static_cast<YGEdge>(edge));
}
void Node::setAlignContent(int alignContent) {
YGNodeStyleSetAlignContent(m_node, static_cast<YGAlign>(alignContent));
}
@@ -112,10 +104,6 @@ void Node::setFlexDirection(int flexDirection) {
m_node, static_cast<YGFlexDirection>(flexDirection));
}
void Node::setDirection(int direction) {
YGNodeStyleSetDirection(m_node, static_cast<YGDirection>(direction));
}
void Node::setFlexWrap(int flexWrap) {
YGNodeStyleSetFlexWrap(m_node, static_cast<YGWrap>(flexWrap));
}
@@ -248,14 +236,6 @@ void Node::setGap(int gutter, double gapLength) {
YGNodeStyleSetGap(m_node, static_cast<YGGutter>(gutter), gapLength);
}
void Node::setGapPercent(int gutter, double gapLength) {
YGNodeStyleSetGapPercent(m_node, static_cast<YGGutter>(gutter), gapLength);
}
int Node::getBoxSizing(void) const {
return YGNodeStyleGetBoxSizing(m_node);
}
int Node::getPositionType(void) const {
return YGNodeStyleGetPositionType(m_node);
}
@@ -281,10 +261,6 @@ int Node::getFlexDirection(void) const {
return YGNodeStyleGetFlexDirection(m_node);
}
int Node::getDirection(void) const {
return YGNodeStyleGetDirection(m_node);
}
int Node::getFlexWrap(void) const {
return YGNodeStyleGetFlexWrap(m_node);
}

View File

@@ -76,7 +76,6 @@ class Node {
void setPositionType(int positionType);
void setPosition(int edge, double position);
void setPositionPercent(int edge, double position);
void setPositionAuto(int edge);
void setAlignContent(int alignContent);
void setAlignItems(int alignItems);
@@ -84,7 +83,6 @@ class Node {
void setFlexDirection(int flexDirection);
void setFlexWrap(int flexWrap);
void setJustifyContent(int justifyContent);
void setDirection(int direction);
void setMargin(int edge, double margin);
void setMarginPercent(int edge, double margin);
@@ -125,9 +123,6 @@ class Node {
void setPaddingPercent(int edge, double padding);
void setGap(int gutter, double gapLength);
void setGapPercent(int gutter, double gapLength);
void setBoxSizing(int boxSizing);
public: // Style getters
int getPositionType(void) const;
@@ -139,7 +134,6 @@ class Node {
int getFlexDirection(void) const;
int getFlexWrap(void) const;
int getJustifyContent(void) const;
int getDirection(void) const;
Value getMargin(int edge) const;
@@ -167,8 +161,6 @@ class Node {
float getGap(int gutter);
int getBoxSizing(void) const;
public: // Tree hierarchy mutators
void insertChild(Node* child, unsigned index);
void removeChild(Node* child);

View File

@@ -70,7 +70,6 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("setPositionType", &Node::setPositionType)
.function("setPosition", &Node::setPosition)
.function("setPositionPercent", &Node::setPositionPercent)
.function("setPositionAuto", &Node::setPositionAuto)
.function("setAlignContent", &Node::setAlignContent)
.function("setAlignItems", &Node::setAlignItems)
@@ -110,8 +109,6 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("setMaxHeight", &Node::setMaxHeight)
.function("setMaxHeightPercent", &Node::setMaxHeightPercent)
.function("setBoxSizing", &Node::setBoxSizing)
.function("setAspectRatio", &Node::setAspectRatio)
.function("setBorder", &Node::setBorder)
@@ -119,9 +116,6 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("setPadding", &Node::setPadding)
.function("setPaddingPercent", &Node::setPaddingPercent)
.function("setGap", &Node::setGap)
.function("setGapPercent", &Node::setGapPercent)
.function("setDirection", &Node::setDirection)
.function("getPositionType", &Node::getPositionType)
.function("getPosition", &Node::getPosition)
@@ -148,8 +142,6 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("getMaxWidth", &Node::getMaxWidth)
.function("getMaxHeight", &Node::getMaxHeight)
.function("getBoxSizing", &Node::getBoxSizing)
.function("getAspectRatio", &Node::getAspectRatio)
.function("getBorder", &Node::getBorder)
@@ -201,7 +193,5 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("getComputedMargin", &Node::getComputedMargin)
.function("getComputedBorder", &Node::getComputedBorder)
.function("getComputedPadding", &Node::getComputedPadding)
.function("getDirection", &Node::getDirection);
.function("getComputedPadding", &Node::getComputedPadding);
}

View File

@@ -19,11 +19,6 @@ export enum Align {
SpaceEvenly = 8,
}
export enum BoxSizing {
BorderBox = 0,
ContentBox = 1,
}
export enum Dimension {
Width = 0,
Height = 1,
@@ -38,7 +33,6 @@ export enum Direction {
export enum Display {
Flex = 0,
None = 1,
Contents = 2,
}
export enum Edge {
@@ -56,7 +50,7 @@ export enum Edge {
export enum Errata {
None = 0,
StretchFlexBasis = 1,
AbsolutePositionWithoutInsetsExcludesPadding = 2,
AbsolutePositioningIncorrect = 2,
AbsolutePercentAgainstInnerSize = 4,
All = 2147483647,
Classic = 2147483646,
@@ -143,8 +137,6 @@ const constants = {
ALIGN_SPACE_BETWEEN: Align.SpaceBetween,
ALIGN_SPACE_AROUND: Align.SpaceAround,
ALIGN_SPACE_EVENLY: Align.SpaceEvenly,
BOX_SIZING_BORDER_BOX: BoxSizing.BorderBox,
BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox,
DIMENSION_WIDTH: Dimension.Width,
DIMENSION_HEIGHT: Dimension.Height,
DIRECTION_INHERIT: Direction.Inherit,
@@ -152,7 +144,6 @@ const constants = {
DIRECTION_RTL: Direction.RTL,
DISPLAY_FLEX: Display.Flex,
DISPLAY_NONE: Display.None,
DISPLAY_CONTENTS: Display.Contents,
EDGE_LEFT: Edge.Left,
EDGE_TOP: Edge.Top,
EDGE_RIGHT: Edge.Right,
@@ -164,7 +155,7 @@ const constants = {
EDGE_ALL: Edge.All,
ERRATA_NONE: Errata.None,
ERRATA_STRETCH_FLEX_BASIS: Errata.StretchFlexBasis,
ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING: Errata.AbsolutePositionWithoutInsetsExcludesPadding,
ERRATA_ABSOLUTE_POSITIONING_INCORRECT: Errata.AbsolutePositioningIncorrect,
ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE: Errata.AbsolutePercentAgainstInnerSize,
ERRATA_ALL: Errata.All,
ERRATA_CLASSIC: Errata.Classic,

View File

@@ -14,7 +14,6 @@ import YGEnums from './generated/YGEnums.ts';
import type {
Align,
BoxSizing,
Display,
Edge,
Errata,
@@ -96,7 +95,6 @@ export type Node = {
getComputedRight(): number;
getComputedTop(): number;
getComputedWidth(): number;
getDirection(): Direction;
getDisplay(): Display;
getFlexBasis(): Value;
getFlexDirection(): FlexDirection;
@@ -116,7 +114,6 @@ export type Node = {
getParent(): Node | null;
getPosition(edge: Edge): Value;
getPositionType(): PositionType;
getBoxSizing(): BoxSizing;
getWidth(): Value;
insertChild(child: Node, index: number): void;
isDirty(): boolean;
@@ -131,7 +128,6 @@ export type Node = {
setAlignSelf(alignSelf: Align): void;
setAspectRatio(aspectRatio: number | undefined): void;
setBorder(edge: Edge, borderWidth: number | undefined): void;
setDirection(direction: Direction): void;
setDisplay(display: Display): void;
setFlex(flex: number | undefined): void;
setFlexBasis(flexBasis: number | 'auto' | `${number}%` | undefined): void;
@@ -146,8 +142,7 @@ export type Node = {
setHeightAuto(): void;
setHeightPercent(height: number | undefined): void;
setJustifyContent(justifyContent: Justify): void;
setGap(gutter: Gutter, gapLength: number | `${number}%` | undefined): Value;
setGapPercent(gutter: Gutter, gapLength: number | undefined): Value;
setGap(gutter: Gutter, gapLength: number | undefined): Value;
setMargin(
edge: Edge,
margin: number | 'auto' | `${number}%` | undefined,
@@ -170,8 +165,6 @@ export type Node = {
setPosition(edge: Edge, position: number | `${number}%` | undefined): void;
setPositionPercent(edge: Edge, position: number | undefined): void;
setPositionType(positionType: PositionType): void;
setPositionAuto(edge: Edge): void;
setBoxSizing(boxSizing: BoxSizing): void;
setWidth(width: number | 'auto' | `${number}%` | undefined): void;
setWidthAuto(): void;
setWidthPercent(width: number | undefined): void;
@@ -214,7 +207,6 @@ export default function wrapAssembly(lib: any): Yoga {
'setMaxWidth',
'setMaxHeight',
'setPadding',
'setGap',
]) {
const methods = {
[Unit.Point]: lib.Node.prototype[fnName],

View File

@@ -4,15 +4,13 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9deb466dfc94bb340137a9e6b5d5c63d>>
* @generated SignedSource<<777a238fc942436d2c803822110bcd07>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
*/
import { instrinsicSizeMeasureFunc } from '../tools/utils.ts'
import Yoga from 'yoga-layout';
import {
Align,
BoxSizing,
Direction,
Display,
Edge,
@@ -76,150 +74,6 @@ test('absolute_layout_width_height_start_top', () => {
config.free();
}
});
test('absolute_layout_width_height_left_auto_right', () => {
const config = Yoga.Config.create();
let root;
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Absolute);
root_child0.setPositionAuto(Edge.Left);
root_child0.setPosition(Edge.Right, 10);
root_child0.setWidth(10);
root_child0.setHeight(10);
root.insertChild(root_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(80);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(80);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('absolute_layout_width_height_left_right_auto', () => {
const config = Yoga.Config.create();
let root;
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Absolute);
root_child0.setPosition(Edge.Left, 10);
root_child0.setPositionAuto(Edge.Right);
root_child0.setWidth(10);
root_child0.setHeight(10);
root.insertChild(root_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(10);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(10);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('absolute_layout_width_height_left_auto_right_auto', () => {
const config = Yoga.Config.create();
let root;
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Absolute);
root_child0.setPositionAuto(Edge.Left);
root_child0.setPositionAuto(Edge.Right);
root_child0.setWidth(10);
root_child0.setHeight(10);
root.insertChild(root_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(90);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('absolute_layout_width_height_end_bottom', () => {
const config = Yoga.Config.create();
let root;
@@ -1643,172 +1497,6 @@ test('absolute_layout_padding_bottom', () => {
config.free();
}
});
test('absolute_layout_padding', () => {
const config = Yoga.Config.create();
let root;
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
const root_child0 = Yoga.Node.create(config);
root_child0.setMargin(Edge.Left, 10);
root_child0.setMargin(Edge.Top, 10);
root_child0.setMargin(Edge.Right, 10);
root_child0.setMargin(Edge.Bottom, 10);
root_child0.setWidth(200);
root_child0.setHeight(200);
root.insertChild(root_child0, 0);
const root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setPositionType(PositionType.Static);
root_child0_child0.setPadding(Edge.Left, 50);
root_child0_child0.setPadding(Edge.Top, 50);
root_child0_child0.setPadding(Edge.Right, 50);
root_child0_child0.setPadding(Edge.Bottom, 50);
root_child0_child0.setWidth(200);
root_child0_child0.setHeight(200);
root_child0.insertChild(root_child0_child0, 0);
const root_child0_child0_child0 = Yoga.Node.create(config);
root_child0_child0_child0.setPositionType(PositionType.Absolute);
root_child0_child0_child0.setWidth(50);
root_child0_child0_child0.setHeight(50);
root_child0_child0.insertChild(root_child0_child0_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(220);
expect(root.getComputedHeight()).toBe(220);
expect(root_child0.getComputedLeft()).toBe(10);
expect(root_child0.getComputedTop()).toBe(10);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0.getComputedLeft()).toBe(0);
expect(root_child0_child0.getComputedTop()).toBe(0);
expect(root_child0_child0.getComputedWidth()).toBe(200);
expect(root_child0_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0_child0.getComputedLeft()).toBe(50);
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(220);
expect(root.getComputedHeight()).toBe(220);
expect(root_child0.getComputedLeft()).toBe(10);
expect(root_child0.getComputedTop()).toBe(10);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0.getComputedLeft()).toBe(0);
expect(root_child0_child0.getComputedTop()).toBe(0);
expect(root_child0_child0.getComputedWidth()).toBe(200);
expect(root_child0_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0_child0.getComputedLeft()).toBe(100);
expect(root_child0_child0_child0.getComputedTop()).toBe(50);
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('absolute_layout_border', () => {
const config = Yoga.Config.create();
let root;
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
const root_child0 = Yoga.Node.create(config);
root_child0.setMargin(Edge.Left, 10);
root_child0.setMargin(Edge.Top, 10);
root_child0.setMargin(Edge.Right, 10);
root_child0.setMargin(Edge.Bottom, 10);
root_child0.setWidth(200);
root_child0.setHeight(200);
root.insertChild(root_child0, 0);
const root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setPositionType(PositionType.Static);
root_child0_child0.setBorder(Edge.Left, 10);
root_child0_child0.setBorder(Edge.Top, 10);
root_child0_child0.setBorder(Edge.Right, 10);
root_child0_child0.setBorder(Edge.Bottom, 10);
root_child0_child0.setWidth(200);
root_child0_child0.setHeight(200);
root_child0.insertChild(root_child0_child0, 0);
const root_child0_child0_child0 = Yoga.Node.create(config);
root_child0_child0_child0.setPositionType(PositionType.Absolute);
root_child0_child0_child0.setWidth(50);
root_child0_child0_child0.setHeight(50);
root_child0_child0.insertChild(root_child0_child0_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(220);
expect(root.getComputedHeight()).toBe(220);
expect(root_child0.getComputedLeft()).toBe(10);
expect(root_child0.getComputedTop()).toBe(10);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0.getComputedLeft()).toBe(0);
expect(root_child0_child0.getComputedTop()).toBe(0);
expect(root_child0_child0.getComputedWidth()).toBe(200);
expect(root_child0_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0_child0.getComputedLeft()).toBe(10);
expect(root_child0_child0_child0.getComputedTop()).toBe(10);
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(220);
expect(root.getComputedHeight()).toBe(220);
expect(root_child0.getComputedLeft()).toBe(10);
expect(root_child0.getComputedTop()).toBe(10);
expect(root_child0.getComputedWidth()).toBe(200);
expect(root_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0.getComputedLeft()).toBe(0);
expect(root_child0_child0.getComputedTop()).toBe(0);
expect(root_child0_child0.getComputedWidth()).toBe(200);
expect(root_child0_child0.getComputedHeight()).toBe(200);
expect(root_child0_child0_child0.getComputedLeft()).toBe(140);
expect(root_child0_child0_child0.getComputedTop()).toBe(10);
expect(root_child0_child0_child0.getComputedWidth()).toBe(50);
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('absolute_layout_column_reverse_margin_border', () => {
const config = Yoga.Config.create();
let root;

Some files were not shown because too many files have changed in this diff Show More